tag:blogger.com,1999:blog-5638372.post110078327992792719..comments2023-10-10T05:22:56.347-05:00Comments on binkley's BLOG: Why Java needs delegationBrian Oxleyhttp://www.blogger.com/profile/06617364377560752378noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-5638372.post-1101452843575362782004-11-26T01:07:00.000-06:002004-11-26T01:07:00.000-06:00What I don't like is the static implementation of ...What I don't like is the static implementation of interfaces by the Person. This is inflexible and ultimately unmanagable when you have lots of interfaces to implement. You're better off doing it the otherway around I.e like I said, have a role class and put specific behaviour / attributes in that.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5638372.post-1101411380843166952004-11-25T13:36:00.000-06:002004-11-25T13:36:00.000-06:00Distiller -- which part of the design do you disli...Distiller -- which part of the design do you dislike? (Yes, the examples range widely, so I'm not sure which you are spcificatlly pointing out.) I'm wanting a cleaner IoC/delegation solution, one blessed by the language syntax. (I'd like the same cleanness for properties, but I'm unsure how to get it without new keywords.)<br /><br />The point about using policy classes is great. It's one of my favorite techniques. Look at the Loki smart pointer classes for an excellent example in C++ of how much flexibility and power the idiom lends.Brian Oxleyhttps://www.blogger.com/profile/06617364377560752378noreply@blogger.comtag:blogger.com,1999:blog-5638372.post-1101392551795780752004-11-25T08:22:00.000-06:002004-11-25T08:22:00.000-06:00I know it's just an example to prove your point bu...I know it's just an example to prove your point but I think this is pretty bad design. <br /><br />I.e. If you look at Peter Coad's work on the Domain Neutral Component, it is much more flexible to create specialised Role classes for things like Commuter & Dad. This has the advantage of being able to add more roles later on without the knowledge of the Person or Organisation etc. <br /><br />E.g. (with generics because it is clearer what my intent is)<br /><br />class Party {<br /><br />}<br /><br />class Person extends Party {<br /> public <T extends PartyRole> getRole(Class<T extends PartyRole<Person>>);<br />}<br /><br />class PartyRole<P extends Party> {<br /><br /> public P getParty(){ ... }<br /><br />}<br /><br />class Commuter extends PartyRole<Person> {<br />public void walkToWork();<br />public void driveToWork();<br />public void flyToWork();<br />}<br />etc. <br /><br />Similarly, you could map Dad this way.<br /><br />This also lends well to an O-R mapping situation.<br /><br />-- DistillerAnonymousnoreply@blogger.com