Search code examples
code-analysisimpact-analysis

How to quickly analyse the impact of a program change?


Lately I need to do an impact analysis on changing a DB column definition of a widely used table (like PRODUCT, USER, etc). I find it is a very time consuming, boring and difficult task. I would like to ask if there is any known methodology to do so?

The question also apply to changes on application, file system, search engine, etc. At first, I thought this kind of functional relationship should be pre-documented or some how keep tracked, but then I realize that everything can have changes, it would be impossible to do so.

I don't even know what should be tagged to this question, please help.

Sorry for my poor English.


Solution

  • Eventually this task cannot be automated or reduced to an algorithm, otherwise there would be a tool to preview refactored changes. The better you wrote code in the beginning, the easier the task.

    Let me explain how to reach the answer: isolation is the key. Mapping everything to object properties can help you automate your review.

    I can give you an example. If you can manage to map your specific case to the below, it will save your life.

    The OR/M change pattern

    Like Hibernate or Entity Framework...

    A change to a database column may be simply previewed by analysing what code uses a certain object's property. Since all DB columns are mapped to object properties, and assuming no code uses pure SQL, you are good to go for your estimations


    This is a very simple pattern for change management.

    In order to reduce a file system/network or data file issue to the above pattern you need other software patterns implemented. I mean, if you can reduce a complex scenario to a change in your objects' properties, you can leverage your IDE to detect the changes for you, including code that needs a slight modification to compile or needs to be rewritten at all.

    • If you want to manage a change in a remote service when you initially write your software, wrap that service in an interface. So you will only have to modify its implementation
    • If you want to manage a possible change in a data file format (e.g. length of field change in positional format, column reordering), write a service that maps that file to object (like using BeanIO parser)
    • If you want to manage a possible change in file system paths, design your application to use more runtime variables
    • If you want to manage a possible change in cryptography algorithms, wrap them in services (e.g. HashService, CryptoService, SignService)

    If you do the above, your manual requirements review will be easier. Because the overall task is manual, but can be aided with automated tools. You can try to change the name of a class's property and see its side effects in the compiler

    Worst case

    Obviously if you need to change the name, type and length of a specific column in a database in a software with plain SQL hardcoded and shattered in multiple places around the code, and worse many tables present similar column namings, plus without project documentation (did I write worst case, right?) of a total of 10000+ classes, you have no other way than manually exploring your project, using find tools but not relying on them.

    And if you don't have a test plan, which is the document from which you can hope to originate a software test suite, it will be time to make one.