ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  A Generic MVC Model in Java
Subject:   Good demonstration poor example
Date:   2004-07-19 08:42:01
From:   mbrowncpwr
The major advantage of generics is the type safety provided by the collections classes. What you demonstrated for MVC can be done more generically and with less coupling using normal inheritance and interfaces.


In the publish-subscribe (or Observer pattern), the only thing the Observable object needs to know is that the Observer implements the
update(Observable)
method. It shouldn't care if the Observer is a WidgetObserver or a WicketObserver. You actually hamper extension by placing those restrictions because now instead of iterating through a list of Observables and registering as an Observer, my Observer has to know what kind of Observable he is registering with before hand. This will probably require reflection which totally defeats both goals of inheritance and generics.


1 to 1 of 1
1 to 1 of 1