4 ms·
I think this is ultimately caused by developers not quite knowing where and how to place their ambition. It's easy to look at the big legacy app and be like, "I
by vinceguidry 12y ago
I think this is ultimately caused by developers not quite knowing where and how to place their ambition. It's easy to look at the big legacy app and be like, "I can fix that!" Then they roll up their shoulders and go to work, management be damned. Management can't see or understand what he does, and they're paying him for his expertise, so they give him the benefit of the doubt and let him do what he thinks he needs to do.
I documented my own answer to this situation here. Basically, don't treat organizational problems as technical ones. They're paying you to do a job, everything else you do is basically an ambition. First rule of ambition is to do no harm.
https://news.ycombinator.com/item?id=8768524 https://news.ycombinator.com/item?id=8768524
If you're going to refactor, don't refactor in the direction of new. Refactor in the direction of coherency. Do things that you can finish, or, that at least, don't matter that much if you don't. Like adding tests. Nothing wrong with that.
If you want to fix the legacy app, you need to make less ambitious changes, because you need to be able to finish them. Instead of changing the data types, refactor the initialization code. The initialization code runs once, data manipulation code is basically convention and you need to change it everywhere at once or not at all. Refactor it to the point where you can change it everywhere at once and then do that. Or get really good with a text editor and macro the changes.
Giles Bowkett has a great book on it. Unfuck A Monorail For Great Justice. It's Rails-specific but the ideas can work everywhere. Write code that understands code.
http://gilesbowkett.blogspot.com/2013/03/new-ebook-unfuck-monorail-for-great.html http://gilesbowkett.blogspot.com/2013/03/new-ebook-unfuck-mo...
But understand that there are probably better things to do with your time. You can pick out pieces of the legacy app and try to understand them well enough to rubber-duck debug them without having the source code in front of you. Once you have that then really, you don't need to be a hero. You're already a hero because you know the system better than anyone. You can focus on other things. Maybe use your new-found credibility to build some consensus among your peers and managers. Then when you make your case to replace the app, it won't just be you.
- _asummers 12y ago> Refactor it to the point where you can change it everywhere at once and then do that. This can be generalized: refactor the code to the point where what you need to next is easy to do.
- algorithmsRcool 12y agoI feel like this is very sound advice but i'm not sure if i can really accept it fully. I'm a fairly green developer (3 years professionally) working on an C# application that suffers from design schizophrenia as detailed in the article. I'm more or less the sole developer assigned to it now. Although I am new, I feel very strongly about my 'pride as an engineer' in my application of sound design, knowledge and rigor to the best of my abilities. So it discourages me greatly when i hear a lot of "Uhh, that was a long time ago...", "We had tough deadlines..", "Well developer 'X' and me disagreed about that..." from the former maintainers of the code. I've taken to a rash practice of just tearing out tightly coupled, untestable, duplicated and poorly designed code by the roots. I feel like i am somehow passing a 'holier-than-thou' judgment on the work of my predecessors. But due to it's tight coupling i can't have much confidence about even seemingly simple changes since they always seem to come back with a wagon of defects. The new code i write surely isn't perfect and has it's own defects that come back to me, but i feel much better about the code in many ways and i am always open to criticism and discussion over my design choices. If anyone would ever give them serious study... I have this gut feeling that if i leave the code i touch messy that i'm not doing my job and the next poor soul to come behind me will lose weekends to trying to clean up an even deeper mess. I feel judgmental even voicing these thoughts.
- vinceguidry 12y ago> I've taken to a rash practice of just tearing out tightly coupled, untestable, duplicated and poorly designed code by the roots. That's not a terrible approach. Depending on the context the code is running in, that might be a worthwhile way to maintain it, especially if there's not all that much different between doing that and working on it as is. If it's taking you the same amount of time, why not leave it better than you found it? The important thing is that you finish the job, and it sounds like you're doing that. You're not making a three-year plan, not telling anyone about it, and doing a little bit every day. That way lies the lava layer. Me personally, I have like four other projects I could be working on. Give me a choice between working on old legacy and working on new hotness, I'll band-aid the legacy every time and just get on with life. I didn't use to do it this way. I wanted to make my mark on the legacy codebase, prove that I was better than it. So I'd tell my boss I'd need the rest of the week to implement this and then dive in. I'm happy I don't need to do that anymore.
- jrochkind1 12y ago> If you're going to refactor, don't refactor in the direction of new. Refactor in the direction of coherency. 1000x times this. And making things coherent will make it a lot easier to put the new hotness in too. Add in the new hotness only when you can do it in a coherent way. If you can't do it in a coherent way, you might need to refactor until you can get there. You might never get there in a legacy codebase, but if everyone took this attitude from the start, you might be less likely to end up there. You can put new things in and change architecture, but you always have to do so coherently -- which does mean you can put in fewer new things, and sometimes not the new things you want to put in as soon as you want to put them in. And oh, yes, so very much: "don't treat organizational problems as technical ones." Without understanding the organizational disfunction at the root of your technical issues (it's almost always there), you're doomed. Of course, then you've got to figure out what to do about the organizational problems (or how to operate succesfully in their shadow), which is not what you find the most fun part of your job, but that's how it is.