![]() Option 2 is appealing to me, but now I have muddied the waters between the ModelMain and the sub-models. But as I am tending to 1:1 ratio because of my IoC choice/usage (and that may be debatable) this has advantages in seeing the relationship between the files. I sort of dislike option 1 because of the class name in the path. Option 4 - Taking the functionality example further MySolution Option 3 - Seperating Interface and Implementation MySolution Option 2 - Organized by functionality (mostly) MySolution Option 1 - Organized by class name MySolution ![]() Should I keep the class and interface together? Or should I keep classes and interfaces together? EG: The question is about how to organize my solution. Thus code wise I end up with 2: public interface ICommonFunc However it does not mean that I am slavishly writing an interface for each and every class I write. Because each of my classes performs different (and-non-overlapping) functionality this means that there is a 1:1 ratio between interface and class 1. This implies that for every object I want to instantiate from Unity, there has to be a matching interface. I don't pretend to be an expert in it, but my understanding of it is that you register a tuple of interface and class with the container and when you want a concrete class you ask the IoC container for whatever object matches a specific interface. The IoC container that I am using is Microsoft Unity. The two models are instantiated within the ModelMain class (which itself is instantiated at a higher level etc - but I am stopping at this level). However I have a third class CommonFunc that contains some public functionality that is implemented in both ModelOne and ModelTwo and has been factored out as per DRY. ![]() I have two classes ModelOne and ModelTwo, These classes perform similar type of functionality but are unrelated to each other. after all the discussion I'm changing my question slightly to better reflect a concrete example that I am dealing with. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |