How to deal with great products written with shitty code?

I was asked to improve and maintain the internal web application used and approved by an important community of users. This includes performance improvements and feature additions.

Unfortunately, the code is bloated, sometimes very poorly written, and difficult to read and modify. This greatly complicates the implementation of the changes.

Despite all this, the application looks beautiful, useful and users like it and want changes.

That’s why I feel like I’ve been deceived. Is it really better to write cheesy code for a faster result and fame, and then leave it for large new projects that leave so many problems?

I already read a lot about this topic on Coding Horror , but I would like to read more from people who experience this sad reality and how they deal with it. Perhaps I probably also need to show courage;)

Since my main language is not English, please rewrite this question with better grammar.

+7
language-agnostic
source share
9 answers

This will happen to most programmers. The first desire is to rewrite it. The best approach is to just do what you are asked to do. If you move on to basic transcriptions, you are likely to break it.

If the required changes are simple, you should implement them with as few changes as possible in the style in which it is already written.

If the changes are more difficult, try to apply your changes as few places as possible. If your plan is to clear the code over time, this is the place to run. Be careful with the changes you make, because you can easily break dependencies that you don’t understand. My personal experience was that I usually add new functions or implement changes, actually deleting the code and rewriting what is left in any given routine or method.

Resist the temptation to rewrite everything. Look at it as a sort. The priority of the changes that you would like to see and implement when you make the changes that are set. Avoid influencing code that you are not prompted to change. Do not force your users to solve problems because of changes that you make only because of aesthetics.

+5
source share

Almost every developer, ever, everywhere, when he was injected into some code that they did not write, he wants to rewrite it to fix crappy bits.

Resist the urge to rewrite everything, fix bits that are broken. Handle bits that are unreachable when you need to support them!

+10
source share

Write a set of tests for the product to be sure that you are not breaking anything.

Then reorganize the worst bit of code or the bit that you need to change anyway.

But: think about "if it has not broken, do not correct it." If the area is working and you don’t need to change it, consider whether the risk of introducing problems is “good”.

And find the original developers and seduce them into some dark alley :) Or better, make them change

+7
source share

I wrote cheesy code for some projects. However, reasonable "bad" code. An insidious code can be caused by many reasons, and not just human skills (well, in most cases this is related to skills)

Programmers can write very good code if you have enough time and no pressure from the business. However, business people do not appreciate good coding, but functionality and appearance. I think the "crappy" encoder is the smart guy in the business. He simply developed a solution model, earned software in a short time, and also made the employer happy! If you let the encoder write it again, he / she can do it much better.

First of all, you need to convince yourself to evaluate how many things the early coders went through, this is one of the issues to consider if you are a mature developer or not. Most people complain and even laugh at existing versions because they know that they can do it better. It is like drawing on blank paper with your imagination or making a copy of an existing picture. Which one is harder?

Secondly , look at the general code and find out where it can be improved, you can find what you misunderstood.

Thirdly , a roadmap, this may contain recent and future TODO

Finally , start planning how you can improve it if you create it from scratch, a new architecture, etc. and present it to the leadership when it is ready and complete.

Each software has room for improvement, so you hired it to improve it.

+5
source share

Bad code technical debt ; it may be cheaper to write, but it becomes much more expensive to maintain (unless you pay off the debt by refactoring or rewriting).

You can get faster results and fame, but when users later want to make changes, you will have to spend more and more effort on their implementation (or fixing the inevitable errors).

+3
source share

Yes, some poorly written programs are popular. The disadvantage is that such applications become more complicated over time (for example, in terms of scaling, adding new functions, fixing bugs, etc.).

But no, it's not good to write garbage code. It’s good to determine what users want, and give them a good interface, etc., and make the code convenient for maintenance. Sometimes this may mean that users will have a bit more time for new features, especially at an early stage, but you can do more in the end.

In your case, I suggest you try to improve a little at a time. If you can, cut one area and "fix" it, and make sure it never goes back to the "bad old days." Then cut the next area, etc. In the end, you get a beautifully written application. This may take longer than rewriting from scratch, but you can give users improvements as you go, and you will have more confidence that it is a working system at any given time.

+2
source share

Sometimes, when a programmer first builds an old project and sees that all classes, interfaces, code modules, etc. immediately consider it "bloated." In fact, it may just be a very deep architecture, which may be overwhelming at first. If your project does not have documentation (such as class diagrams), take the time to draw it. This will help not only understand how the project works, but also help anyone who follows you.

This also applies to statements such as "hard to read." If you know a programming language, then it is not difficult to read, like any other application. The original style of the programmer may differ from yours, but if the application works, then they do nothing that the language does not allow them to do. The flow may be difficult, but this can be overcome by drawing a process (for example, a flowchart). Most managers will let you study the learning curve before making changes to the application. Take this time to sketch some diagrams, you (and the programmer who follows you) will be glad you did.

As for the “crap code,” it is very subjective. Is it really code (implementation) that is “crappy” or design? Is there a flaw in design patterns? Excessive or poor implementation of design patterns? Or do they really implement robust design patterns, but you're just not familiar with them to recognize them?

The bottom line is that it can be overwhelming when a new project is submitted for support, and it’s easy to blame the original programmer for “bloating,” “crap code,” “hard to read and make changes,” etc. Sometimes this is really true, but many times it may be due to the fact that the programmer does not understand the design and architecture of the application or understands why some things were implemented the way they were.

+2
source share

Make sure that your management and users know that the code is of poor quality in terms of interchangeability. When evaluating how much time you need to implement new features, always indicate how much time you need to clear the affected code.

+1
source share

"Despite this, the application looks good, useful, and users love it and want changes."

The application clearly provides customers with what they want, but it looks like it has reached an inconspicuous stage.

I think there is nothing else for this but refactoring tirelessly. It will probably be easier and less painful if you resist pressure in order to add some non-trivial functions at the same time. By all means, tell managers that, despite the fact that the software is good, he risks becoming one big pile of unreachable piles.

Improving your code often introduces one or two errors yourself, but in the long run it will save you a lot of damage. Get as many extra eyeballs as possible to help with testing and debugging, and stick with really bad bits first.

Consider introducing unit tests if your previous employee has not done so already, so you have a lot of confidence that refactoring has not broken anything. I do not advocate the philosophy of "if this failed ...", as this will keep you on the same unsatisfactory carousel.

Don't worry about your English, it makes sense to me, and your predicament is universal.

+1
source share

All Articles