Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which comes first - The Interface or the Class [closed]

During the process of designing new features in your software, which process is the best practice

  1. Design the Interface that the Class will implement.
  2. Writing the Class and extracting the Interface later.

If going the route of number 2, when do you decide that an Interface is needed?

like image 634
David Williams Avatar asked Mar 13 '09 17:03

David Williams


1 Answers

Which comes first? The need for a feature or the implementation of a feature?

In my own workflow, the interface comes first spontaneously. If some part of my project needs a new feature, it is built around how I want to use it, i.e., its interface. Then the implementation follows.

This way, the implementation contains only what is actually needed and no time is wasted in overengineering a shiny useless piece of code.

like image 161
mouviciel Avatar answered Sep 19 '22 22:09

mouviciel