Problem Statement
Describe a scenario where you discovered a module with low cohesion and high coupling. How did you refactor it to improve design quality? Outline steps and outcomes.
Explanation
In such a scenario you might find a module that handles UI tasks, database access and business logic all in one (low cohesion) and depends on many other modules (high coupling). /n/n To refactor you would: 1) extract the business logic into a separate service or module; 2) move database access into a repository class/module; 3) isolate UI code into its own module; 4) introduce interfaces or abstractions to reduce direct dependency between modules; 5) ensure each new module has a single clear responsibility and minimal dependencies. /n/n As a result you achieve higher cohesion in each module and lower coupling between modules. This reduces complexity, improves testability, and makes future enhancements safer. Demonstrating such experience or reasoning in an interview shows you grasp practical design quality.
Practice Sets
This question appears in the following practice sets: