2,220 karma · joined October 30, 2018
I've seen plenty of stuff in my career where I've gone on record to say "hey - we really shouldn't do this". Nothing got done about it. But hey, I did what I could.
Recently I learned about Rasmussen's dynamic safety model. I think this is a very handy mental model to have. It's the human factors that make what we do really hard. Often line level practitioners know better than they are allowed to do in practice and trying to fight organizational politics to Do The Right Thing can be an uphill battle.
I ran the stats retrospectively on a codebase I once worked on to derive sensible values for max class length and max function length. To be honest, they came out at some fairly sensible values and I would be happy putting a blocker in place to say "if you are doing anything more than this, you shouldn't be". I think it was something like 200 lines for a method and 3 or 4 thousand lines for a class.
If you can do it at the outset what you'll find is that the vast majority of the time the rule is never triggered. In the majority of cases that it is triggered, it's trivially easy to break the method up a small amount to be under the limit. It's very, very rare to feel like you're having to break it up unnaturally and it feels very forced, though it happens on the extremely odd occasion. I'm OK with that trade-off. The benefit is you never wind up with the 5k line long methodzilla that someone thinks is a good idea and everyone laments forever.
Every code base I've seen has one godzilla method. I'd prefer we avoid godzilla methods at least. You don't need an 18k line class. Nor a 5k line method.
https://mikhail.io/2018/07/monads-explained-in-csharp-again/
I teared up at this point. I've got a 4 year old and that is the exact kind of thing they do. Just kids being kids don't realize how even the most mundane, simple, innocent of their behaviors can be stress inducing at the easiest of times. Then they do the same things they always do but this time all hell is breaking loose and you're like "please, just don't".
The people that stand out to me aren't necessarily the ones who do what they're told. It's the ones who do what's effective.
I have a two data points from a -10x engineer that say otherwise. They definitely do start things. The rest of us spend a decade making their mess a stable, workable system.
I think there is a bit of Dunning-Kruger going on too. The "architecture astronaut" variety always manage to introduce mountains of tech debt.
I worked with a guy, great engineer, great guy, deep domain knowledge and a very solid understanding all the way through the stack. He was a great mentor and only barked when he was absolutely too slammed to help, which was rare. The thing that always amazed me is not only did he consult on all the really difficult stuff and ship it, but frequently you would come back to code you wrote recently and it would look nicer, cleaner and just a little more polished. He'd been in there leaving not a trail of destruction, but a trail of cleaning.
Now, I have also heard of the trail of destruction kind too. They're more like -10x though. They just pump it out really fast, but super low quality. IMO that's a bad kind of 10x to be. It's 10x the recklessness. A truly great engineer is one that can help the team and the company avoid writing as much code as possible. As such I don't consider the 'trail of destruction' 10xers to be 10xers, but rather really fast cowboys.
I'm glad I'm not the only one out there that sees it like this.
It's a bit of column A and a bit of column B. Organizational politics often blocks productivity. Often the it's better to ask forgiveness than permission is quite effective so long as you're reasonably astute about how much political capital you have, how much you will make from the move and how much you will spend by the move. Other times it's the ability to build consensus and gain buy in to remove the organizational roadblocks is what can really be a force multiplier.
Both of these dynamics are at play.
But... sigh I feel exactly how you feel about Git about Vim. It's the one editor everyone has decided despite it's arcane and bizarre UX that you aren't a real programmer if you don't know.
Refuse to learn it. Absolutely refuse.
I think everyone has one of those things.
But the rest of your examples are very far off base.
I somewhat agree with Single Responsibility being perhaps not quite right as "single" isn't always desired, appropriate or possible. But the general philosophy is absolutely on point. It's an instruction to carefully consider whether a component should be responsible for something or not and if not then think about where else that responsibility should lie. It gets pretty gnarly when you see things that just have way too many responsibilities. They become unwieldy. An object being responsible for holding and manipulating its state isn't what I would class as a responsibility. That is below the line. That's thinking far too granularly about what a responsibility is.
Same for open/closed. There is a great picture that represents open/closed of a human body (being the closed system) that you can put different layers of clothes on (open for extension) which I think beautifully captures the essence of the principle. When this is done right it's an absolute blessing. You mostly find it in frameworks that have a life-cycle and at certain points (say before anything happens or after everything has happened) they provide an overridable method with no behavior. That method allows you to insert logic the framework designers didn't think to cater for, but also keeps the framework life-cycle intact.
The example of dependency inversion just doesn't make sense. If you're creating a string manipulation library it should take strings and nothing else. It doesn't need anything else. If you're creating a string manipulation library in the first place you probably should just use the standard library. Maybe that's just a bad example, but I still don't agree with your sentiment with always avoid runtime dependency injection.
Forgetting the string manipulation example - I'm curious what you have in mind when you say "modules should instead communicate with one another". How does this communication take place? What language are we talking about and what does some code look like? Mostly what comes to mind when I think of that are either newing up an instance of a class or calling a static method, or perhaps making some kind of http/tcp request?
It sort of can though. It depends on the circumstance. If there is an interface with one implementation or even multiple implementations and that interface isn't referenced anywhere nor are any of its references then you can reason that those dependencies might be provided to the DI container but will never be requested as they can't be. In that case - delete them.
In the case where you have one interface which has multiple implementations and the interface is referenced, I agree. Nothing will tell you if there is one implementation sitting there entirely unused forever.
If you wanted to solve that problem you probably could. In practice I don't find it a big issue.
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?