4 ms·
My pet peeve with this, is that people write code that doesn’t reflect the problem. A messy problem should have a messy solution as that would reflect the probl
by he0001 4y ago
My pet peeve with this, is that people write code that doesn’t reflect the problem. A messy problem should have a messy solution as that would reflect the problem. As soon you start to write code that’s either for the sake of something else, clean code etc, you deviate from what you are trying to solve. That creates a solution which hard to follow, as the problem is abstract and others may be able to interpret that. But then if you look at some code that does something entirely different, due to language constructs, framework or some diligent programmer trying to write good looking code but has nothing to do with the problem. That creates cognitive load as you need to not just only understand and solve original problem and changes, you need to understand the actual code too.
- atoav 4y agoI once wrote an extremely general and elegant piece of code for an extremely messy problem (some obscure CSV from a source system I cannot influence with a ton of inconsistencies and mistakes that I have to straighten out automatically). I started out with straightforward and somewhat messy code, but after adjusting that 3 times, I ended up writing something that is more or less a toolset to deal with the problems that data had. The code of the tools is convoluted, but when I have to adjust some things every now and then I just use the tools I built anyways so who cares. Abstraction in programming should be seen like certain devices, helpers etc. someone would make use of in woodworking. Of course it costs you some time to built them, but it can make your life a lot easier, because ot makes results more consistent and testable.
- layer8 4y agoYes, I would formulate this as the distance between the mental model of the functionality being implemented and the structure of the code. The interesting question is how to design programming languages, libraries and tooling so that gap remains small.
- michaelwww 4y ago> A messy problem should have a messy solution as that would reflect the problem I've never heard this expressed before and it goes against my experience. My entire goal is to find a simple solution to a messy problem. I can think of a lot of simple solutions to messy problems. If programming required me to come up with messy solutions to messy problems I wouldn't want to do it. Most programmers like that "a-ha" moment of a discovering a simple and elegant solution to a messy problem.
- Aperocky 4y agoExactly, solution to a messy problem is 3 simple solutions working together, not one messy solution.
- michaelwww 4y agoI'm a bit old so when I was growing up in the 60's a cartoonist named Rube Goldberg made his living by amusing people with overly-complicated solutions to simple problems. I don't hear him mentioned anymore so I'll mention him now https://en.wikipedia.org/wiki/Rube_Goldberg_machine https://en.wikipedia.org/wiki/Rube_Goldberg_machine
- speed_spread 4y agoI've been thinking about a Ruby variant that would be called Rube.
- kaba0 4y agoThat is not always possible - sometimes the problem domain is simply complex enough and we should accept that. Fighting essential complexity is stupid.
- bmitc 4y agoI think you maybe over interpreted what they said, at least compared to how I interpreted or think about these things. Highly optimized or robust code or code with a lot of edge cases is "messy" in the sense that there's a lot of details separate from the high-level concept that get mixed in and can't always be modularized or abstracted away or made simple. That's fine though if pieces of code like that are localized to the complex problem they solve. Simple is a relative concept that can change substantially. Simple code closer to hardware is messier that simple code at a higher level. I once interacted with a developer that optimized everything. Looking at the code, it was impossible to know what actually needed to be optimized because everything was optimized or had the appearance of so.
- kaba0 4y agoI would probably put it like a messy problem can’t have a too elegant solution, in that essential complexity can’t be reduced. If your problem domain have edge cases everywhere you might be able to put an elegant abstraction over the common case, but the edge cases will have to be dealt in an inelegant way.