4 ms·
I’m allergic to debt. Financial, code, whatever. I’m big on “If I do it right the first time, I don’t need to do it over.” It’s worked so far, but I don’t hav
by ChrisMarshallNY 4y ago
I’m allergic to debt. Financial, code, whatever.
I’m big on “If I do it right the first time, I don’t need to do it over.”
It’s worked so far, but I don’t have any raging success stories, so I guess the “Cram a lash-up out as fast as possible” crowd can sneer at me.
I’m still gonna write code, the way I do, though.
- iveqy 4y agoThe trouble is that requirements change. So you write it "the right way", then you get a minor requirement change that forces you to slightly bend the rules, which is okay. 100 requirement changes later your code is a real mess.
- PainfullyNormal 4y agoPart of writing it "the right way" is to make it easy to change. This is why I've come to dislike OOP. The rules are too rigid and result in exactly what you describe.
- xbfjvusb6 4y agoI find OOP fine but it's not something you can just let rot. You need to be ok with redefining classes and refactoring things around the new boundary lines regularly as requirements change. This requires a testing suite that gives you confidence to make these sweeping changes quickly. Without it, it's not a fun way to work. Also, you don't have to go all in on oop. I like to use procedural most of the time only defing objects for things I find more easy to reason about as objects. For example, I'll write the command line interface in procedural that looks a lot like a complicated bash script and then define objects that do the work. This often results in objects not really changing much because they're not defined until later in development when their needs are well known. The place that changes is usually feature switches, command toggles, output formats, and the like. All that can be objects if you want but for the most part a function or two goes a long way and results in easier to change code.
- PainfullyNormal 4y agoYour post reminds me of this scene from Indiana Jones and the Last Crusade: https://www.youtube.com/watch?v=nGTEXqudVJM https://www.youtube.com/watch?v=nGTEXqudVJM
- int0x2e 4y agoI often feel the same way. I've seen cases where trying to add functionality to an existing but "very clean and correct" codebase ended up being extremely difficult and the result felt far too complex in my mind. I've come to think the real sin is coupling. If you try to keep your codebase clean at all times but don't refractor often enough, you end up with coupling where it shouldn't be, which can sometimes be a lot worse than some of the so called "deadly sins" such as code duplication.
- ChrisMarshallNY 4y agoOOP, when done badly, is an eight-gauge footgun. I should know, I've blown off most of my toes. But, you know what they say: "Good judgment comes from experience. Experience comes from bad judgment." I have pretty good judgment, these days (see "toes," above). Well-written OOP, on the other hand, is a marvel of Quality, simplicity, maintainability, performance, and refactorability. We often like to blame a tool, when it's really PEBCAK. It's like we go to a bar, one night, and there's this old blues guy, alone, with a beat-up Telly and an old Peavey amp, making music that sounds like it came straight from God's House Band. It looks effortless. So we rush home, buy a PRS guitar, and a Mesa Boogie amp, strike a pose, and hit the strings. The cat grabs his favorite dead rat, and heads for the hills, never to be seen again. The kids delete their TikToks. The wife calls a lawyer. Maybe there's something to be said for learning mastery of a tool, before disparaging it.
- PainfullyNormal 4y agoThere is such a thing as a bad tool. In most industries, they simply refuse to use the tool anymore. Not so much in software development, for some reason.
- yakshaving_jgt 4y agoA good tool drives the wielder towards success. Given how frequently I hear something along the lines of "OOP is great; you're just doing it wrong!", I'm inclined to believe it actually isn't so great.
- ChrisMarshallNY 4y agoDefine "good." I hear functional programming is great. Not so sure I'd write a driver with it, though. Everyone loves to rain hate on C++. I ran a C++ shop for 25 years, and have heard it all. Listen. It's current fashion to hate OOP, and I'll never convince anyone otherwise, so I'll just back off, and let y'all think what you will. For me, I like some of the new stuff. If you you look at the links in my comment elsewhere in this thread, you'll see some of the transitions that I've made, from an older, OOP/delegate-based model, to one that leverages protocols and closures. I'm not averse at all to learning new tech, but I've found a lot of mileage in combining it with classic patterns.
- mbrodersen 4y agoSame here. And the result is tag I am vastly more productive long term compared with “quick and dirty” developers.
- laurencerowe 4y agoI think it depends a lot on where the code you are working on lives in the stack. The further down it is the more it makes sense to do it right. The further up it is it becomes a question of whether that code will be around long enough to make worthwhile the more interesting invasive changes required to do it right. An extreme case is A/B tested UI code which has a strong chance of not working out.
- drran 4y agoMoreover, I try to embedded documentation and diagnostic/debugging tools, such as meaningful error messages and traces, into code. Usually, debugging takes 3x more time than coding, so it is very profitable to reduce debugging time from the very beginning. Also, I'm automating branching, building, testing, merging, committing, releasing procedures, so for me, it feels like a game: read a ticket, make a branch, write a test case, write the business code, update documentation, tests are OK? -> merge and commit, update resolution comments, send ticket for review and manual testing, next ticket. Of course, it works only when the whole team works the same way and each member of the team plays his/her role properly.
- karmakurtisaani 4y agoI've made peace with the fact that rewrites are almost a necessity, however well you do it the first time. Currently I'm rewriting a well-designed and written piece of code, which just was abstracted in a way that couldn't support new business requirements. I've embraced this approach in personal projects too, and don't suffer from analysis paralysis or gumption traps as much as I used to. You want to make something nice? Prepare to do the same thing at least two-three times, each time being better than the last.
- club_tropical 4y ago100% agree. Rewrites are great and easier than untangling and surgically updating prior code. Far more motivating, too.
- pmontra 4y agoThis week I worked on the code of a customer that was passing an object into a command / service hierarchy and extracting some attributes of that object in the lowest level of the hierarchy, where a method is doing the real job. Unfortunately the new feature I worked on needed most of the methods of that hierarchy but didn't have that object because it doesn't have more than half of the data needed to build it. So, passing individual attributes as arguments instead of the object would have been the right implementation and the assumptions the code was based on were wrong for this new use case. I derived a class from the first level of the hierarchy with only the methods I needed, redefined as empty the ones that were using the attributes I didn't have and ended up with code that passed tests. No time to refactor all the code into the correct abstraction. Time to understand how the class hierarchy worked: too much. Was it overengineered? Yes. I prefer simple straightforward code with few files to navigate to understand how it works.
- karmakurtisaani 4y agoAh, the good old time constraint driven programming. The worst of them all.
- throwaway290 4y ago
- hinkley 4y agoThis is frequently not subtle enough an a source of conflict with coworkers. You don't know up front what 'right' is and quite a few people can't look at this and so they ghost some of their bad decisions instead of owning them and learning from them. The concept of Reversible Decisions is based on the idea that some decisions have a small blast radius, that we should make those quickly and cheaply, and that if we are proven wrong we pivot quickly and cheaply. Don't invest energy here because you'll need it for the Irreversible Decisions. For the Irreversible ones, you need a long runway. You need time to stew on them. You need to know when the Last Responsible Moment is, and you need to gather every bit of evidence for or against a certain solution prior to that moment. Those are the only decisions you need to get right the first time, and often you get a better decision if you delay. Not procrastinate, delay.