BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Working with 'value' objects? (databound help needed)

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design
View previous topic :: View next topic  
Author Message
Shawn Oster
Guest





PostPosted: Mon Feb 02, 2004 12:23 am    Post subject: Working with 'value' objects? (databound help needed) Reply with quote



All,

In my current model I'm attempting to come up with a way to represent
different (data-bound) value sources for the fields of my class. For
example in a TMap various TMappedItems have a Latitude and a Longitude to
identify their position. So we have..

TMappedItem = class
Latitude: integer;
Longitude: integer;
end;

Now there are Buildings and there are Cars. A Buildings Latitude and
Longitude will never change (we hope *grin*) and hence only have two
values. On the other hand, most of the Cars will be moving (except those on
cement blocks), and so their Latitude and Longitude values will be changing
constantly.

I have a rendering routine that only knows about TMappedItems and draws an
item based on some other attributes (basic dimensional data) and places it
at the correct Latitude and Longitude on a grid.

I need the Cars position information to be 'data-bound' as it were to my
information source (it's GPS data) while the Building is static. The
rendering engine shouldn't need to know which objects are data-bound and
which aren't.

My first attempt around the issue is to make all the properties a generic
TPropertyValue class:

TPropertyValue
public
property AsString: string read GetAsString;
property AsInteger: integer read GetAsInteger;
property AsBoolean: boolean read GetAsBoolean;
end;

Then to create two descendant classes, a TStaticPropertyValue to hold simple
static information that adds write methods to the above class. The other is
TDataBoundPropertyValue:

TDataBoundPropertyValue = class(TPropertyValue)
public
property DataLink: TDataLink; // links between my GPS db and
function GetAsString(): string; override; // overridden to ask DataLink
for a value
end;

First, does this seem like a workable model? I know most consider anything
databound to be evil but I can't think of another way to transparently (at
least for the render engine) mix static with data-bound values.

Secondly, if I go down this road I have issues with object creation. If I
want to transition a propertyvalue from TStaticPropertyValue to
TDataBoundPropertyValue then who is responsible for freeing the old
TPropertyValue, the TStaticPropertyValue?

Any advice or insights greatly appreciated!

Thanks,
Shawn



Back to top
Bryan Crotaz
Guest





PostPosted: Mon Feb 02, 2004 11:24 am    Post subject: Re: Working with 'value' objects? (databound help needed) Reply with quote



1. You could possibly have two different class heirachies, both of which
implement ILocation.

2. Have a simple data holding class TMappedItem:

TMappedItem = class
Latitude: integer; // shurely, single?
Longitude: integer; // shurely, single?
ID: Integer;
LastModified: TDatetime;
end;

Then have a data aware broker which pushes values into *some* of the mapped
items. Or rather, it pushes values into all of them at startup, but only
updates moving objects.

Now you can have several map views. In each view, log the time you last
drew anything. Depending on your layering techniques, it's possible to only
draw things that have moved since you last drew (using LastModified). You
can also have multiple views (for example a wide view and a zoomed view).

Bryan


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.