The beginning is the most important part of the work - Plato
The beginning is the most important part of the work - Plato
The beginning is the most important part of the work - Plato
The beginning is the most important part of the work - Plato
Stephan van Hulst wrote:An example in the standard API: InputStream is a class, and if you want to make a custom InputStream, you have to extend InputStream in some way, preventing your class from extending other types. InputStream should probably have been an interface.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
j rab wrote:I guess I wanted to if there are certain situations where inheritance would be more efficient than composition and why.
Search for “write dumb code Brian Goetz”, and you find, would you believe, Brian Goetz telling you to write dumb code. Look at these two links: 1 2, which both tell you the same thing. Bear's clarity of code will translate into efficiency.Bear Bibeault wrote:. . . Efficient is not a factor. Clarity is the goal.
Campbell Ritchie wrote:Isn't this an even worse example?
Java™ Platform, Standard Edition 8 API Specification wrote:A more complete and consistent set of LIFO stack operations is provided by the Deque interface and its implementations, which should be used in preference to this class.
Yes, that is the real problem. I am sure it would be possible to retrofit Deque and Stack simply by creating this sort of interface:-I am leaving the country before somebody shoots me for using the convention of an I at the beginning . You can also have an advanced stack interface for us Forth users including methods like duplicate duplicate2 nip drop drop2 swap and rotate. [edt] Good idea to call your Deque stack.Stephan van Hulst wrote:. . we don't have a Stack interface, . . .
Bear Bibeault wrote:
j rab wrote:I guess I wanted to if there are certain situations where inheritance would be more efficient than composition and why.
Efficient is not a factor. Clarity is the goal.
Stephan van Hulst wrote:The first time I found out how much it sucks to have a widely useful class without an accompanying interface was when I tried hacking something together with Observable.
After a while I gave up and decided it was much easier to just write my own listener interfaces, and I've never used Observable/Observer since.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|