How to add new features in a tightly coupled system?

How to add new features in a tightly coupled system?

How can you add new features to an existing application where the main entity's name has been hard-coded?

This depends on the type of system you are trying to improve. If such a system is tightly coupled, then the addition of new features can be cumbersome.

Hive Coworking Space
Photo by Michael Warf / Unsplash

An example case scenario

Let's imagine a simple yet relevant use case: In an online shopping site, any seller can sign up and sell his or her furniture(s). The display and payment are managed by the site while the seller physically stores and delivers his or her item(s).

The owner of the site now wants to enable the sellers to sell anything, not only furniture (as per more demand from sellers themselves). In the back-end, however, the entity furniture has been hard-coded instead of something more generic such as products.

Understand data

The first step is to understand the data - we can otherwise take bad decisions without enough information at hand. In this instance, I might want to use an additional property called type, but if I don't know the data or the model, I might override it if it already exists - and if does something else (regression bug).

Possible Solutions

There are at least two ways to add these features:

  1. The easier option is to add two other types: type (represents the type of product) and label, to display on the view e.g. Furniture, Copybooks etc... The type is then used to differentiate between the items. You just need to refer to the type on the VIEWS instead of the original hard-coded value.
  2. A better but more difficult option: is to create a new Model and Class known as Product Types, with properties such as id, name and description; and enter the types such as Furniture, Shoes, Copybooks etc... Then in the existing Furniture Class, a new property is added, called type which relates to the Product Type.

For a start, irrespective of the implemented change, the user visiting the site should not see any difference - even with the furniture. Otherwise, there will be regression issues with existing customers.

The best solution is to refactor the Furniture class completely to Product and add a Product Type class. This however, results in plenty of regression through the sites, particularly concerning features like the payment.