1. According to Fowler’s definition this pattern is implemented by having all classes in a layer inherit from a superclass. But after some googling it appears all of the following are considered as implementations of a Layer Supertype pattern:
a – all classes in a layer inheriting from the same superclass
b – having only some ( thus not all ) of classes in a layer inheriting from a superclass
c – layer having superclasses S1 and S2, where classes A and B inherit from S1, while C inherits from S2
So which of above are considered as implementations of a Layer Supertype?
2. If a,b and c are all considered implementations of a Layer SuperType, then I fail to see how this pattern is any different from a regular class inheritance. In other words, couldn’t we then claim we’re using Layer Supertype any time some class inherits from another class?
thanks
3
As defined by Fowler, only a would be a Layer Supertype. However, people consider the others Layer Supertypes in that they are specific to a layer–all of the subtypes of the supertype must exist and be relavant to the same layer.
Consider, for example, the view layer in an MVC application. You might have the windows or pages all extend a single supertype, but also have helper classes or strategy classes that also live in the layer to support the view. The supertype is very much tied to the layer, in this case, even though it does not underlie everything. I don’t think it’s wrong to call this a layer superclass.
2