We have two systems for registering students/program participants in courses, one for “for credit” offerings, and the other for non-credit. Years ago these were the same system that contained A Lot of conditional code to handle the business rules specific to each (lots of government regulations for credit stuff that just doesn’t apply to non-credit, and lots of other business requirements specific to each type).
After a while, the system was forked and over time we’d removed a lot of the code on each “side” that was specific to the other side. This made each app much easier to reason about as we were developing, but it greatly increased the duplication of code and maintenance where we’re now making the same (or nearly the same) fix in both apps.
We’d love to modularize and pull out common code into modules. Right now we are on CB 3.6 and are doing some dev testing to migrate to 4.0. When we get to that point we’re strongly considering seeing if we can start pulling common code out into modules. However, I wanted to get advice on how to approach it, specifically when we see code like this (see below; appologies for the image size). The squiggly lines are lines of code that are identical between the systems. We have many such cases where the app-specific code is right in the middle of large swaths of code that is identical to both sides.
Is there a way to pull out the common code and avoid:
- going back to essentially the same “merged” system that’s difficult to keep business rules separate and straight
- breaking up any function that has domain specific logic into numerous functions that are strung together
- other equally difficult to maintain formulations