3 ms·
I disagree with you about namespaces. I find Java's packages more useful since they give you access control which increases encapsulation. If I want a factory m
by guelo 9y ago
I disagree with you about namespaces. I find Java's packages more useful since they give you access control which increases encapsulation. If I want a factory method guarding the instantiation of a class in java I can make the factory public and the class package private. In C# the only answer for this type of encapsulation are assemblies but they're much heavier weight and it is recommended not to have too many of them in a project.
- BitterAmethyst 9y agoYou can make the constructors on the class private and have a public static method on the class that does the instantiation.
- guelo 9y agoFor the simple case yes. But if you want several classes cooperating, maybe helpers or related data classes, your options are assemblies or like you said to shove everything into one giant class. You have less flexibility of separating things out.