What improvements did I make when I was refining an old project from a few years ago?

What improvements did I make when I was refining an old project from a few years ago?

[[134665]]

In recent months, I have used my spare time to complete a project. This project was actually a web project I worked on in my previous company in 2008. Later, the client wanted to upgrade the project, which involved some functional changes and interface modifications. Since I was responsible for the entire project architecture and main coding at the time, the former company's boss asked me to take over this project and complete it in my spare time. I thought about it and agreed. I just work hard to earn some money to support my family.

A few months ago, before I took on this job, I wrote an article titled "If I were asked to improve a project from a few years ago, what improvements would I make?" It mainly described the improvements I would make from the perspective of engineering practice.

After several months of hard work, I finally completed this feature upgrade and got paid. Let me talk about the specific changes I made to this legacy system.

1. Try not to change what is not needed. Since I wrote the code as an intern in 2008, it is naturally terrible, and some parts are very cumbersome. After several years of polishing, my requirements for code quality have risen to many levels. Seeing these bad codes, I can't help but want to refactor. But I held back, because this is a legacy system, and there was no unit test at the time, so the refactoring process must be risky. In addition, the project can only be completed in my spare time, and the new requirements should be the main focus, and only the code that needs to be touched when developing new requirements should be changed.

2. Use GitHub as a code hosting service. Even if you are developing alone, you still need to use source code management tools so that you can have peace of mind. I have used GitHub for several years and it is very useful. I also bought a GitHub membership. So this time I put the code on it as a private repository. You can write and submit at any time, which is much more convenient than setting up a source code server yourself.

3. Introduce the bootstrap framework as the front-end framework. An important task of this upgrade is to optimize the front-end to make it compatible with multiple browsers. In 2008, everyone was using IE6, IE7, and IE8, but few people used them. After so many years, the website is no longer compatible with modern browsers, and the screen resolution adaptation is also very poor. As a front-end novice, I only spent a little time learning bootstrap and quickly introduced it into my project. I basically deleted the previous css and js codes, and used bootstrap to easily transform this old website into a website compatible with multiple browsers and multiple screen sizes.

4. Upgrade various components used in .net. This website uses the WebForm framework, version 2.0. I found that the front-end HTML, CSS and JavaScript generated by the WebForm component in modern browsers have a lot of incompatibility issues. The website page became very unstable. After upgrading to the 4.0 platform, the problem was greatly improved. In addition, I also used the AjaxControllToolKit component and found that the page could not be partially refreshed in some browsers (such as 360 browser). So I also upgraded to the latest version 15.3. Although various components have been upgraded, there are still some JavaScript problems, such as the calendar selection box cannot be displayed and selected normally. The method I adopted is to abandon the old JS code and seek a mature JS framework to replace it. For example, use the bootstrap-datepicker component to implement the selection of the calendar box.

5. Use the latest Visual studio editor. Microsoft finally figured it out. Instead of letting us use pirated Visual Studio all the time, it is better to directly release a community edition. I downloaded the Visual Studio 2013 community edition and installed the ReSharper component. Since ReSharper is paid, there is a trial period of about 1 month. I have been using Intellij development tools for development before, and it is also very cool to use it in Visual Studio 2013.

6. Introduced the package management tool, using Nuget to install and manage various project dependencies. During use, I found that Nuget is not as powerful as Maven or Gradle under the Java platform. Many dependencies are not the latest version, and the management concept is also different. But it's better than nothing. I manage front-end components such as bootstrap and back-end components such as ajaxcontrolToolkit through Nuget.

7. Use the transaction mechanism to handle the core logic in the system. This system is a coding management system that mainly handles the entire circulation process of explosives and detonator coding. Sometimes the system will have duplicate coding. For example, the code of a detonator exists in both the inventory and the consumption warehouse. This is because there was a problem when the detonator was converted from the inventory state to the consumption state, and the code was not deleted from the inventory. In this upgrade, I used transactions to handle similar logic. Once an exception occurs, the entire system will be rolled back, and no dirty data will be generated.

In fact, several points I wanted to introduce were not completed for various reasons.

1. No unit test was added. I wanted to add a unit test framework to Visual Studio 2013, but it took me several hours to get it done. In addition, the project directory also needed some adjustments to introduce test projects, but after failing to do so, it was abandoned. Since 80% of the functions of this upgrade are improvements to the front-end pages, not much back-end code modification is involved, so I am more confident in modifying the existing code without unit testing.

2. Continuous integration was not introduced. It was still due to time cost. After all, this work was done in my spare time. It would take several days to build CI for the C# stack, so it was not implemented in the end.

3. Automated deployment. Previously, the deployment of .NET websites was manual, which involved copying the compiled files to the server, pausing IIS, reloading the files, and restarting IIS. In fact, these can all be automated, but I didn't spend time studying them, so I didn't implement them.

4. Use a mature log framework to log the key logic of the system . I am just lazy and don’t want to do this. Because adding logs will make it easier for me to troubleshoot errors later, and it has no impact on customers, I am too lazy to do it.

5. No automated testing was introduced. It was still due to time cost. Writing automated tests for the web took too much time, so it had to be abandoned.

<<:  VLC-based video player

>>:  30 Unforgettable HTML 5 Templates

Recommend

Advertising poster planning and design guide

Good design can increase exposure, enhance corpor...

Insights into new marketing trends in 2022

2022 is getting closer and closer. Looking back a...

5 Taobao store operation routines to double your sales!

E-commerce has developed rapidly in recent years,...

Case study: Steps to set up a Kuaishou information flow advertising account

The delivery operations of information flow platf...

Mobile app performance issues determine user retention

——China’s first in-depth analysis report on mobil...

Microsoft copied more OS X gestures in Windows 10

According to a report by The Verge, a Windows 10 ...

Why do users pay you?

When we are doing event planning and product sale...

2015 App Promotion Guide (Full Version)

Online channels 1. Basics are online The major mo...

Does the "graviton" really exist? Condensed matter physics finds a "substitute"

Author: Luo Huiqian, Researcher, Institute of Phy...