6 ms·
This is a fantastic article. Contagion is a really great term. I've seen my poor abstractions be replicated by others on my team, to my horror -- "don't they s
by methodover 8y ago
This is a fantastic article.
Contagion is a really great term. I've seen my poor abstractions be replicated by others on my team, to my horror -- "don't they see why I did that in this particular case, and not in this other case?" Of course, that's entirely, 100% my fault. I picked a poor abstraction, I put it in the code, I didn't document it well enough, and of COURSE other programmers are going to look to it when solving similar problems. They should!
That said... Sometimes I spend a bunch of time finding the right abstraction for a feature that we end up not expanding. And then it feels bad that I spent all this extra time coming up with the "right" solution, instead of just hacking out something that works. Hmm...
- zachsnow 8y agoI have found the closer I am to the product and the clients that will be affected, and the more thoroughly I understand the usecase from the client’s perspective, the better I am at understanding how much effort to spend on “getting it right” in this way. Still wrong sometimes though!
- worldsayshi 8y agoInteresting how you point to a slightly different kind of contagion in replicating code patterns. While the article seems to discuss the kind that is inevitably forced on whoever depend on the code.
- theptip 8y agoI found contagion to be a great clarifying concept too; it's something that I've been looking at in my codebase as the team expands. My gut feel is that it's not necessarily about what you write in the first place, but what you refactor -- sometimes you can get away with a gradual replacement strategy (like std::string => AString from the article), but if the original pattern is contagious and bad, then you might have to take a more aggressive one-shot refactoring approach. I've definitely seen this where a localized refactor is made to try to find a better way of doing something, we decide that we like the new way, and then don't find the time to replace the rest of the usages, resulting in a confusing state of affairs where you need to know which is the "blessed"/"correct" way of doing things. I think that "contagion" is a good lens to use when assessing what the refactoring strategy should be for a given change to the codebase.
- e28eta 8y agoI really enjoyed the Lava Layer antipattern for incremental refactors that never complete. Having learned to recognize it, I think I'm more aware of the cost/benefit of introducing a new pattern, even if it's better in some way. http://mikehadlow.blogspot.com/2014/12/the-lava-layer-anti-pattern.html http://mikehadlow.blogspot.com/2014/12/the-lava-layer-anti-p...
- tetha 8y agoThat article has changed my behavior in some places as well. Sometimes it's indeed better to sit down and replace the entire old solution, instead of going incrementally. It's a bigger immediate pain, but less following pain.
- wpietri 8y agoOne team I was part of kept a separate backlog of technical debt and experiments. It was nice to have a place to say, "in 30 days, look at this hacky thing and see if it's worth making better". Or, "I noticed this is a mess, here's how I might clean it up." We'd occasionally talk over the backlog and prioritize it, which helped communicate both the general make-things-better spirit and specific issues like you mention. I really liked it. One thing that made it work is that we worked on it in small slices all the time, without involving the product manager. It was still visible, so there'd be the occasional question, but as long as we kept delivering user value, nobody worried to much about our mysterious code concerns.
- LtRandolph 8y agoYeah, trusting developers to use their time wisely given a high-level alignment on the big goals can be very powerful. One of our struggles on the individual level is the uncertainty of "is this the little feature that will take the champion from good to great?" that leads to slow and steady feature creep. It's tough to weigh those against tech debt cleanup even though we have the autonomy to work on "mysterious code concerns" when we choose to.
- drinchev 8y agoFunny enough, most companies I worked for, I had to follow "You can refactor if the PM doesn't catch you spending those precious minutes for this". There was only one time, where we had every Friday, time to improve the codebase. 2 months later it became every 2nd Friday, though. I'm really pissed that technical debt is considered as "Hey the dev guys are complaining again".
- dtech 8y ago> I'm really pissed that technical debt is considered as "Hey the dev guys are complaining again". That's because it's very untransparent to anyone other than the engineers working on a project. I've had a limited amount of success by making this more transparent. Signaling every time a feature will take longer because of a piece of technical debt the team wants to fix caused the fix to get priority before implementing the 4th and 5th feature affected.
- danShumway 8y agoI've also seen bad pattern replication, and had a difficult time explaining to other teams why it was a problem. I used to write a lot of app-wide Javascript at a previous job that would get consumed by multiple teams. If I didn't encapsulate something well enough or if I left a private open, I'd later find a code review with someone exploiting it. The worst offender was a team that once used the prototype of a shared class as a mixin, duplicated/mocked just enough of my implementation logic to get three or four methods working, and then left it at that. Of course, the next time I changed any of my code, even in the constructor, their page broke. My experience has been that when other teams see these patterns, they see a single page or feature that's working at the moment and assume "this must be fine." They don't see the three or four frantic show-stopping bugs that got logged last month. When I would confront teams about this, often the response that I would get was "Well, if it's good enough as a quick fix for them, why can't we do the same thing? Why are we the only team that has to fix this?" Of course, when teams don't want to be the first one to break from a bad pattern, the end result is that nobody changes anything.
- outworlder 8y agoThis is my number one concern in my current team. I have implemented a bunch of things that, while helpful short term, had clumky hacks to make up for either lack of tooling, or due to time constraints. And then the solutions get replicated verbatim, because "they work". The more time passes, the worse they become.
- mannykannot 8y agoI would like to suggest that there is a fourth dimension that might be called 'interest' as we are using a debt analogy - the tendency for the cost to increase over the time elapsed since the debt was incurred. When an item of debt is first created, the people making it are often well aware of what they have done and are therefore in a relatively good position to fix it, but that knowledge quickly dissipates, to the point where it is often forgotten that there is a specific issue there. Furthermore, there is a tendency for it to be made less obvious as further changes are layered on top and around (this is distinct from contagion, as it can occur if the later changes are themselves debt-free, or at least independent of the decisions that created the debt and their consequences.)
- sytse 8y agoThe top comment under the articles uses the hight of the interest rate to describe the level of contagion http://disq.us/p/1ros2o9 http://disq.us/p/1ros2o9 'tl;dr "contagion" is the most important attribute because its properties are similar to interest rates. Having a small loan (small impact/fix cost) but high interest rate (high contagion) can quickly dwarf large loan small interest rate.'
- brightball 8y agoOne place I worked addresses this by having mandatory post-deploy monitoring / patch day. We’d all do a deploy and keep an ear to support / logs while going ahead and improving things we knew needed a little clean up. If we saw anything come in from the release, we fixed it immediately. An entire day is excessive in a CD setup, but for a two week release cycle it worked well. Kept the rough edges out of customer view very well.
- 0xdeadbeefbabe 8y agoThe whole tech debt concept might be the wrong abstraction.
- hinkley 8y agoContagion is why I want a VCS tool that allows me to keep code review comments with the code. Just because someone senior did something bad two years ago doesn’t mean you have carte Blanche to make new code that behaves the same way!
- swozey 8y agoWould gitlens help? I love it. https://github.com/eamodio/vscode-gitlens https://github.com/eamodio/vscode-gitlens
- nojvek 8y agoIf I need to have the author explain something in the codebase as part of a PR, I usually make them write it down as a proper comment. “Comments are for human context, code is for computers”