Hacker News new | ask | show | jobs
by bhuber 1606 days ago
I'm not sure I agree with the premise. Most of the time I see someone not following best practices it's because they're unaware of them and just do the simple/most obvious thing, which just so happens to be bad for not-so-obvious reasons. Or they are aware of the best practice, but decide not to follow it because of reasons x, y, and z. It's very rare, however, that I see someone do the wrong thing because someone told them it was the right thing (at least in the programming field).

Perhaps this is just an artifact of my own personal experience though, all my professional experience has been at dedicated software shops with highly competent engineering teams. I realize that's not the case everywhere.

Does anyone have any specific examples of worst practices explicitly being disseminated under the guise of best practices? Is this something that you tend to see happen only within organizations, or across the internet as a whole?

3 comments

Best Practices

The requirement was to ingest a CSV, transform it, and put it in a database somewhere. The solution was three microservices.

The first read the data piece by piece (unit of work) and passed it to the second via HTTP. This was slow so it was threaded.

The second provided an abstract class which was extended to facilitate string transformations. Each was accompanied by a unit test. Similarly, the result was passed along to the third service via HTTP. This was also threaded.

The third put the data into a third-party queue which wrote into a database.

It took nearly a half of a day for the process to complete. I rewrote it as an SQL script which read the CSV into the database directly, used SQL functions for the transformations and then stored its result. It took a few minutes to complete. But, this wasn't a best practice or popular, and what would the team work on?

That sounds like a nightmare, but I would not consider micro-services to be "best practice". It's a design decision.
Step 2: there are no "best practices" at all. These are just design decisions made by other people for their own reasons.
> It's very rare, however, that I see someone do the wrong thing because someone told them it was the right thing (at least in the programming field).

> any specific examples of worst practices explicitly being disseminated under the guise of best practices?

OOP.

The actor model envisioned by Alan Kay was promising, but the brand we saw in Java and C++ in the late 90's and early naughties was pretty bad. There's a reason we moved away from inheritance in favour of composition, a reason why OOP languages took a clue from statically typed FP languages and grew generics 20 years later than them, a reason why they eventually grew first class functions… and don't get me started on performance sensitive software which could have benefited from a bit of data orientation.

Don't get me wrong, classes have their uses. Grouping related data together is very handy, as well as the namespacing. And sometimes, even inheritance has its uses. But as a whole it's just the wrong way to look at things. A program's job is to move & transform data, and instead of focusing on that data OOP encourages you to think of an inevitably contrived model of the world.

The Right Thing

I've heard people say, "React is fast. It has an intermediate layer to optimize changes to the HTML. You get much better performance with it." Of course, we know that effectively manipulating the DOM via plain JavaScript is the best you'll get. (And you can achieve great performance with well written jQuery too.)

Agree. I did a web application where all views were defined in the HTML file, all disabled except for the current view. The app would then switch views by simply enabling/disabling views as needed. It was super fast. And keeping the views up-to-date was easy. The app simply updated all views when the data changed => the visible view and all non-visible views would always be up-to-date without needing any special handling or virtual DOMs. Super simple. Super fast.
> Of course, we know that effectively manipulating the DOM via plain JavaScript is the best you'll get.

With an infinite amount of hand-tuning by experts, yes. In practice to know what parts of the DOM to update based on what changes and maintain that mapping correctly as your system evolves, you have to either use React or use/build something equivalent to it.