c# - 2 Product lines sharing same code -


After

We are working on two product lines that will share the same code.

For different functionality, I have applied the same interface to both product lines (in some case or base class) and these types of main classes (which are different for both product lines) Will be passed and forward downstream

For deep code inside business logic, it is very difficult to be product line-specific code we do not want to do for the user (Productline == "ProductLine1") and the rest of the operating system.

Then I'm planning to apply for a factory class which will have static methods NewObject1 (), NewObject2 (go back) and prompt. . This factory will be registered in the main category in the form of Factory.RegisterClient (ProductLine1)

With the above approach, then the factory (which internally includes ProductLine1Factor & ProductLine2Factory) make the types of objects Who knows for

Do you know a better approach to this problem, please note that ProductLine1 already existed and ProductLine2 is something new (but productive 1 is equal to 90%). We can not rigid refactoring that both the product lines are present. We want to make the least offensive code changes as possible.

In the factory's perspective, an interface is usually exposed, but the problem with the interface is that I can not even highlight the static types which are also necessary. > I really appreciate, some experts will be shining some light.

Your approach looks okay.

Instead of a custom factory, why do not you use a fully developed IOC framework like Ninject or Unity? You can implement this service twice for every customer, and choose one in the container configuration file, steady. In this way, you do not even need to change a line of your code, if you add another implementation, then you just reconfigure it, that is, make some changes to the XML file.

However, an IOC container is just a tool, whether or not it is used, it is in place of your factory (IOC container is sometimes called "factories on steroids").

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -