The Artima Developer Community
Sponsored Link

.NET Buzz Forum
On the factoring of interfaces

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
Udi Dahan

Posts: 882
Nickname: udidahan
Registered: Nov, 2003

Udi Dahan is The Software Simplist
On the factoring of interfaces Posted: Apr 11, 2005 6:32 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Udi Dahan.
Original Post: On the factoring of interfaces
Feed Title: Udi Dahan - The Software Simplist
Feed URL: http://feeds.feedburner.com/UdiDahan-TheSoftwareSimplist
Feed Description: I am a software simplist. I make this beast of architecting, analysing, designing, developing, testing, managing, deploying software systems simple. This blog is about how I do it.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Udi Dahan
Latest Posts From Udi Dahan - The Software Simplist

Advertisement
Chris Mackenzie's take on "Implementing an Interface in the UI, or the 7-layer system" is based on having an interface for each of our entities in the system. His example focuses on a Person entity, thus having an IPerson interface. Now, the issue of having UI elements implement these interfaces is interesting, but secondary. First, we have to take a look back at what separating an interface from an implementation entails. A "Person" is more than just their data - our IPerson interface should also contain methods for manipulating Person objects. I would even go so far as to say that we should avoid using the "set" part of properties - all manipulation should be entirely method based. I know that this is OO zealotry, but I've found that, more often than not, large blocks of code are written behind "set" properties. This can be easily taken too far. So, what I propose is to refactor our IPerson interface into 2: an IPersonInfo interface which contains the data-only aspect of a Person as property "get"s only, and an IPerson interface which inherits IPersonInfo and contains the behavioral aspects of a Person - the methods. What is the good for? Well, for those cases where we will want UI controls to implement our IPerson interface, it would seem odd to have such a control need to implement a "GiveTwoWeeksNotice" method. Also, since the IPersonInfo is, in essence, read-only data, we can safely pass it anywhere without worrying that the data in our object will be corrupted somehow. There is one thing to watch out for, though. The IPersonInfo is really a data transfer object, something of an anti-pattern within a given application boundary. We need to make sure our application doesn't regress into procedural manipulation of the data. I don't think there will be too much danger of that for developers used to separating interface from implementation. So, to end on a positive note, the IPersonInfo can also be effectively used at application boundaries - between client and server for instance. As well, when it comes to persistence, all we're really interested in is the data - no need to use an IPerson when an IPersonInfo will suffice; but one can consider persistence to databases (and the like) as a kind of application boundary too.

Read: On the factoring of interfaces

Topic: Generating Ad Revenue in the Age of Syndication: Corante.com and Munincipal Wi-Fi at the Crossroads Previous Topic   Next Topic Topic: Trying to tame our estimates

Sponsored Links



Google
  Web Artima.com   

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