Live data from Hacker News

Nobody cares about your clean code

felipecsl.com

81–90 of 177 posts

Re: Nobody cares about your clean code

#81

Earlier quoted context omitted.

It’s because it makes no effort to prevent people doing insanely insecure things. Rails has a lot of safeguards for insecure things like using user input to update a record. PHP won’t even fix bugs due to backwards compatibility. They worked out their sql string escape function didn’t escape properly but instead of fixing it and telling everyone to check their code, they duplicated the function and prefixed the name…

Rails is not a language. PHP maintainers do fix bugs. I don't use PHP right now, it's not my favorite language, but I hate when people are trying to excuse their own laziness and incompetence by saying “it’s all because of tool X”.

Rails and ActiveSupport are a huge extension to Ruby and are bigger than the non Rails Ruby usage. If you read the average PHP tutorial, it starts you out connecting to a db, running raw sql and rendering templates in the same file. An absolutely horrible idea. If you start on the default rails tutorial, you gets set up with a decently safe configuration.

Re: Nobody cares about your clean code

#82

"throw the first one away" When I'm prototyping or hacking something together, I don't write tests, I don't comment/document much, I use lots of shitty variable/type names, lots of commented out code, debugging printfs, not much organization of files (often one large file). The prototype software is write-once, read-maybe. Maybe I'll want to see what I did down the road, but more likely I'll be shortly rewriting what…

When I'm prototyping or hacking something together, it eventually becomes production. I cannot relate to people who make prototypes to throw away, I've never done it, and I don't know why I'd do it. Due to that, I write my first line of code as if it's going to be on production forever, because it will.

> I cannot relate to people who make prototypes to throw away, I've never done it

Have you ever had that moment when you say: "Oh damn, now I got it! I should do it entirely differently!" — and then you code up a different approach, the approach that works well enough.

If you had this moment, it was the moment of throwing away the prototype.

Re: Nobody cares about your clean code

#83

This is very true. END USERS in particular do not give a rats about clean code or the number of code reviews that have been done. They only care that it works. Technical debt, refactoring, reuse? Nobody cares except developers. The paying customer is all that matters.

The paying customer cares when your tech debt becomes so burdensome that you can no longer deliver features (or fix bugs) on the timeline they want.

Re: Nobody cares about your clean code

#84
post #28

Earlier quoted context omitted.

> I cannot relate to people who make prototypes to throw away, I've never done it, and I don't know why I'd do it. When I'm at the prototyping stage, I don't yet know how to solve the problem. That means I need to iterate quickly, which affects my choice of language (Python) and the amount of time I'm willing to spend keeping code clean (very little, because I could hit a dead-end at any point). But once I have a wor…

Is this stealth promotion for Go?

Go does not have a REPL with interactive introspection and fiddling capabilities. Such a thing is key for prototyping.

Re: Nobody cares about your clean code

#86
post #74
post #69

If you don't care about clean code, you don't care about collaboration. Projects that don't care about collaboration don't scale.

Projects (and companies) that never ship or ship too late also don't scale. In my experience, it's much easier to overbuild than it is to underbuild. I definitely agree that collaboration is essential though!

What really matters is having somebody to blame when the project fails!

Re: Nobody cares about your clean code

#87

"throw the first one away" When I'm prototyping or hacking something together, I don't write tests, I don't comment/document much, I use lots of shitty variable/type names, lots of commented out code, debugging printfs, not much organization of files (often one large file). The prototype software is write-once, read-maybe. Maybe I'll want to see what I did down the road, but more likely I'll be shortly rewriting what…

When I'm prototyping or hacking something together, it eventually becomes production. I cannot relate to people who make prototypes to throw away, I've never done it, and I don't know why I'd do it. Due to that, I write my first line of code as if it's going to be on production forever, because it will.

So I just hacked together an animated LED strip lamp on an Arduino. I didn't write any tests or setup production. What would you have done?

To me, "I write my first line of code as if it's going to be on production forever" means setting up a testing infrastructure, a reproducible build that can be automated, a CI that runs my tests. An auto-commit system where I can create a PR and submit it to the CI and if it passes it will automatically get merged to main, etc...

Instead of my lamp project taking 1-3 hrs it would have been a week of setting all this up before I was ready to write my first line of actual code.

Are you saying you'd actually take that week? Would you therefore never write something on shadertoy because it's missing all that infrastructure and you can't write code as if it's going to be in production forever?

Re: Nobody cares about your clean code

#89
post #43

John F. Woods (who I actually knew IRL briefly - nicer guy than his online reputation suggests) said it best. "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." I'll just add that the psychopath in question might be your own future self.

Oh boy... I believe I'm this kind of psycho, when I see my name in a git blame after tracing a bug that I didn't foresee... I feel awful, disgusted, then I fix it and think "You sure are dumbass, now try to be a lesser one".

And the relief when you see your name is nowhere near the defect.

Re: Nobody cares about your clean code

#90
post #12

I think it's ironic that the author claims that clean code is....... Package your code down into small, atomic and reusable units Follow the single responsibility principle Use frameworks and libraries to avoid reinventing the wheel Whatever language you pick, don’t pick PHP These are best practices. It is possible to follow every one of those rules and still have a pile of broken, insecure, garbage code. Likewise yo…

That's partly the reason why the term "best practice" has become a bit controversial in some communities --- it's seen as mindless dogmatic cargo-culting. I've heard the saying "best practices are best not practiced" from the opposition. There is nothing more frustrating than working on a codebase that puts 12 lines of code in each file and then spreads that code into 1,000 files. In other words, "Enterprise" code, w…

If you are having difficulty navigating a project because it has many modules, I really don't think that is an argument for disavowing whatever best practices. Rather, it is more of an argument against whomever organized the code base in a way that they like and you don't.
Post reply on HN