News for hackers. Stuff that matters.
Re:Write code that is easy to delete, not easy to extend (2016) by rerx on Wednesday July 22, 2020 @05:24AM (#23915303)
> Very clean. Also, changing the slightest things required to go through 5-6 files.

Martin Fowler's "Refactoring" is a great book (I only know the 2nd edition from 2019). From a naive understanding of the "clean code" school of thought one might assume that splitting up everything into small functions, classes, modules is always the way to go. But Fowler's advice is much more nuanced than that. His list of bad code smells includes the aptly named "Shotgun Surgery", which describes just your quoted situation. The suggested way to go is then to first inline all the scattered stuff, next to extract parts such that the logic is more contained.

Your rewrite sounds very similar. And of course you are right: School and books probably don't do a good job of transferring this knowledge. That "Shotgun Surgery" paragraph is easy to discard by a reader who hasn't experienced the pain themselves.

Re:Write code that is easy to delete, not easy to extend (2016) by dionian on Wednesday July 22, 2020 @10:05AM (#23917110)
I remember coming across Refactoring after having already adopted it for some years. I wish I had come across it sooner. But with my initial experience under my belt I was able to realize what a gold mine it is. Anyone working in a higher level OOP language especially should give it a read