top | item 41565999

(no title)

Crazyontap | 1 year ago

I've often thought that simpler technology tends to be more robust because it has fewer moving parts.

This might be an apples-to-oranges comparison, but I've noticed that writing vanilla PHP or JavaScript code, while harder at first, results in more robust and easier-to-debug applications. On the other hand, using frameworks, ORMs, and other abstractions can make the codebase feel brittle and harder to maintain.

discuss

order

ajuc|1 year ago

This is mostly because when you write from scratch you have to understand the whole control flow.

Frameworks encourage learning stuff on "as-needed" basis, and you often don't know what you should know. So you do stuff on layer 3 because you can (and you already worked nearby), when it's already handled by layer 1 and reprocessed in layer 5. So you debug to see why you can't see changes and "fix" it on layer 7. And it seems to work.

Repeat this over 100 changes and you create crazy mess.

I've seen code that gets a list from the framework (already can't be null), checks if it's null, checks if it's empty. Makes it null if it's empty, then passes it through several more layers with null and emptiness checks on some of them, and then fails with NPE because there was no null check at n-th layer :)

The person writting this code was in the proccess of adding another null check at the NPE line to "fix the problem" :) The solution was to remove all the custom code except for the final destination of that list :)

I've written similarly bad code in some more complicated scenarios without realizing.

rbanffy|1 year ago

Simplicity at one layer might mean more complexity on others - I prefer vanilla JS when possible (and modern browsers are quite good at that), but the conceptual simplicity of PHP pushes some complexity into the template rendering, and using database APIs directly do couple you to a certain way of storing data.

lores|1 year ago

Agreed, but I think there's something to be said for allowing light coupling sometimes. Anathema to "proper" design, but not uncommonly the overall complexity of a proper design makes maintenance harder, not less. I'd rather change a hardcoded SQL query than three layers of abstraction, myself; centralisation beats having to follow a trail of classes, and you always need a good test suite anyway.