Design – How to handle assumptions while designing any system

designdesign-patternsobject-oriented-design

I have been going through various system design examples to understand how we approach any system design question.
Here is what I have understood till now.

  1. Know the system first and find out how it works.
  2. Think of all use case.
  3. Identify key components and their responsibilities.
  4. Connect all the components so that they can communicate to each other.
  5. Use all standard practices while integrating components and if possible use standard design patterns.

Sometimes we make assumptions about the system, so those assumptions should be used to remove one use case or to add a variation.

I will put this question in context of Parking Lot design.

If I assume that Parking Lot is not commercial, and it is free parking lot, then design of parking lot should handle free parking lot as one of use cases , and it should be generic. OR Simply design parking lot which will never work for Commercial parking lot.

Main idea is that if someone asks you to design a parking lot and that is free parking lot, then design should be generic or specific?

Best Answer

Personally, I'm a big fan of YAGNI - (you ain't gonna need it).

Designing the general solution is hard.

The general rule I've seen (but naturally can't find a link to when I want it) is

  1. Write the first block of code to solve the problem.
  2. When you see a second instance of the problem, copy the first code & make changes to suit.
  3. When you see a third instance of the problem, refactor to a general solution.

You might find the story about the Object Toaster useful reading. It's a cautionary tale about the dangers of over thinking a problem.

Related Topic