Re: Method chaining with generics
- From: Thomas Weidenfeller <nobody@xxxxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 09:53:50 +0200
iksrazal@xxxxxxxxxxxx wrote:
Allow my code to explain:
Bsc bsc = BscHelper.createBsc(); SiteType siteType = BscHelper.createSiteType(id,name); bsc.getSite().add(siteType);
getSite() returns List. It was written without generics in mind.
The real error is an architectural design bug. You have a class Bsc which contains a list of sites, and you hand out that list to the public for manipulation. This seriously breaks encapsulation. Class Bsc should instead get a method addSite(), and do all the list handling internally.
/Thomas
-- The comp.lang.java.gui FAQ: ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/ .
- Follow-Ups:
- Re: Method chaining with generics
- From: Thomas Hawtin
- Re: Method chaining with generics
- From: iksrazal
- Re: Method chaining with generics
- References:
- Method chaining with generics
- From: iksrazal
- Method chaining with generics
- Prev by Date: Re: how to detect a hard link in Java?
- Next by Date: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- Previous by thread: Re: Method chaining with generics
- Next by thread: Re: Method chaining with generics
- Index(es):