News for hackers. Stuff that matters.
Re:Repeating Yourself Thrice Doesn’t Turn You into a 3x Deve... by echelon on Sunday July 30, 2023 @01:34PM (#36933721)
You're talking about two entirely different things.

OP is saying don't write a "magic thingcombobulator factory" that "simplifies X endpoints with Y and Z similar behavior". This might be an earnest attempt to try to speed development, but it all collapses under its own weight at scale. The maintainers after you will be left holding the bag and have immense difficulty refactoring or migrating to a new set of requirements, a new data model, or an entirely new service.

Clever abstraction kills.

I've dealt with undoing insane magicality by crazy lazy devs, mostly in magic method dispatch / monkey patch Ruby land.

One person once exposed the entire database as a "safe" SQL-like query parameter DSL. No more endpoints to write - just use the thing.

There are so many problems with this. For example, when millions of transactions per day on mobile clients or via third party integrators bake these assumptions in, you can't easily migrate them away. You have to keep serving the same data assumptions, even while you're gutting and changing everything under the hood.

Simple endpoint logic is best. Your data model should be well thought out, and the CRUD code is a well-defined, super maintainable means to manipulate it.

Re:Repeating Yourself Thrice Doesn’t Turn You into a 3x Deve... by klodolph on Sunday July 30, 2023 @01:59PM (#36934051)
Agreed. I’ve also gone into a codebase and seen the most boring code ever. It looked like examples from an intro to web programming class. The backend did simple parameteried SQL queries. It was a pleasure to work with.

My conclusion is that the real “star” developers will, most of the time, write code that’s so simple, it looks like anyone could have written it. They ship a project on time, with good performance and availability, and then they move on. Anyone can come in and maintain it because the code is so obvious.

Re:Repeating Yourself Thrice Doesn’t Turn You into a 3x Deve... by rightbyte on Sunday July 30, 2023 @07:11PM (#36936980)
So much this. I feel that many developers have some fear of writing simple code. Probably because that is the way newbies do it, i.e. straight forward big functions that do stuff.

Reading function pointer dispatch code, disguised as whatever it is called when not C, can be hopeless.

Re:Repeating Yourself Thrice Doesn’t Turn You into a 3x Deve... by lovasoa on Sunday July 30, 2023 @02:01PM (#36934070)
I think your parent comment was making a good point. The "just write the code" and "don't try to be smart" mentality is good only up to a certain point.

Too much "just write the code" ends up creating huge unmaintainable monstrosities.

When you have a lot of time in front of you and a large team, it's okay to just put two junior developers at work for two weeks, and get a big CRUD REST api in the end.

But when you are trying to iterate quickly with a small team, exposing your database is not as stupid an idea as it sounds. And that's why things like Firebase, Hasura, Apollo, Postgraphile, etc. are so popular.

The post is not trying to convince people to build custom DSLs just for querying their database (sorry you had to work with that). It is saying that there are things that exist today, that dramatically reduce the complexity of full stack applications. And that whether or not we like it, this is probably the direction the industry is taking.

Re:Repeating Yourself Thrice Doesn’t Turn You into a 3x Deve... by CuriouslyC on Sunday July 30, 2023 @03:59PM (#36935299)
The end goal is to minimize software TCO. In addition to being semantically less clear, repeated plumbing code tends to diverge over time, which makes it difficult to refactor and more bug prone if people assume behavior is homogenous.

The best way to handle cases that will be almost the same but may diverge over time is to create a functional mini DSL that describes the domain behavior, and create a template implementation that can be used if desired. Then everything is using a common language, and a non-template implementation indicates the presence of non-standard logic.

Re:Repeating Yourself Thrice Doesn’t Turn You into a 3x Deve... by disgruntledphd2 on Monday July 31, 2023 @05:46AM (#36940436)
> The best way to handle cases that will be almost the same but may diverge over time is to create a functional mini DSL that describes the domain behavior, and create a template implementation that can be used if desired. Then everything is using a common language, and a non-template implementation indicates the presence of non-standard logic.

I mean yeah, I'm a big fan of DSLs. The problem occurs when someone writes the DSL, doesn't document it and leaves. Then it becomes super, super painful to maintain and extend.

Basically I'm coming round to the conclusion that (assuming reasonably competent colleagues), the least experienced person should be able to maintain and extend the code if it's to have any hope of remaining useful over time.

And good tests, for gods sake test the crap out of anything complicated with well-chosen names so that people can read the tests and understand how the code should be used.

Re:Repeating Yourself Thrice Doesn’t Turn You into a 3x Deve... by CuriouslyC on Monday July 31, 2023 @08:14AM (#36941464)
If the functions are all clearly named and reasonably small-ish DSLs can be mostly self-documenting. Plus you can always ctrl click in your IDE of choice to view function source. I'm talking something like this:

f(base data) .validate() .domainAction1() .domainAction2() .log() .describe() .sendHtmlResponse()