4 ms·
Sometimes (hard to say without a specific example) the superclass can be represented as its own class and included in each subclass as composition. This has sev
by chillacy 10y ago
Sometimes (hard to say without a specific example) the superclass can be represented as its own class and included in each subclass as composition. This has several advantages, including less code per class and therefore smaller interface surface area, more explicit interface / information hiding, and easier testability.
- marcosdumay 10y agoThe most obvious examples would be the widget classes all GUI frameworks export. Java has some interesting classes for networking, like its AbstractHTTPServer, and Applet. Most OO languages have some variant of Thread or Runnable that is built this way too.