The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Golden Core Hammer

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Golden Core Hammer Posted: Jan 27, 2004 8:44 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Golden Core Hammer
Feed Title: David Buck - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/buck-rss.xml
Feed Description: Smalltalk can do that
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From David Buck - Blog

Advertisement
I've been reading lots of articles on what the .NET community calls "strongly typed collections". These are collections that implement their own methods for Add, Remove, Contains, and so forth but take a parameter of a specific class instead of just Object. The argument is that these strongly typed collections don't have "dangerous downcasts" when removing elements from the collection and prevent you from writing inappropriate objects into the collection. A particularly good article describing this is from OnDotNet.

An example of such a collection is provided on the Human Compiler blog. At the end, the author states:

This may look like a lot of code, but it's really not. It took me all of 15 minutes to setup from scratch. Now you can use it just like any other Strongly Typed Collection.

My question is - what's the big deal? Collections are almost always encapsulated inside other more interesting objects. The Law of Demeter states that you shouldn't extract a collection from inside an object and proceed to send messages to it. It breaks encapsulation. Instead, you should use Encapsulated Collections. There's no sense having all this code for strongly typed collections when the collection is encapsulated already. Encapsulated Collections involves similar code to strongly typed collections but doesn't encourage people to break encapsulation.

This seems to be a very prevalent pattern in the .NET world. I don't know if I'm the only one (besides Martin Fowler), but I see it as a golden core hammer: You can't see, but it's beautiful on the inside. For anyone to see the gold, you have to break the hammer.

Read: Golden Core Hammer

Topic: Blogging for one year Previous Topic   Next Topic Topic: Smalltalk Solutions 2004 - Call for Participation

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use