2

So I need to create a customer system and there aren't multiple types of customers.

Should I still create an interface or abstract class to inherit from?

2
  • This doesn't sound like a language-independent question. Certainly how you implement something will depend on the features of the language available. What are you using?
    – Gareth
    Commented Mar 25, 2011 at 20:10
  • It depends on how big your project is, and whether you will need to change it (is your specification document completely written and signed by all stakeholders?). If you can write your project simply in a few days, just do it. If this is a 5-month project, then you should probably take care with the architecture.
    – Justin
    Commented Mar 25, 2011 at 20:13

1 Answer 1

8

No. You should only abstract what is needed to be abstracted. You can always come back later and refactor your code if there are new types of customer to be added.

Always keep your design as simple as needed to get the job done.

Don't add abstractions because they look good, you might never need them. Add abstractions because you need them.

3
  • What about for unit testing and coding to an interface not an implementation
    – user660734
    Commented Mar 25, 2011 at 20:13
  • +1. See also the YAGNI (You Ain't Gonna Need It and KISS (Keep It Simple Stupid) principles. Commented Mar 25, 2011 at 20:14
  • With the corollary of "do abstract things when the need arises." The worst code starts simple, and with the best intentions... and then suddenly a new situation comes up, and it's easier to add a condition then it is to refactor. And then it goes downhill from there, until you find yourself with unworkable code and a deadline a year later :) Commented Mar 25, 2011 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.