New answers tagged

1

You have brought up questions about two SOLID principles. The first is about the Single Reponsibility Principle. And now I doubt if I should add a isAdjacentTo(Node) method to the GraphEdge class or I should create a GraphUtil class(*) and add static edgeIsAdjacentToNode(Edge,Node) method to it. The question that you should ask yourself about this is ...


1

TL;DR This phrase would help remind one not to apply SRP prematurely: A good separation of responsibilities is done only when the full picture of how the application should work is well understand. Source: http://www.oodesign.com/single-responsibility-principle.html API Requirements Phase These are given as examples. Cross out ones that are not ...


0

The Single Responsibility Principal states that a class should only have one reason to change. If your class has multiple reasons to change, then you can split it out into other classes and utilize composition to eliminate this problem. To answer your question, I have to ask you a question: Does your class have only one reason to change? If not, then don't ...


21

The single responsibility principle can be tricky to understand. What I've found useful is to think of it like how you write sentences. You don't try to cram a lot of ideas into a single sentence. Each sentence should state one idea clearly and defer the details. For example, if you wanted to define a car, you would say: A road vehicle, typically with ...


6

Update (recap) Since I've written a rather verbose answer, here's what it all boils down to: Namespaces are good, use them whenever it makes sense Using inGameIO and playerIO classes would likely constitute a breach of the SRP. It likely means you're coupling the way you handle IO with the application logic. Have a couple of generic IO classes, that are ...


2

I'd say that the best way to go is to keep them in separate classes. Small classes are not bad, in fact most of the time they're a good idea. Regarding your specific case I think that having the separated can help you change the logic of any of those specific handlers without affecting the others and, if necessary, it would be easier for you to add new ...


2

This would depend on the size and complexity of the form/application. We can keep it simple until the code uses fixed values and stretches to minimum lines. Listing few points below, if answer to any of them is 'yes' then it would be better to separate the concern. You have started to repeat the code. The logic of finding the position is complex e.g. ...



Top 50 recent answers are included