In the real world of real people coding and not in click-bait land, people use clean code as a tool that's sometimes appropriate.
Goodbye, Clean Code (2020)
111–120 of 224 posts
Re: Goodbye, Clean Code (2020)
#112I used to be much more of a curmudgeon about wanting to clean up existing code on sight but a few bits of reality seeped in over time, such as: 0. Existing code is probably working fine, and making changes (for any reason) risks adding a bug. Worse, reviewing code with a bunch of reformatting is tedious and the reviewer may assume you’ve only done reformatting and not notice the accidentally-changed behavior either.…
I’ve worked at “blame game” companies before, if your name was on the commit it was your fault, all other process steps be damned.
So it reduced my inventive to change things unless actually required to ship a feature or fix.
Re: Goodbye, Clean Code (2020)
#113REEEEEEEEEEEEEEEEEEEEEEE!!!!!!!!
/s
Re: Goodbye, Clean Code (2020)
#114Using a different form of deduplicating would be the solution here. Just write a few functions that do the math and then call them, rather than create new abstractions that can later become monstrosities. I think they learned the wrong lesson here.
Just my two cents :)
Re: Goodbye, Clean Code (2020)
#115Sometimes duplicate code is simpler.
Re: Goodbye, Clean Code (2020)
#116"first you learn the value of abstraction, then you learn the cost of abstraction, then you're ready to engineer" - Kent Beck
Premature abstraction is the root of all evil.
It basically comes down to:
1. Write the code that makes the computer do what it needs to do to achieve a specific goal. No more and no less.
2. Refactor ("compress") the code by deriving re-used (implicit) structures and functions.
He puts a lot of emphasis on those steps being done in order and on deferring the second step
Note that this is from someone who writes games/engines/tooling so there is a large, real pressure to write simple and reasonably performant, optimizable code. He would also prefer that most of programming would be done in this way.
Re: Goodbye, Clean Code (2020)
#117I'm shocked that from all discussion nobody noted the root of all evil: "It was already late at night (I got carried away). I checked in my refactoring to master and went to bed, proud of how I untangled my colleague’s messy code." No PR, no code review, no CI. Just a cowboy pushing to the master..
And using clean code wrong. Clean code is not a panacea. If people use it as such and without the correct agile rites, they should do it at their own peril, but blaming it on clean code is at the very least naive (and somewhat dishonest)
Re: Goodbye, Clean Code (2020)
#118"Firstly, I didn’t talk to the person who wrote it. I rewrote the code and checked it in without their input. Even if it was an improvement (which I don’t believe anymore), this is a terrible way to go about it." While undeniably true, this feels completely orthogonal to the question of clean code. You could ruffle someone's feathers in the exact same way by taking code into the opposite direction. "Goodbye, Clean Co…
HN has a lot of people who seem to benefit from these types of “common sense” articles that bury the lede, judging by the fact they appear on the front page so frequently. (Putting common sense in scare quotes to acknowledge that this is new information to some, no matter how obvious to others)
Re: Goodbye, Clean Code (2020)
#119Earlier quoted context omitted.
Why one should ask to the original developer if the code can be modified? If I see a code I want to change, I do it. I don't ask for permission. And colleagues can do the same with code I wrote. We trust each other.
Years ago (2005?) I worked at a call center. Most agents were on one coast - data center was in another coast. Agents in our call center complained about speed. When they'd pull up an account, it was taking seconds... sometimes 15-20 seconds... to pull up the account. This was all a bespoke CRM system. I poked in the code (it was something I had access to) and noticed that ... the entirety of the whole screen was dup…
Re: Goodbye, Clean Code (2020)
#120Earlier quoted context omitted.
The thing I hate most is when some creates the "new way of doing things". Then fails to convert most of the existing code which is "doing things the old way" even when it's clear that it is the same thing.
The "new way of doing things" is risky and might not turn out so good after all. If you treat the new way as an experiment, and only gradually convert the rest of the code, you're in for a smoother ride.
It's totally fine to try out an experiment in a branch and deploy to QA but don't deploy it to prod until you're sure.