Here is what you need to know in order to understand the question:
- I want to connect the SCL class to the Region class.
- Now I have many different ways in which I want to connect an instance of these 2 classes.
- Writing is java
- Global variables not used
Therefore, I can either create several classes (around 9) that use polymorphism, but then each class has only one method called connect (...) with many different parameter lists. I think this is called a functor class.
For example, the class "SCLToRegionOverlapCircleConnect" will have a connection method that looks like
public void connect(SCL scl, Region region, int radius, int overlapPercentage) {...}
while the class "RegionToRegionNonOverlapSquareConnect" will have a connection method that looks like
public void connect(Region bottomRegion, Region topRegion, int sideLength) {...}
OR
I can just create one class called ConnectionTypes and just have 9 different methods, each with a different method signature.
What are the PRO and CON of each implementation? Thanks!
Q Liu source share