www.apress.com

15/04/19

Lessons Learned: Always Baseline and Version-Control Your Software

by Ralph Lecessi

An important lesson I have learned is to always make sure any software you are developing is baselined and under version control. I have had to baseline and place existing apps under version control seven times so far in my career. Let’s look at an oversimplified example of what can happen when companies operate without baselined, version-controlled software. The Widget company has deployed thousands of copies of Widget_1.0.0 to customers. The source for Widget_1.0.0 resides on the hard drive of Programmer_1’s PC. The source (Java) is as follows:

          public class Widget {
               private int x;
               public Widget()
               {
                    x = 5;
               }
               public String toString()
               {
                    return x;
               }   
               public static void main(String[] args)
               {
                    Widget widget = new Widget();
                    System.out.println(widget); // Prints “5”
               }
          }   


The Widget company then decides to hire Programmer_2 who copies the Widget_1.0.0 source to his PC. Since neither Programmer_1 nor Programmer_2 has baselined or version-control the Widget application, they are both working off separate copies of the same app.

Now the Widget company gets orders for a new type of widget that prints “10”. This development is done by Programmer_1 and released as Widget_1.0.1. He overwrites his previous version of the source as follows:

          public class Widget {
               private int x;
               public Widget()
               {
                    x = 10;
               }
               public String toString()
               {
                    return x;
               }
               public static void main(String[] args)
               {
                    Widget widget = new Widget();
                     System.out.println(widget); // Prints “10”
               }
          }     


Programmer_1 then gets a better offer and leaves the company. His PC gets re-imaged. Now, customers of Widget_1.0.1 request that the tag “Widget = “ is added to the application.

Programmer_2 is now in big trouble. He does not have a copy of the source for the Widget_1.0.1 application and can’t figure out how to upgrade his copy to it. Unable to support thousands of customers in production, the Widget company goes out of business.

This could have been avoided if the application were baselined and version controlled as
follows:

  1. Programmer_1 baselines Widget_1.0.0 by collecting all the source into one central repository.
  2. Programmer_1 places the source from the repository under the MAIN branch of his version control software with label WIDGET_1.0.0.
  3. Programmer_2 is given access to the widget database in the version control software.
  4. Programmer_1 creates a WIDGET_UPGRADE branch in the widget database in the version control software.
  5. Programmer_1 makes the changes in the WIDGET_UPGRADE branch and labels the release WIDGET_1.0.1. 


Now, Programmer_2 can support both versions of the Widget application, and the company remains in business.


About the Author

Ralph Lecessi is a software engineer with over 30 years’ professional programming experience in the aerospace, telecommunications, and payment industries at companies including Lockheed Martin, Alcatel-Lucent, AT&T, and Northrop Grumman. He is currently lead embedded software developer at TranSendIT, Inc in Mount Laurel, New Jersey. Ralph is also the author of JAVATM - The Beginnings—a text on basic Java programming that includes many examples and diagrams. Ralph is an adjunct professor of programming at Middlesex County College, where he teaches basic and object-oriented programming in Java. He lives in South Brunswick, New Jersey, with his wife and two children.

This article was contributed by Ralph Lecessi, author of Functional Interfaces in Java.