r/programming • u/nazavo • Jul 14 '22
Principles of software engineering for the grugbrained
https://grugbrain.dev/15
u/renatoathaydes Jul 14 '22
This is very funny, but very long also... I wonder if the author actually speaks like that now after writing so much in "grugbrained" style :D
11
4
8
Jul 14 '22
Wanted to like this. Complexity is bad. However, trying to read that broke my brain. Also, it left the rails at abstractions and unit tests, which are key ways of avoiding complexity.
Abstractions let you not have to change the whole code base when refactoring, fixing, or enhancing. Grug’s correct that they shouldn’t be over designed with unneeded bells and whistles.
Turns out, if you have avoided complexity and used abstractions, unit tests aren’t hard, and don’t break when refactoring (unless they should).
-3
u/JayTh3King Jul 14 '22
You want your unit tests to break when refactoring. Show they are working, then fix your code to pass the tests or your tests again.
6
u/Vidyogamasta Jul 15 '22
You don't want unit tests to break when refactoring, because refactoring implies unchanged behavior. You want the same end result, and unit tests help verify that. It's imperfect because changing up dependencies tends to make tests break one way or another, but if you're just shuffling a few call orders around or changing the grouping of logic to be more flexible, a unit test shouldn't break.
However, a unit test SHOULD break if behavior changes, intentionally or otherwise. If you change behavior and a unit test didn't break, you probably need a test specifying the behavior you changed.
3
2
1
45
Jul 14 '22
[removed] — view removed comment
26
u/dry-mouse-69 Jul 14 '22
Manager : Is it working? Let me announce it to the client.
And with that the client will congratulate him and say they wish to not spend one more dollar on this
3
4
u/WangoDjagner Jul 14 '22
My company keeps telling me to copy paste functions instead of using proper oop and just get things running asap. 'we will refactor it later once we do a version 2 of this' yeah right...
1
4
u/BigManWalter Jul 14 '22
I love it, but not sure I agree on his unit testing take; I find them incredibly useful, and the more, the better!