4 ms·
There was that recent post about innovation being a limited resource. Clever is a limited resource. Save your clever for good, insightful architecture, or for w
by stcredzero 7y ago
There was that recent post about innovation being a limited resource. Clever is a limited resource. Save your clever for good, insightful architecture, or for when you really need the algorithmic chops. Don't expend it just to impress your coworkers.
- runevault 7y agoAnd for the love of god when you do actually need to be clever, document the hell out of why and what the trade offs/benefits were. The first time I had to be clever to get performance I put a nearly half screen comment of why the hell I did it.
- kosievdmerwe 7y agoAnother trick to manage cleverness (or even just messiness) is to hide the code in a well-named function, so readers can understand what it's doing in the context of the rest of the code and only have to delve in when they need to.
- georgebarnett 7y agoOnly somewhat jokingly, this is the start of things like doBillCustomer().
- stcredzero 7y ago"I'm gonna code me a new minivan!" --Wally
- james_s_tayler 7y agoMy favorite recently is a class named CustomerCommandMapEmbelisherConverter. It's not a good name. Nor is it concise, informative or anything vaguely useful. But I get the strong feeling it comes from someone spouting off a line along the lines of "we need to name things for what they do" and then someone else just coming up with that. In your case I'm going to guess doBillCustomer() is about 2.5k lines long with a copy of its entire logic duplicated and it branches based on annual or monthly billing and subtle bugs have been fixed in one implementation but not the other and now they are diverged such that they are only 93% the same but that means all bets are off. There are 15 levels of nesting and it interacts with at least 5 external systems during all of that. Am I close?
- hinkley 7y agoMove the code that should be clever to a separate function, then add the clever in a single commit. People tend to tolerate clever code that is out in leaf functions they don’t have to step through, and knowing they could revert the change makes them tolerate the clever longer.
- deogeo 7y ago> Clever is a limited resource. Save your clever for good, insightful architecture I'd sooner say clever is a skill, that gets better with practice. Compare it to solving tricky math problems - the more you solve them, the more clever you 'expend', the better you get.
- runevault 7y agoSome of A, some of B. But there's plenty of ways to expend clever that don't make the code harder to read as well (clever architectures that aren't obvious before you create them but once they are built are still readable). Clever tricks that require being clever to read as well as to write are the dangerous ones.
- stcredzero 7y agoClever tricks that require being clever to read as well as to write are the dangerous ones. There's a level of clever, where things seem complex and abstruse on the surface. There's another level of clever, where things seem clear and simple on the surface, but deep insight went into making things that way. (Then there's a level of faked deep-clever that relies on "automagic," but which isn't as clever as it seemed on the surface and costs a ton of extra debugging time.)
- deogeo 7y agoNever meant to imply otherwise :)
- stcredzero 7y agoOver the years, I have encountered dozens of programmers in their 20's and 30's who seem to prioritize impressing fellow programmers over the clarity of the code base as a whole. In fact, I'd say there's something about programming education which seems to produce these attitudes.
- stcredzero 7y agoI'd sooner say clever is a skill, that gets better with practice. Exactly! However, keep in mind the difference between rehearsal and performance, and act according to the cost/benefit. It's very analogous to what stand-up comedians do. They do a form of practice, where they try material out with friends in private. There's another level of practice when they're on the road, but in small, obscure venues. Those are the times when they go "courageous," take risks, and try new things out. It's a different matter entirely, when it's their big HBO special filmed in some huge famous theater. That filmed show is going to be a permanent record which affects their reputation for years after. Think on this, when coworkers check code into production. Code in production might be executed and read years down the road.