Live data from Hacker News

It's OK if your code is just good enough

shiftmag.dev

51–60 of 149 posts

Re: It's OK if your code is just good enough

#51

Okay advice for day-to-day, but, horrible advice to take over the long term. Just Good Enough isn't going to improve your skill, it's going to keep you exactly where you are. Your code is a distillation of how well you understand the problem and how it's being solved. Confusion usually means either the requirements are not well-understood, you still have unknowns, or you simply don't understand the problem/solution w…

I think it is super hard to make world where only best developers are working.

You need huge numbers of average developers to keep running all the software there is.

Just like in army, average Joe can be a soldier because there will never be enough “best of the best” to have an army of only special forces.

Re: It's OK if your code is just good enough

#52

How good your code is depends entirely on context and priority. Context and priority should be defined for a project, not just left to the decision of each developer. I am building code for a startup right now. The context and priority is to "get the damn thing working". Thus code quality is largely irrelevant - this codebase is flat out garbage - it is full of commented out code, duplication, files that were obviate…

> This is exactly the right way to build this because none of those "terrible sins" matter when you have no customers and your only goal is to get something working as fast as possible and every second spent making things nice is a waste of time and money because if the business fails then every second spent making things nice was wasted. There's a lot of truth to this, but I would also like to see companies, and pos…

[deleted]

Re: It's OK if your code is just good enough

#53

In the vast majority of cases, writing good, maintainable code does not require more time. The real problem is that the majority of people working as software engineers barely know what they are doing, and use excuses like this because it makes some amount of sense to the incompetent managers in charge of them.

I think one of the exceptions is heavily optimized code, though the surrounding code can still be maintainable and clear, with the weird stuff to tickle the compiler or inline assembly being heavily commented.

Re: It's OK if your code is just good enough

#54

Somehow code quality has become a topic completely divorced from product quality. Your users don't care how clean your source code is, but they definitely care if it's slow and buggy.

> Your users don't care how clean your source code is They do care about bugs and new features though, and bad code quality will lead you to more bugs and slower shipping of features in the medium/long run. At least, that's how I define good code.

yeah, the number of times I've cleaned up some code because it was "just wrong" and as part of making sure it had test coverage for visible impact, identified a "oh, this has been flaky at a customer site for years, but noone had a good angle on it"...

That's also pretty much the only hope of getting product buy-in on this kind of thing, showing that "no really, there was this particular customer impact". Or "by doing this upgrade in a timely manner, we're not screwed by no longer being able to buy old hardware because new kernels/libraries support the modern replacements"...

Re: It's OK if your code is just good enough

#55
"Quality code", in my experience, often means "code that looks like how I would have done it". In other words, it's usually pointless nitpicking and you're better off not engaging in it. Of course, there's some convergence on this topic because certain programming influencers successfully pushed their opinions onto many people who choose not to have opinions of their own which is something that happens in every field because many people find actual independent thought hard or scary.

There are some things that genuinely matter such as minimizing repetition, using variable names that are clear/easily searchable with "find" (meaning without tons of false positives) and not writing undebuggable code if you can avoid it[0]. I also think performance matters even if it seems fast enough on your machine. In my view, you shouldn't use Integer instead of int in Java unless you absolutely have to because Integer wastes resources creating an object containing an int and dramatically increases cache misses[1]. But in general, it isn't worth worrying about unless you can actually come up with a coherent explanation of why your preferred way of writing code will make the software perform better or be easier to maintain. Of course, the only absolute rule in code is that there's always an exception to every rule.

[0]: I'm generally in the "C/C++ macros considered harmful" camp especially when they resemble functions and feel similarly about anything else that makes the code execution path less than straightforward to follow.

[1]: I have a strong suspicion that OOP itself is an anti-pattern and that the entire paradigm is a wrong turn that needs to be abandoned. It's weird because I had a favorable opinion of OOP before I learned what it is in college but it tripped my brain's BS alarm. But I've never worked in a large enterprise environment so I haven't actually seen it in practice enough to fairly evaluate it.

Re: It's OK if your code is just good enough

#56

How good your code is depends entirely on context and priority. Context and priority should be defined for a project, not just left to the decision of each developer. I am building code for a startup right now. The context and priority is to "get the damn thing working". Thus code quality is largely irrelevant - this codebase is flat out garbage - it is full of commented out code, duplication, files that were obviate…

> This is exactly the right way to build this because none of those "terrible sins" matter when you have no customers and your only goal is to get something working as fast as possible and every second spent making things nice is a waste of time and money because if the business fails then every second spent making things nice was wasted. There's a lot of truth to this, but I would also like to see companies, and pos…

>> when security breaches happen

Again, that must be defined as context and priority.

Priorities:

* deliver as fast as possible

* security matters

These two priorities are somewhat in conflict but it's still important to state them, then developers know where to focus.

Re: It's OK if your code is just good enough

#57

In the vast majority of cases, writing good, maintainable code does not require more time. The real problem is that the majority of people working as software engineers barely know what they are doing, and use excuses like this because it makes some amount of sense to the incompetent managers in charge of them.

[deleted]

Re: It's OK if your code is just good enough

#58
post #29

My formatted-by-productivity-standards brain agrees, my heart disagrees. I enjoy the art of programming. I love to think that, for certain types of projects, I am allowed to aim for and reach perfection. My vision of perfection is not yours, so what. If your "good enough" is actually your perfection because of business impact, user happiness or optimal time management, good for you. Just don't tell me that my perfect…

The funny thing with this is, that often times someone’s perfect is someone else’s future headache.

It's more subtle that that. There is a great saying "Always code as if the person who ends up maintaining your code will be a violent psychopath who knows where you live".

I've seen countless bright minds wonder in the pursuit of instant pleasure by adding unnecessary complexity. I have seen others outright sacrificing projects that support people's life to achieve an instant goal of learning a particular library or acquire a useful skill or worse make a point against an imaginary adversary.

Due to the incompetent management, these suckers are never punished. They usually jump board and venture into greener pastures before their playgrounds turns into bloody combat fields where much less sophisticated but more honest former colleagues die or deliver.

Re: It's OK if your code is just good enough

#59
I once saw a 5000 line file of shit-tier code making a business something like a million bucks cash per day.

It was a single huge function, called from cron every 5 minutes. No locking to prevent concurrent runs if it took longer than five minutes to execute. No exception handling. One giant nearly incomprehensible everything-function. Global variables. Bugs everywhere.

Easily hundreds of thousands of dollars of net profit per hour (some hours).

Since then I never worry much about code quality in my prototypes. Build one to throw away.

Re: It's OK if your code is just good enough

#60

In the vast majority of cases, writing good, maintainable code does not require more time. The real problem is that the majority of people working as software engineers barely know what they are doing, and use excuses like this because it makes some amount of sense to the incompetent managers in charge of them.

> In the vast majority of cases, writing good, maintainable code does not require more time Yep. Especially with practice. You can pretty much get to a point where you build things reasonably well by default without even thinking too hard about it. You have to want to attain it, and be willing to ruthlessly evaluate and file down your design repeatedly. I believe there's a compounding effect at play here, which accou…

> You can pretty much get to a point where you build things reasonably well by default without even thinking too hard about it.

That's mastery. There are probably about as many master programmers as there were master... let's say blacksmiths. The problem is there are 10, 20, maybe 50 times as many programmers as we ever had journeymen blacksmiths. And they all seem to think that tenure equals mastery. If we had 10, 20, 50 times as many masters, we'd have enough people to keep an eye on things. But we don't.

Post reply on HN