(R) on large software refactoring some of the ideas

2010-04-01  来源:本站原创  分类:Development  人气:108 

The current project is to do almost a year and a half, and look back, before the year is doing reconstruction and then in a year is to create a new product. Do a little remodeling here summarize some of the things learned when it.

Reconstruction can in fact be a different goal, some refactoring to make code more reasonable, beautiful; while others may be in order to achieve a particular function; also have different levels of reconstruction, and some may just be the function, class level to make some changes, while others are to the entire structure, modules do change; reconstruction of the input is also very different, and some only in the event of bad code or design when it is corrected, while others will set up a special team to spend a long period of time to do the reconstruction.

Precise definitions of basic concepts is the basis for all discussions, I am here to discuss reconstruction "in order to achieve a functional and devoted to large-scale code change."

Architecture design, you can see how far

It simply, we need to do is put a software function of the UI code and the complete separation of the core, then core made of a single product. Of course, this so-called presentation layer and business layer to separate the truth is no one understands, and had indeed joined in the structure of these concepts, but the absence of strict requirements, but also never to separate out the core part of the run, After nearly a decade of development, the core layer of the UI code dependence has been very serious, there is static, dependent on the source code is compiled, there are also dynamic, runtime dependencies. This time to extract the core functions are undoubtedly very difficult and time-consuming (the amount to millions of lines of code in mind). There are now some open source CAD software online, a lot of that is beginning there is a clear division of Core-UI, and can run in kernel mode or UI mode. If FreeCAD . Think if it was then the architect can think of this step, from the outset a clear division can be sure: first, post-human and material resources without spending so much; Second, the quality, design will be much better.

Of course, this fact is not necessarily a vision is not enough, when considered together, and commercial interests, a lot of good design had to be abandoned. For example, your product is only for Windows users, the project group are Windows programmers - for better and faster product launches, cross-platform, you should not consider it - but years later, the boss decided to the Mac into a ~ ~ ~ So, this one is the best, destiny it.


Must be open to a separate branch. Behind closed doors, so you can "do whatever they want", and will not affect the other team. Here do whatever they mean:

  • Build Errors are allowed

Because it is a great code base, you may change somewhere in another one cause compilation errors, or do you use the script to modify surface is particularly broad, and in the machine to do a full build may be a half-day (right, that is used IncrediBuild ), then check-in after the server to help to build, you can continue to work, there are several build error, it does not matter!

  • Regression is normal

Each time before check-in, do not run those kind of automated testing.

Of course, this freedom in many cases is not recommended, but in here, but a very large increase efficiency.

In addition, because changes in the amount of reconstruction is very large, so often with the main or trunk branck to sync, the one-time change control in an acceptable range.

How to ensure quality

Mentioned above, we can not run automated test and check-in, then how to ensure the quality of it.

First, you must have a test automation - based on the code unit testing Ye Hao, script-based functional test but whatever is automated, and it is ok enough coverage - and doing reconstruction, especially in large-scale reconstruction when there is no automated testing, it is simply seeking death.

Because we are working on their own branch, as long as back main / trunk when no regression on it, the middle is what the state we are not very high. The general practice is:

  • Smoketest will run about a week and some related acceptance test, to prevent some major problems.
  • Time and main / trunk sync, we will spend about 4 days or so to do "automation triage" - the case of all automated tests are run again, get the report after the analysis one by one - or batch analysis, because many failure are the same.

This approach greatly improves the efficiency of - you know, we should finish all of the case, along with dozens of servers required to run three days ~ ~ ~

How to manage code

Reconstruction involves a lot of movement and split the file, you need to pay attention to two areas:

  • File history information can not be broken

How a file is changed step by step over is a very important message - you can easily be found who at what time to turn over the documents, how to change the. Move, or split files is very easy to inadvertently lose the history of the operation. Must be correct to use SCM tools to keep this information, such as perforce where we should use intergrate, rather than simply add.

  • Correspondence between the file can not be arbitrary

Involved here from the main branch to the intergration, you put a file in the branch moved on and made changes, and in the main on the same change was made to do intergration, you can easily lose people on the main changes because the correspondence has not been established, there is no way to merge the. I want a different SCM tools should provide a solution, such as perforce in its branch spec can illustrate in their correspondence.

Reconstruction method

I read over during the "reconstruction ---- improvement Design of Existing Code" , mentioned above a lot of good methods and steps to improve the design, but basically useless on. Because of the design, we either case, how to modify the prior research and have been doing the program, and those steps feeling slightly wordy, is not very applicable. Visual Assist provides a reconfigurable module, in general, with the size of the code can also be used, but there are a number of solution for the code can not do anything. Moreover, these are only related to the source code refactoring, we have a project / DLL 's reconstruction.

Our approach is: for different situations, to write perl script to automate some tasks. A simple point example: I changed the name of a method, the script will search all of the code, automatic check-out the file to edit, and replace the new name. Remember to write a perl script to automate many of the calls for perforce, VS call, code, project file changes and so on.

Some of the details

  • interface using the interface for our refactoring work can be said to do anything, and it is a lot of use of the interface before allowing this has been very tight coupling of code UI-core separation is possible. Such as a core layer of the operation is complete is called to refresh the UI code, and move out of this refresh operation is very difficult, this time with the interface is good practice:


    Of course there are other ways to use interface, but ultimately is to achieve separation.

  • Use vsprops
    We are using Visual Studio, hundreds of projects has its own settings, but in fact, many settings are similar, can those same settings into a vsprops file, so that each vcproj file to reference it. To the extent it can improve the degree of consistency and simplicity. MSDN has a detailed description .
  • Virtual function and rebuild. Add, delete virtual functions, especially in the base class virtual function will destroy the original virtual table, so unless all possible references to rebuild the code, or will produce very strange function call, specifically to see this: on the virtual point out the things that function .

Reconstruction of large-scale software to do this, I learned more and more is:

  • The face of some large-scale software systems will not commit Chu, would be more confident.
  • Develop automatic habits, some of the large number of manual operations, will be very tedious, very time-consuming, error-prone to do and there is no sense of accomplishment, but to change if the goal: write a program to automate the above that the problem is not gone :)
  • (R) on large software refactoring some of the ideas 2010-04-01

    The current project is to do almost a year and a half, and look back, before the year is doing reconstruction and then in a year is to create a new product. Do a little remodeling here summarize some of the things learned when it. Reconstruction can

  • Software refactoring 2010-05-21

    Reconstruction (Refactoring) without changing the software is based on the existing functions, by adjusting the program code to improve software quality, performance, design patterns to process and structure more reasonable and improve software scala

  • (Switch) on the reconstruction of some of the ideas of large software 2010-04-01

    The project is also faster to do the current year and a half, looking back to do before the year is in the reconstruction, then a year is in the building of a new product. Sum up to do a little remodeling here when it learned something. Reconstructio

  • A two versions of the old and new R & D management software comparison 2011-01-24

    Relative to the V3.0 version, V3.1 version offers more features, but the database structure is compatible, so the Topo 3.0 free version users only need the following steps to complete the upgrades. 1: apply for a new free version of the license V3.1

  • Software refactoring technology PPT 2009-02-26

    Today, the company talked about aspects of reconstruction, we do not want to explain the reconstruction was found, but the refactoring tools are not familiar with, and if the flexible use of tools, refactoring is a very pleasant thing A live demonstr

  • On process reengineering and software refactoring 2010-09-11

    Today, looking at process re-book. I suddenly thought, ideas and the software reconstruction process reengineering is a reason. Reconstruction software, is the time when the software user behavior does not change, just change the software program str

  • We are what R & D management software? Me one! 2011-02-16

    Topo cloud technology R & D management system is an innovation platform for R & D management, to provide a unified platform for R & D project management, process management, team collaboration complete solution. The system is a data and docume

  • Software testing road constantly with ideas and creative soul 2010-07-28

    Software testing is a creative industry, really need to understand and people like it to mind and soul with a continuous creation. Really likes the test, constantly improve yourself, you can in your own software testing on the road, wider and wider!

  • Software engineering ideas 2009-11-21

    Note: 1) Dr. Lin Rui Zheda the "software engineering thinking" book full chapter 8. This is Mr enough in their own operating company after the success of a profound summary, it is the recommendation of another of his article entitled "Unive

  • Software Testing Software Management Experience 2010-03-08

    Software testing management experience in the software on software testing Person A asked: "test to do too much, make bug solution will not finish?" Person B replied: "It is not easy. Just do not do testing, there is no bug." The dialo

  • Software architecture design points 2010-03-26

    Today's software industry, software architecture decisions, and the software is good or bad. Other than people like skeleton, skeleton, etc. If people are not good, then people are very vulnerable. Software architecture in software engineering that w

  • Industry application software in the field of question? 2010-02-24

    This is a 2 years ago to write articles, and later a harmonious, now changed a bit, re-release: Now the area of enterprise application software, very bad living environment, ISV's profit margins are not large, the reason is it? Largely economic monop

  • Software development and SaaS business model 2010-05-04

    I had some time ago to CIO (chief information officers) point of view of SaaS applications to implement and possible problems , many of whom questioned on SaaS words , this will stand the perspective of software developers continue to SaaS for anothe

  • Software Name Specification (version number) 2010-12-14

    Software naming convention Stage version of the software instructions Base version: This version indicates that the software is only a false link to the page, usually includes all the features and page layout, but the page features are not doing the

  • Software Architecture: General Designer 2011-05-11

    Software Architect is an emerging software industry, occupation, job function in a software project development process, customer requirements into specifications for development plans and text, and to develop the general framework of the project to

  • Software requirements analysis and management of the ten issues 2010-07-17

    [Transfer: http://www.cnblogs.com/neozhu/archive/2009/03/06/1404713.html ] 1 What needs work is related to First of all needs, including product requirements, user needs, software requirements. Product demand is concerned about the standardization of

  • Software development process (CMMI / RUP / XP / MSF) is a non? 2011-06-07

    We often see and hear in the debate agile process, RUP and CMM software development process which the process better, or which is not good, each has a reason, the argument was exhilaration ...... In fact, there is no perfect process, nor is there a b

  • Topo R & D team can bring any 2011-08-09

    Topo R & D team can bring any Topo for the whole R & D project management processes and tools that support process management, can help development teams to quickly optimize the development process, improve team productivity and product quality. T

  • Software Development Process (CMMI / RUP / XP / MSF) are with non-? 2009-05-05

    Often see and hear everyone in the process of argument Agile, RUP and CMM software development process which better or what the process well, have their own reasons, the controversy was in fact ...... joy, there is no perfect process, there is no bet

  • Software Quality Management (1) 2009-05-09

    Software Quality Management The basic principles of quality assurance for the conduct of the fastest growing software development provides an important support. When software products have too many errors, developers patch it possible to spend the ti