Using system.collection(.*) is a code smell(morten.lyhr.dk)

submitted by LyhrLyhr(315) 4 years, 6 months ago

Basically multiplicity is not a concern of the client, so applying SOC we should remove the multiplicity from the client. How is that possible? Composite design pattern to the rescue.

3 comments |category: |Views: 8

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by yesthatmcgurkyesthatmcgurk(4063) 4 years, 6 months ago 0

Impressive. If only I knew what the hell he was talking about. This is one of those instances where a "foo" example isn't appropriate and should be replaced with one based on real life.

Reply

posted by armenczarmencz(220) 4 years, 6 months ago 0

I only disagree that collections are code smell. Generics are simplifying signature of collection but not Composite Pattern. Composite Design Pattern helps to build tree structure collection. For example whenever you need to manipulate with nested objects such as Family Tree, XmlNodes, WebControls, etc Composite Design Pattern is the best approach for it.

“The Rule of Thumb:
Usage of composite pattern is usually appropriate whenever there are hierarchical tree structures where all the tree nods are of the same type. “
Design patterns in real world use case scenarios, posted by Nikola Malovic - http://blog.vuscode.com/malovicn/archive/2007/08/16/design-patterns-in-real-world-use-case-scenarios-composite-part-2.aspx

Message for yesthatmcgurk, try to look at the Nikola Malovic blog post I mentioned above. Composite pattern is very simple, useful and unique.

Reply

posted by LyhrLyhr(315) 4 years, 6 months ago 0

Point taken with the FooBar, next time there will be no FooBar ;-)

---

Why should the Composite pattern only deal with Tree structures? (The Composite Design pattern allows a client object to treat both single components and collections of components identically)

And anyways the composite class could easyly be rewirtten, to accept 2 instances of IFooBar. Then we could greate a tree structure by creating multiple coposites.
But whats the point? the list composite solved the problem?

Reply

information Login or create an account to comment on this story