 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Quicoli Guest
|
Posted: Fri Dec 10, 2004 2:19 pm Post subject: ValueType Framework help please |
|
|
Hi all !
i have printed all posts i found here about ValueType Framework, to try
implementing it here. But i'm getting confused about registering the
metadata. Sometime Joanna exposed her code for us, but sometimes using
interfaces other no interfaces... i'm thankfull for her help !
I would like some code example, but if possible please, a little
complete code.
I know sometimes you maybe think "i got hard to develop this and now
are asking me for expose my code...."
I just need a real code to begin my "adventures" in the "valuetype
world" :)
thanks for helping me !!!!
--
Paulo R. Quicoli
---------------------
Analista Programador
Control-M Informática Ltda.
|
|
| Back to top |
|
 |
Joanna Carter (TeamB) Guest
|
Posted: Fri Dec 10, 2004 2:50 pm Post subject: Re: ValueType Framework help please |
|
|
"Quicoli" <paulo (AT) controlm (DOT) com.br> a écrit dans le message de news:
[email]41b9a1dd (AT) newsgroups (DOT) borland.com[/email]...
| Quote: | I just need a real code to begin my "adventures" in the "valuetype
world"
|
If you have read my examples of Value Types, then you have the best part of
the Value Type framework. You may want to add further Metadata to the base
ValueType class, but whether you use interfaces or classes is not relevant
to the implementation.
The whole purpose of the Value Type is to provide a better system of RTTI
than is already available in Delphi. To a certain extent some of these
features are not as relevant in the .NET framework as it is possible to
query any type just using reflection.
Once you decide how much extra metadata you need you can then set about
using the RTTI that the Value Type framework provides to build either/both
an OPF and/or a GUI framework.
The code for either of these frameworks is not a simple matter, but you can
look at the (incomplete) articles on my website. Full source code for such
things would be subject to copyright and also subject to fees :-)
Joanna
--
Joanna Carter (TeamB)
Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
|
|
| Back to top |
|
 |
Iman L Crawford Guest
|
Posted: Fri Dec 10, 2004 3:20 pm Post subject: Re: ValueType Framework help please |
|
|
Quicoli <paulo (AT) controlm (DOT) com.br> wrote in
news:41b9a1dd (AT) newsgroups (DOT) borland.com:
| Quote: | I would like some code example, but if possible please, a little
complete code.
|
I have some code that does things similar to ValueType. It's just me
playing around and not really ready for any production work. The code is
uncommented. It won't work with Delphi.NET (uses implements keyword). I've
been meaning to place it at CodeCentral. I'll see if I can get it in some
type of usuable form today.
--
Iman
|
|
| Back to top |
|
 |
Joanna Carter (TeamB) Guest
|
Posted: Fri Dec 10, 2004 4:00 pm Post subject: Re: ValueType Framework help please |
|
|
"Quicoli" <paulo (AT) controlm (DOT) com.br> a écrit dans le message de news:
[email]41b9c3f4 (AT) newsgroups (DOT) borland.com[/email]...
| Quote: | Question 1:
===========
I'm implementing a TStringMetadata.GetMetadata like this:
function TStringMetadata.GetMetadata: IMetadata;
begin
Result := (TStringMetadata.Create as IMetadata);
end;
|
Why would you ask a class that couold just as well implement IMetadata to
give you a reference via a method ? If TStringMetadata derives from
TMetadata and TMetadata implements IMetadata, then you can get your
IMetadata simply by asking the either the Value Type or the Type Register.
TValueType = class(...)
....
function GetMetadata: IMetadata; virtual; abstract;
end;
TStringValueType = class(TValueType, ...)
....
function GetMetadata: IMetadata; override;
end;
function TStringValueType.GetMetadata: IMetadata;
begin
Result := TStringMetadata.Create;
end;
| Quote: | But i'm thinking if i need to have reference (a private field) to
IMetadata in my TStringAttribute to avoid duplicated creation of
TStringMetadata when
using something like:
CurrentItem.GetMetadata.GetType
CurrentItem.GetMetadata.GetName
|
You could always create the metadata on first call and then maintain it
until the ValueType dies.
| Quote: | Question 2:
==========
Well, where should i create the TStringMetadata,
In my TStringAttribute.GetMetadata or at TypeRegister ?
|
Either one would work depending on your overall strategy.
Joanna
--
Joanna Carter (TeamB)
Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
|
|
| Back to top |
|
 |
Quicoli Guest
|
Posted: Fri Dec 10, 2004 4:44 pm Post subject: Re: ValueType Framework help please |
|
|
Joanna Carter,
Thank you for your help and attention. I understand your point of view,
and respect it.
So, i gonna look for your advices which are like a light in the night :)
Question 1:
===========
I'm implementing a TStringMetadata.GetMetadata like this:
function TStringMetadata.GetMetadata: IMetadata;
begin
Result := (TStringMetadata.Create as IMetadata);
end;
But i'm thinking if i need to have reference (a private field) to
IMetadata in my TStringAttribute to avoid duplicated creation of
TStringMetadata when
using something like:
CurrentItem.GetMetadata.GetType
CurrentItem.GetMetadata.GetName
Question 2:
==========
Well, where should i create the TStringMetadata,
In my TStringAttribute.GetMetadata or at TypeRegister ?
Again, thank you !
Joanna Carter (TeamB) wrote:
| Quote: |
--
Joanna Carter (TeamB)
Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
|
--
Paulo R. Quicoli
---------------------
Analista Programador
Control-M Informática Ltda.
|
|
| Back to top |
|
 |
Quicoli Guest
|
Posted: Fri Dec 10, 2004 5:01 pm Post subject: Re: ValueType Framework help please |
|
|
Iman L Crawford wrote:
| Quote: |
I have some code that does things similar to ValueType. It's just me
playing around and not really ready for any production work. The code is
uncommented. It won't work with Delphi.NET (uses implements keyword). I've
been meaning to place it at CodeCentral. I'll see if I can get it in some
type of usuable form today.
|
Iman,
thanks for openning your code ! I hope you code get my mind open to
understand more about Attribute framework. I will see your ideias an try
to get good concepts from your code...
really thanks !
--
Paulo R. Quicoli
---------------------
Analista Programador
Control-M Informática Ltda.
|
|
| Back to top |
|
 |
Iman L Crawford Guest
|
Posted: Fri Dec 10, 2004 10:53 pm Post subject: Re: ValueType Framework help please |
|
|
Quicoli <paulo (AT) controlm (DOT) com.br> wrote in
news:41b9c7b4 (AT) newsgroups (DOT) borland.com:
| Quote: | thanks for openning your code ! I hope you code get my mind open to
understand more about Attribute framework. I will see your ideias an
try to get good concepts from your code...
|
Done:
http://cc.borland.com/codecentral/ccWeb.exe/listing?id=22876
This is a proof of concept and a work in progress. If anyone has
questions, comments or critiques post here.
--
Iman
|
|
| Back to top |
|
 |
Joanna Carter (TeamB) Guest
|
Posted: Fri Dec 10, 2004 11:22 pm Post subject: Re: ValueType Framework help please |
|
|
"Iman L Crawford" <ilcrawford.at.hotmail.dot.com> a écrit dans le message de
news: Xns95BBABDF872F8ilcrwfrd (AT) 207 (DOT) 105.83.66...
| Quote: | This is a proof of concept and a work in progress. If anyone has
questions, comments or critiques post here.
|
I would be surprised if this compiles :-)
You have forward declarations of interface types that are not completely
defined before the classes that use them; this causes problems that the
methods mentioned in the full declaration, aren't visible in classes
declared before that, even with the forward declaration.
When you are going to the trouble to create your own Value Type framework,
why would you bother using Delphi RTTI as well ?
Joanna
--
Joanna Carter (TeamB)
Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
|
|
| Back to top |
|
 |
Iman L Crawford Guest
|
Posted: Sat Dec 11, 2004 4:43 am Post subject: Re: ValueType Framework help please |
|
|
"Joanna Carter (TeamB)" <joanna (AT) nospam (DOT) co.uk> wrote in news:41ba2fd1
@newsgroups.borland.com:
| Quote: | I would be surprised if this compiles
|
Be suprised. If I read the help correctly, forward declared
interfaces are no different that forward declared classes. It works
without in AV's so far.
| Quote: | When you are going to the trouble to create your own Value Type
framework, why would you bother using Delphi RTTI as well ?
|
I didn't want to have to register my properties and keep them in sync
when the class changes. I would have felt compelled to write a code
generator, blech. Adding a new property involves placing a property
declaration in the published section of your class. I only suport six
property types right now, but it's simple to expand IProperty to any type
supported by RTTI. Interface types were next on my list.
I've concentrated on the IProperties the most. It seems to work as
expected, with few caveats. I've been pleasantly suprised by it.
The IObjectList is less developed. I can't make up my mind whether to
use a Cursor or an Iterator pattern. I have a small bug in its current
implementation of IProperties. An interator would fix that and simplify
some subject/observer stuff.
The Subject/Obsever stuff is pretty rudimentary. I'm still grappling
with it and haven't messed with it in a while. It got tedious writing
code to communicate with visual components. I just fixed up a few
showstopper bugs so that Paulo could see some code.
If you get a chance to look at it any more, comments would be welcome.
I'm still not 100% comfortable with interfaces. (ex: how/when/why to use
const interface parameters). Don't worry about bruising my ego, this is
all a learning exercise for me.
My goal has been to include some type of persistent machanism, make it
thread safe and build an object server. I got distracted being a soccer
coach the last couple of months and I'm helping a friend figure out
TCP/IP communications beyond request/response. We want to send out
notifications to all the clients when the server processes an
update/delete/addition, but that's another thread.
--
Iman
|
|
| Back to top |
|
 |
Joanna Carter (TeamB) Guest
|
Posted: Sat Dec 11, 2004 1:36 pm Post subject: Re: ValueType Framework help please |
|
|
"Iman L Crawford" <ilcrawford.at.hotmail.com> a écrit dans le message de
news: Xns95BBE6A9A4B6Eilcrwfrd (AT) 207 (DOT) 105.83.66...
| Quote: | Be suprised. If I read the help correctly, forward declared
interfaces are no different that forward declared classes. It works
without in AV's so far.
|
IMO implementing an interface before its GUID has been declared stops you
from casting the an instance of the implementing class to the correct
interface.
| Quote: | I didn't want to have to register my properties and keep them in sync
when the class changes. I would have felt compelled to write a code
generator, blech. Adding a new property involves placing a property
declaration in the published section of your class. I only suport six
property types right now, but it's simple to expand IProperty to any type
supported by RTTI. Interface types were next on my list.
|
The only reason I find for registering Value Types is to cater for OPF
mapping or possibly to support knowing which class support which interface.
What about having the ability to stream private fields rather than having to
access the published properties ? Especially if the property has a different
representation to the field .
e.g. you might want to store a Date of Birth value but only ever show the
Age .
| Quote: | I've concentrated on the IProperties the most. It seems to work as
expected, with few caveats. I've been pleasantly suprised by it.
|
I rather like the idea of IProperties; I use a GetValueTypes method on an
ObjectValueType to give me an IValueTypeList.
| Quote: | The IObjectList is less developed. I can't make up my mind whether to
use a Cursor or an Iterator pattern. I have a small bug in its current
implementation of IProperties. An interator would fix that and simplify
some subject/observer stuff.
|
To simplify coding, I also use templates in Delphi to allow me to declare a
list and an iterator for each type in only half a dozen lines of code.
| Quote: | The Subject/Obsever stuff is pretty rudimentary. I'm still grappling
with it and haven't messed with it in a while. It got tedious writing
code to communicate with visual components. I just fixed up a few
showstopper bugs so that Paulo could see some code.
|
Extending the Observer pattern into the MVP framework really simplified the
coding required to get controls hooked up to the VTF (Value Type Framework)
| Quote: | If you get a chance to look at it any more, comments would be welcome.
I'm still not 100% comfortable with interfaces. (ex: how/when/why to use
const interface parameters). Don't worry about bruising my ego, this is
all a learning exercise for me.
|
I am in the middle of evaluating the changes required to port the frameworks
to .NET where the interface paradigm is different and we also have garbage
collection which tends to obviate the need for some interfaces. Added to
which, mixing interfaces and objects is not the problem it is in Delphi for
Win32. <Yaaayyy!!>
| Quote: | My goal has been to include some type of persistent machanism, make it
thread safe and build an object server. I got distracted being a soccer
coach the last couple of months and I'm helping a friend figure out
TCP/IP communications beyond request/response. We want to send out
notifications to all the clients when the server processes an
update/delete/addition, but that's another thread.
|
That really is approaching perfection in OPFs )
Joanna
--
Joanna Carter (TeamB)
Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
|
|
| Back to top |
|
 |
Charles McAllister Guest
|
Posted: Sat Dec 11, 2004 3:26 pm Post subject: Re: ValueType Framework help please |
|
|
Iman L Crawford wrote:
| Quote: |
Be suprised. If I read the help correctly, forward declared
interfaces are no different that forward declared classes. It works
without in AV's so far.
you should be aware of this: |
http://qc.borland.com/wc/wc.exe/details?ReportID=1531
and please vote on it if it becomes a problem for you. Thanks!
|
|
| Back to top |
|
 |
Charles McAllister Guest
|
Posted: Sat Dec 11, 2004 3:28 pm Post subject: Re: ValueType Framework help please |
|
|
Charles McAllister wrote:
|
|
| Back to top |
|
 |
Marcos Guest
|
Posted: Sat Dec 11, 2004 3:45 pm Post subject: Re: ValueType Framework help please |
|
|
Which the importance of "GetMetadata: IMetadata" method inside of
TValueType?
Could not I simply use the information contained in the inherited
interfaces of IValueType (IIntegerValueType, IStringValueType,...) to
get all that I want about the attribute?
For me, Metadata is information on a class and don't remain an instance
of this class.
Does anybody have an example of how Metadata of an attribute is used
inside of OPF or of MVP?
Thank you
|
|
| Back to top |
|
 |
Marcos Guest
|
Posted: Sat Dec 11, 2004 4:51 pm Post subject: Re: ValueType Framework help please |
|
|
Bob Dawson wrote:
| Quote: | Classic metadata for a TStringType, for example, might include
Isrequired, min and max length, case sensitivity, case restriction, input mask
should a zero-length string be submitted to datastore as is, or as null
|
It is this that I still didn't understand. If I have in a class:
TPerson
Name: string;
Address: string;
Both registered like TStringType in a TypeRegister (like Joanna do it).
I should have a field metadata (FMetadata: IMetadata) for each attribute
(Name and Address) or should I have in both attributes a reference to a
single object TStringMetadata?
If the affirmative answer is the first one, then I believe that max,
length, IsRequired,... they could be put directly in the interface
TStringType or your base class (TValueType) and not in an attribute
Metadata inside of TStringType. Can anybody comment on?
If the affirmative answer is the second one, then max, length,
IsRequired could not be part of the metadata because Name.IsRequired
attribute can be direferent of Address.IsRequired. Can anybody comment on?
Thank you, sry my bad english
|
|
| Back to top |
|
 |
Marcos Guest
|
Posted: Sat Dec 11, 2004 5:16 pm Post subject: Re: ValueType Framework help please |
|
|
Bob Dawson wrote:
| Quote: | Classic metadata for a TStringType, for example, might include
Isrequired, min and max length, case sensitivity, case restriction,
input mask
should a zero-length string be submitted to datastore as is, or as null
|
It is this that I still didn't understand. If I have in a class:
TPerson
Name: string;
Address: string;
Both registered like TStringType in a TypeRegister (like Joanna do it).
I should have a field metadata (FMetadata: IMetadata) for each attribute
(Name and Address) or should I have in both attributes a reference to a
single object TStringMetadata?
If the affirmative answer is the first one, then I believe that max,
length, IsRequired,... they could be put directly in the interface
TStringType or your base class (TValueType) and not in an attribute
Metadata inside of TStringType. Can anybody comment on?
If the affirmative answer is the second one, then max, length,
IsRequired could not be part of the metadata because Name.IsRequired
attribute can be direferent of Address.IsRequired. Can anybody comment on?
Thank you, sry my bad english
|
|
| Back to top |
|
 |
|
|
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
|
|