Considerations

You should keep in mind that the delegation pattern introduces a new level of indirection, which can increase code complexity and make the code more difficult to understand. We should consider some factors when deciding to use the delegation pattern.

First, how much code can you reuse from the existing component? Is it 20%, 50%, or 80%? This ought to be the very first question you ask before you consider reusing an existing component. Let's call the amount of reuse the utilization rate. Obviously, the higher the utilization rate, the better it is from a reuse perspective.

Second, how much development effort can be saved by reusing an existing component? If the cost of developing the same functionality is low, then it may not be worth the effort to reuse the component and increase the complexity of extra indirection. 

From the opposite angle, we should also review if there is any critical business logic in the existing component. If we decide to not reuse the component, then we could end up implementing the same logic again, violating the Don't Repeat Yourself (DRYprinciple. This means it can be a maintenance nightmare to not reuse the component.

Given these considerations, we should just to make a good judgment about using the delegation pattern or not. 

Next, we will learn how to implement traits in Julia.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.246.203