Live data from Hacker News

Goodbye, Clean Code

overreacted.io

521–530 of 599 posts

Re: Goodbye, Clean Code

#521

Earlier quoted context omitted.

I need to disagree with you, I've been in a few positions where one engineer suddenly decided to rewrite parts of the code base without any input from other engineers. It's a huge blow to team morale, and it gave me a fear of writing code in this team. Every time I wrote a piece of code, I wondered how long it would be there for, I understand that code evolves, but seeing your code being rewritten after a week is no…

I know that programmers are humans but I think paying too much attention to people's feeling is what is dragging the IT industry down, if you have self esteem issues go see a shrink

It’s not about personal feelings or self esteem, it’s about trust within the team, and confidence that when you do something the team sticks to it. When a rewrite is required, the team talks about it and then acts.

Re: Goodbye, Clean Code

#522

Earlier quoted context omitted.

> make it “generic enough to handle future use cases”. The answer to this is usually YAGNI. That is, don’t plan for a future you might never have. Code in a way that won’t back you into a corner, but you don’t know what the future’s cases might be (or if there even will be any) so you can’t possibly design in a generic way to handle them. Often you just end up with over-engineered generec-ness that doesn’t actually h…

The repetition is what is YAGNI! Repeating code 7 times in preparation for separate evolution of those 7 cases is YAGNI, unless the requirements are on the table now. Merging repeated code into one is something that is demonstrably needed now, not later.

Yes, I agree. That’s not what I was replying to, though. I noted in another comment that I consider merging worthwhile even in the absence of three use cases, certainly if what you have now is very similar.

Re: Goodbye, Clean Code

#523

Earlier quoted context omitted.

> What fraction of us can claim they have, really? I think it's larger than you imagine. Just look at the code of GitHub, BitBucket, Sourceforge etc. Not to mention self-hosted commercially-developed FOSS. > Most developers work at the application layer, the last one. Well, that doesn't mean they have to work _only_ on that. Each developer uses a bunch of libraries, utilities and frameworks which are either FOSS or c…

> Just look at the code of GitHub, BitBucket, Sourceforge etc I think those are misleading on two accounts: first, it's the tip of the iceberg. Most co-workers I've spoken to don't contribute to any such open source projects. They tend to have other priorities, starting with the proprietary or custom software they are paid to write. Yes, there are many programmers writing open source code out there. I'm willing to gu…

> Most co-workers I've spoken to don't contribute to any such open source projects.

You asked "what fraction can claim they have"; and you're saying "most" of your co-workers haven't. Fair enough, it's the same for me actually. But "Most" is just over 50%. A sizable fraction have.

> Second, there's a lot of unused garbage out there.

Yes, that's true (and also a lot of unused gems). But even if we only take code that's seen use by others, my previous argument stands. Of course, "used" can mean 10 people or a Million people.

> Take me... GitHub raking... I'm in the top percentile

Wow, I didn't even know about these rankings! Thanks!

Anyway, I looked at my rankings, but more than that - I looked at the overall number of contributors. There are supposedly [1] about 24 Million software developers in the world today. Now, There are 300K C++, 300K C, 760K Java, 600K Python and 1M Javascript contributors on GitHub, Then it's pretty safe to assume that between 5% and 10% of developers contribute merely on GitHub. Actually, yeah, over 2 M active users in 2017 [2]. And again, there are other venues for FOSS contribution, like I mentioned. So dropping the unused stuff, we're still close to 10% of developers.

> I quickly concluded that universal free software is mostly incompatible with capitalism.

If you put it that way, I agree that that's the case. But - I didn't mean to say programmers should be inspired just by the fact that software can be free; I also mean that they should strive to write their software as though it were about to be released as FOSS.

[1] - https://www.daxx.com/blog/development-trends/number-software...

[2] - https://www.infoworld.com/article/3253948/who-really-contrib...

Re: Goodbye, Clean Code

#524
post #504

Earlier quoted context omitted.

Do you have specific experience that suggests that hyper-generalizing code before you even know about multiple use cases is beneficial over carefully extracting shared logic only when needed? If I to pick one single practice junior engineers employ that ultimately bites everyone in the ass, it's a blind adherence to generic code and DRY at all costs.

> Do you have specific experience that suggests that hyper-generalizing code before you even know about multiple use cases is beneficial over carefully extracting shared logic only when needed? I've gone over my comment three times now and I'm yet to see where I even implied something like this. Could you tell me how you got this from my comment? I do want to see how I could send the wrong message so I can word mysel…

The article was literally about that, and your first line says "nah I'm good."

Re: Goodbye, Clean Code

#525

Earlier quoted context omitted.

Every single rule or advice in programming is good until it isn't. OOP is good until it isn't, function programming is good until it isn't, premature optimization is the root of all evil until it is the root of all good. For some reasons humans have this deep need to try and boil things down to bulleted lists which in the domain of programming are just incredibly not useful.

well said. for a while I started treating everything as a soft rule, more like guideline. it gets easier then :)

Consider them to be heuristics, not rules.

Re: Goodbye, Clean Code

#526

Earlier quoted context omitted.

I need to disagree with you, I've been in a few positions where one engineer suddenly decided to rewrite parts of the code base without any input from other engineers. It's a huge blow to team morale, and it gave me a fear of writing code in this team. Every time I wrote a piece of code, I wondered how long it would be there for, I understand that code evolves, but seeing your code being rewritten after a week is no…

> Every time I wrote a piece of code, I wondered how long it would be there for. The fix for that sort of thing is to have a satisfying, enduring side project where you're the boss: nothing is upstreamed that you don't like. Then you can stop caring if your code at work gets replaced, and how fast.

I care more about the way it gets replaced. I constantly learn from my code being replaced, and replacing code myself. However I doubt anyone liking code being pushed onto them. That’s how I feel when someone decides to rewrite code without anyone’s knowledge. They already did the work, so they’re expecting it to be merged in.

Re: Goodbye, Clean Code

#527
post #453

Earlier quoted context omitted.

I need to disagree with you, I've been in a few positions where one engineer suddenly decided to rewrite parts of the code base without any input from other engineers. It's a huge blow to team morale, and it gave me a fear of writing code in this team. Every time I wrote a piece of code, I wondered how long it would be there for, I understand that code evolves, but seeing your code being rewritten after a week is no…

> seeing your code being rewritten after a week is no fun, and it's a huge blow to your confidence as well. The people doing the rewrite benefit from your work though. They might would have done the initial writing "worse" than you did. It is good to have fresh views. I agree it is good to communicate, too.

The main thing is indeed the communication, it would solve most issues.

Re: Goodbye, Clean Code

#528

Earlier quoted context omitted.

That can be boiled down to the “Rule of 3”. My CTO often asks me to implement a feature to do X and make it “generic enough to handle future use cases”. My answer is always the same - either give me at least three use cases now or I am going to make it work with this one use case. If we have another client that needs the feature in the future then we will revisit it. Of course, there are some features that we know in…

The Rule of 3 is a great rule, except when it isn't. I had a colleague some time ago who wrote a couple of data importers for FAA airspace boundaries. There were two data feeds we cared about, "class airspace" and "special use airspace". These airspace feeds have nearly identical formats, with altitudes, detailed boundary definitions, and such. There are a few minor differences between the two, for example different…

> The Rule of 3 is a great rule, except when it isn't.

"Rules are for the guidance of wise men and the obedience of fools."

It's unfortunate that you had to deal with a fool, but that's not a indictment of the particular rule that they picked to follow off a proverbial cliff.

Edit: fixed ambiguous quote formatting.

Re: Goodbye, Clean Code

#529
post #102

Sorry for the off topic grammar question, but am I the only one who finds it confusing how people have started to use plural pronouns to refer to individual people?

I'm a native English speaker and found absolutely nothing unusual about the grammar in the article. Do you have any specific examples?

One example:

> My boss invited me for a one-on-one chat where they politely asked me to revert my change. I was aghast. The old code was a mess, and mine was clean! I begrudginly complied, but it took me years to see they were right.

The first they sounds like the boss and the colleague were in the same room, but it can't because he says one-on-one. Still, presumably both the boss and the colleague wanted the revert. But the second they is really ambiguous. Was the boss right or the colleague?

Re: Goodbye, Clean Code

#530
post #57

Sorry for the off topic grammar question, but am I the only one who finds it confusing how people have started to use plural pronouns to refer to individual people?

It started in the 14th century. Wikipedia has a good article on it: https://en.m.wikipedia.org/wiki/Singular_they

Fair enough, but at least they had plural you back then: thou.
Post reply on HN