4 ms·
I am not a big fan of 'Solid'. Some of them are true but of the category 'water is wet'. I.e., the SRP principle. Others don't seem useful. The open-closed prin
by cjfd 7y ago
I am not a big fan of 'Solid'. Some of them are true but of the category 'water is wet'. I.e., the SRP principle. Others don't seem useful. The open-closed principle, for instance. All software should be adaptable and we generally don't know what requests are going to come from the field so we cannot write parts of software to never be changed. Perhaps you think that
bool is_prime(int n)
is never going to change but someday somebody is going to request that it can report progress during its calculation. So really, you can never know.
Also, these things with dependency injection and interfaces. Please, only introduce these complications when you can prove that you need them. The software will be complicated enough when it is satisfying all its requirements. It is unnecessary to invent complications for no reason.
- croo 7y agoIf SRP is akin to water is wet I'm working with newborns. What is so trivial about what to do in a class? Deciding where to put what is one of the hardest part of the job...
- cjfd 7y agoWhat to do in a class may not be entirely trivial but also not that complicated. What is trivial is noticing that a class is doing too many things. The problem is actually doing something about it. This seems in many case to be more of a discipline problem than it actually being that hard. I also have seen that people are trying to do too much. When one sees a problem many have the inclination to want to refactor everything at once and also redesign an entire program. A more productive way is to do one small refactoring that solves just one code quality issue at a time. Before you know it you have done 5 or 10 small refactorings and things are starting to look much better. The big refactoring is very likely to make as many things worse as it makes better. The small refactoring has much more chance to have only or mainly positive effects. Sometimes one also has to take a step back and think about in what direction to go with an application. That can be a bit hard, indeed. Even in that case it is much better to do small steps in the right direction that one has envisioned rather than some bing bang rewrite.