Object-Oriented Programming

Vertical Development

Michael L. Collard, Ph.D.

Department of Computer Science, The University of Akron

Workflow

  • When working on a project, you can work vertically or horizontally
  • On most projcts, you should work vertically

Terminology

Layer f g h
Function Call if (f()) if (g()) if (h())
Function Declaration bool f(); bool g(); bool h();
Function Definition bool f() {} bool g() {} bool h() {}

Vertical Workflow

  1. Write a function declaration for a single function in xml_parser.hpp
  2. Write the function definition for that function in xml_parser.cpp
  3. Replace the code in srcFacts.cpp to call this new function
  4. Commit to the repository

Vertical Commits

  • git commit -am "Extract function f() from srcFacts into xml_parser"
  • git commit -am "Extract function g() from srcFacts into xml_parser"
  • git commit -am "Extract function h()) from srcFacts into xml_parser"
  • Complete one function at a time
  • Can be in any order

Vertical Workflow Advantages

  • See results almost immediately. Results here are improvements to the design of srcFacts.cpp.
  • Learn as we go. As you start extracting functions, you will see as you are going along whether it will work.
  • Can report progress better. Each commit reflects an improvement in srcFacts that you can show.

Horizontal Workflow

  1. Write the function declarations for multiple functions in xml_parser.hpp
  2. Commit to the repository
  3. Write the function definitions for those functions in xml_parser.cpp
  4. Commit to the repository
  5. Replace the code in srcFacts.cpp to call these new functions
  6. Commit to the repository

Horizontal Commits

  • git commit -am "Write all function declarations in xml_parser"
  • git commit -am "Write all function definitions in xml_parser"
  • git commit -am "Replace code in srcFacts with call to xml_parser function"
  • Have to be done in order

Horizontal Workflow Disadvantages

  • There are no results (i.e., improvements in the file srcFacts.cpp) until we are all done.
  • Do not learn as we go. Often have to rewrite what we have done.
  • Can only report progress at the very end.

Summation

  • Work vertically
  • Get one thing done on srcFacts that shows improvement to srcFacts
  • Quit working horizontally