This is in C#
I have a complex object (class A) that requires its properties to be set and some validation to occur.
This class (class A) inherits from another class (class B) and overrides certain methods and fields. I cannot avoid inheriting from this base class and I cannot introduce dependency injection into these two classes.
I have another class (class C) that I want to build that will take in some values, perform some validation, then construct objects of type class A setting parameters based on certain logic.
Class A would also have some of its own validation logic.
I’ve looked into the builder pattern and strategy pattern. I’m not sure if these are going overboard or just aren’t correct.
My end result would be class A being constructed with slightly different properties being passed into class C. Example:
Class C classC = new classC(string properties) classC.SubmitObjects();
The above code would do the following:
Construct two objects of class A.
Submit those two objects to some other process. Validation occurs in Class C and in Class A.
Now that I’ve typed this out it seems like the builder pattern makes sense — but since I have a total of 4 different variations of class A (different properties) would I need 4 different classes that all implement the same interface as class A?