Comments by "Christian Baune" (@programaths) on "Software Engineering Is About Thinking, Not Typing | Prime Reacts" video.
-
To give a practical example, I did a project for advanced form validation with configuration provided by the user.
I need to have literal values, computed values, and fields at some point.
The whole implementation has no clue about the fields themselves or where the value comes from.
It just asks something else: what is the value of field X? What is the value linked to some variable Y ?
Later, another dev had to implement the same feature in another technology.
It was a copy-paste, and all he had to rewrite was the part answering the two questions above.
It was so unfathomable to him that he didn't even understand that it was all he needed to do.
It was so strong that I had to ask him to take control, do the copy-paste, and write a few lines of code with him...then it just worked.
The other nicety is that testing was much more straightforward. The core worked, so only the pluggable part had to be tested for his specific project, which was as easy as reading the code to confirm it did what it should.
And yes, it looks weird to have a class that required a FieldLocator and ValueLocator, but that made it easy to port.
It also makes the core more high-level and reusable. You don't have to read some documentation to have an outline of the algorithm; the class is so short you can read it at a glance.
It's the kind of code a junior would refactor to "reduce complexity" or "flatten the object graph." 😂
And I saw that at play. I wrote a set of decorator classes in one company to implement different concerns. There were like 5 types involved, and it looked like this: new A(new B(new C()))
I quit, and someone wrote that by merging the content of each class. The company asked me if I could give them a hand because it hadn't worked since the rewrite.
Yeah, that's why it was done the way it was done. To ease adding and removing features without confusing oneself passing a train of booleans to the method ^^
It is also much faster in a test; you can just initialize your service, omitting one decorator (the one making requests to a third party for legal reasons).
"It's over-engineered" or "It's written academically" is a cope for "Albeit it looks simple, I am uncomfortable with it, so I will rewrite everything, and it will be bristle."
1