Click here to Skip to main content
15,891,409 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a requirement and i am addled to which pattern i must go for.

Requirement : I have 3 methods namely PopulateAccountBalance(), PopulatePayeeAccount() and PopulateDistributionDate(). Here the two methods PopulateAccountBalance() and PopulatePayeeAccount() implementation is going to vary based on 3 GroupTypes namely Group1 , Group2 and Group 3.

I know i can go either for Strategy Pattern OR a normal abstract classes with Parent-child relationship where base class acts as parent and 3 separate child classes for each Group.

In the second choice the base class will be an abstract class and will hold common method PopulateDistributionDate() being implemented and the other two methods which gonna vary based on child class will be abstract methods. It is the duty of the child classes to implement abstract methods on their way.

Now which way should i follow. Whether shall i go for Strategy pattern or Abstract class way.
Posted

1 solution

I would go for Abstract class way (Second Method).

Update:

It is difficult to justify. It is definitely upto your business need.

One clear advantage is you can have partial or full implementation of the methods in the base class itself.

You can read the following articles to get more information:

Abstract Class versus Interface[^]

MSDN Reference[^]

Mark it as answer if it is helpful
 
Share this answer
 
v3
Comments
sri_3464 10-Jan-11 5:22am    
can you please justify.. i tried googling to know about it.. not getting the satisfying reason
Venkatesh Mookkan 10-Jan-11 5:34am    
I have updated the answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900