Think of an interface as a contract to define semantics or concepts. This is a general approach and not a very specific language. In the context of OO, if you work in the same inheritance model, there is a great example for preferring interfaces over classes to define your object model, as this single superclass path is quite valuable, and you want to keep it for something more “significant” than the definition properties that are exposed to the object or methods.
So that the semantics of IContainer (contract) is a pretty bad reason to make an interface from your folder; it is better to have your own folder (if it runs any non-trivial logic) "implements" (probably already existing) the IContainer or ICollection interface in your language frameworks.
As always, the best choice is quite dependent on the specific problem. In the case of your recipes, which are also folders (?!), You probably think about the parent-child or composition, attitude - semantics, which can (and should) be expressed using interfaces if you have other elements in your system "work" with things that consist of this semantics.
There is a bit of overhead (programming) with interfaces, and if you find that when you are done, nothing more than a set of Woof and IWoof classes and interfaces, then you will find out that you probably need to express your problem in terms of interfaces - simple classes would be enough.
As a rule, for any I, you should have at least a few specific classes (with more meaningful names other than IImpl, or).
Hope this helps.
alphazero
source share