Re: Method chaining with generics
- From: Thomas Hawtin <usenet@xxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 13:16:14 +0100
Thomas Weidenfeller wrote:
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.
Not necessarily. If assuming that the implementation of the list returned keeps bsc in sync, it's fine. List doesn't have to imply ArrayList/LinkedList.
Law of Demeter, perhaps.
Tom Hawtin -- Unemployed English Java programmer http://jroller.com/page/tackline/ .
- References:
- Method chaining with generics
- From: iksrazal
- Re: Method chaining with generics
- From: Thomas Weidenfeller
- Method chaining with generics
- Prev by Date: Re: problem downloading excel file
- Next by Date: Re: To increase speed on manipulating big arrays in Java with minimal bounds checking, ...
- Previous by thread: Re: Method chaining with generics
- Next by thread: [strus] LOCALE
- Index(es):