News for hackers. Stuff that matters.
Re:Write code that is easy to delete, not easy to extend (2016) by taeric on Wednesday November 04, 2020 @12:30PM (#24991104)
I feel this is somewhat muddled in push. I agree with all of the items, but I don't agree with how folks often pursue it.

My specific concern is where it pushes that a big ball of mud is easy to write, but hard to maintain. I agree, but oddly, a ball of mud is also somewhat easier to delete. Such that, it is best to grow your code from that core and only grow to reusable parts if needed.

I encountered this at work recently. I fully agree that reusable and "single responsibility" is nice. However, to extract out 5 lines of code such that we now have 3 new classes and possibly a new dependency seems the opposite of the spirit here. If we ever got where that logic isn't needed, as is, you delete 5 lines of code. In the "abstracted out" world, you have to delete several classes, making sure nobody else had taken a dependency on it.

I get that counting by lines of code is not the best metric, but it is an easy one. And, in general good faith code, the lower that metric, the better. It is less to read. Less things connected together to reason about. And, less stuff that you could delete in the future if able.

Re:Write code that is easy to delete, not easy to extend (2016) by aszen on Wednesday November 04, 2020 @01:03PM (#24991400)
The problem with removing ball of mud code is that you don't know much of that mud is entangled with useful code. I do think oop design patterns bring a lot of indirection sometimes but atleast we can use small well thought out functions instead of connecting all things inside one giant one
Re:Write code that is easy to delete, not easy to extend (2016) by taeric on Wednesday November 04, 2020 @02:01PM (#24991935)
That is true of all code you delete. It had some use, or it would never have been added in the first place.

I'm not arguing for the entire thing to be a ball of mud. Just pushing that there are trade-offs. And, in general, less code is better code. Even if it is a larger method.

Granted, I think a lot of this is in strawmen. Breaking 5 lines out of a 40 line method so that you can be better abstracted is usually fighting the wrong things. Breaking it out of a 500 line function is different.