Properties on Properties

Discussions about design and architecture principles, including native JADE systems and JADE interoperating with other technologies
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Properties on Properties

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:32 am

by Brian Mills >> Tue, 5 Oct 2004 23:55:22 GMT

Is there any way i can add properties to properties?

Ie. I have a student class, with id, name and email address on it. I want to add a property on them to define weather they are extractable by a particular extract. In time I would also like to be able to add other properties that define other usefull features of the system. Like mandetory fields. This is basically metat data. The reason I would like to do this is we are building a comon framework that will actually operate different systems with slightly different requirements. It would be very handy to allow the interface to customise based on meta data rather than having to maintain different interfaces for each version of the product.

Anyones thoughts or experiences with doing such things would be most usefull.

Brian.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Properties on Properties

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:32 am

by rob >> Wed, 6 Oct 2004 2:03:03 GMT

Brian,
I've used the text field for storing information, most recently for data dictionary definitions. It's handy because it's easy to maintain both manually and programmatically. If you adopt an xml format, you can store multiple different types of data.However, it's not type-safe, and you are vulnerable to spelling errors. Define a generic method on the Property class (or Schema Entity if this is what you need) that examines the xml for a particular tag & value, e.g.

Property::isMandatory() :Boolean;begin

return getXmlValue(self.text, MandatoryTag) = 'true';
end

Cheers,
Rob

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Properties on Properties

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:32 am

by allistar >> Wed, 6 Oct 2004 9:15:42 GMT

Hi Brian,
As Rob mentioned you could use an existing property such as "text". You could also define a method on the Object class called "getMetaInformation" which could have a signature like this:

getMetaInformation(propertyName: String; meta: MetaInformation input);

And if you want to get the MetaInformation for the address property on the customer class you could call it like this:

create meta transient;
customer.getMetaInformation(Customer::address, meta);

The Customer::getMetaInformation method could look like this:

vars
begin

if (property = Customer::address) then
meta.setIsExtractable(true);
meta.setIsMandatory(false)
endif;
end;

The "MetaInformation" class could have properties like:
isMandatory: Boolean;
isExportable: Boolean;

and whatever other distinguishing features you want to be able to associate with properties. You could extend this to do lots of things, such as more tightly binding database properties to fields on forms so the framework populates a form with the properties on an object instead of the developer having to code this for each form.

It is nice in JADE6 that you can access metadata like this: "Customer::address", so you don't have to worry about misspelling anything.

The disadvantage of this approach is that you need an instance of the class you want to get metadata for, although you could always create a transient instance to satisfy that.

I have used a similar approach before to write generic data export/import routines on subsets of a JADE database.

Regards,
Allistar.
--
------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Properties on Properties

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:32 am

by Brian Mills >> Thu, 7 Oct 2004 2:00:15 GMT

The only problem with that approach is that it doesnt solve the problem of if you want different defintions for different instances of the same system/codeline.

Does Jade 6 have meta data options in built?

Brian.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Properties on Properties

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:32 am

by allistar >> Thu, 7 Oct 2004 7:26:04 GMT

Since the "getMetaInformation" requires an instance of the class to work, then the retured results could be conditional based on a property of the object.

JADE6 allows you to access meta information more easily by using the ":;" syntax. As far as I am aware it doesn't give you any way of storing additional data on meta data such as properties other than the "text".

Regards,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------


Return to “Design and Architecture”

Who is online

Users browsing this forum: No registered users and 16 guests