Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Suppose, I have four different entities in our c# design system.

 1. Organization
 2. Class
 3. Course
 4. Students

Now, I have to pull the above entities data from the third party API and store in our system.

I have created the four different business access classes of above entities which will have common pull method.

    Public bool PullFromThirdPartyApi()
    {
    //Logic goes here
    }

So far, I can use the factory design pattern for it but problem will arise when business class may contains different functions.

Suppose, Organization and Class business access contains extra below method which Course and Students business Class may not contain.

    Public bool PullByIDFromThirdPartyApi()
    {
      //Logic goes here
    }

Please suggest the suitable design pattern here with approach.

What I have tried:

I have tried with factory design pattern which is not suitable if it extends further as mentioned in question description.
Posted
Updated 13-Dec-18 3:25am
v3
Comments
BillWoodruff 13-Dec-18 15:31pm    
Have you considered forcing Classes to implement a common Interface ?
Graeme_Grant 14-Dec-18 1:59am    
This smells of school homework or assignment ...
[no name] 14-Dec-18 11:42am    
Your explanations for doing / not doing something make no sense.

The API supplies a particular entity (/ interface) or it does not. Period.

1 solution

Maybe this will be of help: Factory Method Pattern vs. Abstract Factory Pattern[^]
If you want to learn about other patterns from the original "Gang of four" then DZone has a nice refcard about it (you will need to sign in, it's free):
https://dzone.com/refcardz/design-patterns?chapter=1[^]
 
Share this answer
 
v2

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