Reputation: 51
Can you suggest some good design pattern for below scenario:
We have multiple vendors, called Company A, B and C. Each company has their own business logic.
Upvotes: 2
Views: 153
Reputation: 38910
If your business logic is related to creation of different objects
for different vendors, you can use Factory Method / Factory_ patterns.
If your business logic is related to change behaviour of system
for different vendors, you can use Strategy_pattern
Refer to related SE questions for more details about these patterns:
Real World Example of the Strategy Pattern
What is the basic difference between the Factory and Abstract Factory Patterns?
What is the difference between Factory and Strategy patterns?
Upvotes: 0
Reputation: 363
For this you can use the following patterns
also consider this following diagram.
Upvotes: 0
Reputation: 11163
You may use an interface, CompanyTemplate
which will contains all the common methods that should be implemented by company A
, B
and C
-
public interface CompanyTemplate{
public someCommonMethod();
}
After that A
can inplement CompanyTemplate
-
public class A implements `CompanyTemplate` {
public void someCommonMethod(){
//implementation code
}
//Other methods special only for company for A
}
Upvotes: 0