If I were asked to improve a project from a few years ago, what improvements would I make?

In 2008, before I graduated from university, I was working as an intern in a company. At that time, the boss took over a project, which was a web version management system for a subsidiary company of PetroChina. A classmate and I bit the bullet and finished it. The back end of this system uses c# web form, the front end uses common html+css+javascript, the database uses sql server2005, and the deployment server uses Microsoft Server 2008. Looking back on this system now, although the code is badly written and the architecture is badly written, it can run normally. This is due to occasional small bugs that are inexplicable and difficult to solve. After all, it was my code 5 years ago. At that time, I was too young, I didn’t know a lot of things, and I didn’t have much experience.

So if I were to upgrade the function of this system, or even redo it, what improvements would I make? This is an interesting topic. If you can really find out a lot of shops that can be improved, it means that you have really improved in the past few years.

There is a real possibility that this system will be functionally upgraded. I thought about it, and I will make improvements and adjustments in the following aspects.

  1. Use the latest Visual Studio IDE and install the ReShaper plugin. Now it has become a shortcut key control, reconstruction control. As the saying goes, if a worker wants to accomplish something, he must first sharpen his tools. Good programmers use the best tools of course. The new Visual Studio has improvements in efficiency and intellisense. As a refactoring tool under .net, ReShaper is of course essential.

  2. Host your code in a private repository on github, using git as your source control tool. In the previous project, svn was used, and the company server was used for code hosting, and the company server was not so stable. As a distributed source code management tool, git is free from the shackles of the central server, and has the characteristics of rapid creation, branch switching, local submission, etc., which completely explodes svn. As the world's largest code hosting center, github is convenient and practical, and the cheapest membership is 7$ per month, which is economical.

  3. Log the important functions in the system. Back then, we wanted to record some program logs, and we had to write a simple log class library ourselves. There are many mature log frameworks that can be used by C#. Just imagine how difficult it is to troubleshoot bugs when your program is deployed on the server, if there are not enough logs. The server can't let you restore the scene, can't debug, the only thing that can help is those logs. Of course, there is a lot of knowledge in logging, such as log level settings, output settings, etc., so I won't go into details here.

  4. Handle complex logic using transaction mechanism. There were a lot of concurrent operations in this system. At that time, I didn't understand transactions very well, and used some very lame methods to handle possible data exceptions. Now I will use a mature distributed transaction mechanism to handle these concurrent logic to make the program more robust.

  5. Use TDD to improve unit test coverage. There were no unit tests in the previous system, and a simple piece of code required manual verification by the launcher. Such feedback is time-consuming and not repetitive. Test-driven development can ensure that the code is concise and correct, and can get feedback quickly to ensure test coverage. When encountering legacy code, you can also add unit tests first to establish a protective net and make refactoring more confident.

  6. Automated functional testing with webdriver. I once changed a piece of code before demoing to a client, and I didn't expect that this code just broke an important function of demoing to a client. All this can be avoided if there are automated functional tests. Automated functional testing increases confidence in the product that every change is under control.

  7. Write build scripts for continuous integration. Even if only one person is working on the project, build scripts should be written to apply continuous integration. This ensures that each of your commits is safe; and automating some repetitive tasks frees your brain to focus on more important areas.

  8. Automated deployment. It is a painful experience to deploy a project to the server every time. It needs to manually replace some files in the project, copy the files to the server, and terminate the current server service... Any error in any link is a fatal blow. Manual work is not only inefficient, but also prone to errors. Automating deployment by writing scripts can be done once and for all, and say goodbye to tedious manual operations.

  9. Use Nuget as a dependency management tool. If you want to reference a 3rd party dependency and need to manually download it from the web and add it to your project, then you're out. As a Java programmer, build tools such as maven and gradle are standard, and they all provide automated management of dependencies. You only need to add a string to indicate which class library you want to use, and the download and reference are all handled by the management tool. Of course, there is a corresponding product in the c# world, that is Nuget, and dependency management is no longer a headache.

  10. Use c#'s own features, such as LINQ, delegation, functional programming, etc. Compared with the Java language, which is not enterprising, c# does not know how many times stronger. Java officially introduced Lambda in the Java 8 version, and LINQ of C# has been out for many years. If you're only using foreach when doing list operations, you're too old-fashioned. List operations are nothing more than filter, map, sort... and c# has provided us with a series of extension methods, such as Where, Select, Sort.... Poor Java can only use a nondescript third-party class library like Guava to achieve the corresponding effect , and far less beautiful than the native functions of c#. Since c# references so many features every year, it is necessary to learn, master and use. Many people use the old-fashioned syntax of C# while saying that they are proficient in C#, which makes people speechless. Putting so many good features out of use makes us Java programmers really envy and hate.

  11. Use some front-end frameworks and JavaScript frameworks. For a front-end novice like me, it is really powerless to want me to design a beautiful page. Don't be afraid, the designers have taken into account the feelings of the front-end incompetent, such as bootstrap and other front-end UI frameworks are simply born for us. These are not only easy to use and have obvious effects, but also come with a responsive design. They are really powerful tools for front-end Xiaobai, and it is no longer a dream to realize your own beautiful web site. Not much to say about JavaScript, what jQuery, AngularJs, ExtJs... Various framework class libraries emerge in an endless stream, covering all aspects of front-end development. Whether you want to draw, manipulate DOM elements, create single-page applications, use MVC architecture... in the JavaScript world you always have options. Back then, in order to display a statistical graph on a web page, I used .net to draw a picture in real time in the background and load it into the foreground for display, and it was all tears. Ok now, just bind the data model to the chart control, and it will be done in minutes.

Well, that's all for writing. How to judge that a programmer really has N years of work experience, rather than 1 year of work experience reused for N years? A good way is to take out a previous project and see what improvements he can make.

For programmers who have worked for many years, they must have a wide range of knowledge and vision to be competitive. This depends on the usual learning and accumulation, but also good at thinking, how to do better at the things at hand.

Author: Huang Bowen@Invincible Beigua 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326823728&siteId=291194637