Re: [TFUI] Understanding the Representation Layer
"Phlip" <[email protected]> Fri, 26 Aug 2005 10:41:13 -0700
| Newsgroups | gmane.comp.programming.test-first-user-interfaces |
|---|---|
| Message-ID | <01e901c5aa65$607d7260$2701a8c0@Marley> |
Paul: This is a question about my use of the term "Representation Layer". The post treats the term as canon and works within it. However, the poster then extrapolates a little too far, and the TFUI mailing list participants helped him out. My book's contents show how to use Emergent Design to avoid the mistake. (Many other posts in various disciplines call this "humble dialog box style", after Mike Feather's influential paper.) ----- Original Message ----- From: "xelcury" <[email protected]> To: <[email protected]> Sent: Thursday, February 17, 2005 9:35 PM Subject: [TFUI] Understanding the Representation Layer > > > I'm trying to understand the concept of a "Representation Layer" > better. In the process of asking my question, I'm going to expose how > much I don't know about a large assortment of things. Please bear with > me. So, here we go. > > Suppose we're building a database application for a veterinarian > office. The database tracks pets (and their owners and appointments > and whatnot). The project might be split into layers: > > 1) We have the data access layer. This is comprised of classes that > retrieve and save data to a database, say a Microsoft Access database. > > 2) Then we have the business object layer. This is comprised of > classes that give us an easy, object-oriented way of dealing with data > from the database. Here is one of our classes: > > Pet > --- > Properties: Name, Id, Species, HairColor, BirthDate, etc. > Methods: Save, LoadFromID > > The business object layer can do data validation. For example, say > HairColor is never allowed to be set to "orange" if the Species is set > to "ferret". The Pet object can throw an exception if you try to set > HairColor to "orange" if the Species was already set to "ferret". The > gui is expected to deal with that exception in an intelligent way. > > 3) Next we have our gui -- the forms that the users see. Here is one > of these classes: > > PetForm > ------- > Controls on the form: textboxPetName, textboxId, comboboxSpecies, > comboboxHairColor, datepickerBirthDate, etc. > > The "non-humble" way of doing things is to somehow bind the controls > in PetForm to the related properties of a Pet object. So in the > constructor for PetForm, we might have... > > Pet currentPet = New Pet(); > Bind(textboxPetName, currentPet.Name); > Bind(textboxId, currentPet.Id); > Bind(comboboxSpecies, currentPet.Species); > Bind(comboboxHairColor, currentPet.HairColor); > currentPet.LoadFromID(petID); > > 4) So, we come to the "representation layer". > > I understand that it is meant to fall between the gui and the business > objects. We add a new class: > > PetFormRepresentation > ---------------------- > Properties: TextBoxRepresentativePetName, > ComboBoxRepresentativeSpecies, etc > > A TextBoxRepresentative is an object that represents a TextBox, except > it never draws anything on the screen. It has a "Text" property just > like a TextBox, and all the same events. > > Somehow TextBoxRepresentativePetName in PetFormRepresentation gets > bound to textboxPetName in PetForm. And somehow PetFormRepresentation > is in turn bound to a Pet object. > > How far off is that? > > -Patrick > > > > > > > To unsubscribe, email: > TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org > > Yahoo! Groups Links > > > > > > > ------------------------ Yahoo! Groups Sponsor --------------------~--> Fair play? Video games influencing politics. Click and talk back! http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/nhFolB/TM --------------------------------------------------------------------~-> To unsubscribe, email: TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/TestFirstUserInterfaces/ <*> To unsubscribe from this group, send an email to: TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/