Sub-typing and user-defined types

The use of specific JADE features and proposals for new feature suggestions
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Sub-typing and user-defined types

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:33 am

by Craig Shearer >> Fri, 4 Feb 2000 8:21:42 GMT

Two major deficiencies that I have encountered in JADE are:

1. The inability to create new sub-types of JADE primitive types.
2. The inability to create new types altogether.

1. As an example, it would be great to be able to sub-type Decimal into, for example, a UnitPrice type, which was defined as Decimal[12,2]

When developing the Point of Sale system for Gilmours, we had many places where prices were stored as attributes on classes. Each time, we'd have to define a Decimal[12,2]. It would have been much nicer, and much more maintainable to be able to simply define an attribute of type UnitPrice. That way, when we decided that we actually wanted a Decimal[14,4] instead of a [12,2] we could change it in one place instead of dozens.

I know that this suggestion has been discussed before but there seems to have been little movement on it, apart from acknowledging it as a good idea.

2. It would be great to be able to define completely new types which would be a composite of other types. This would be the equivalent of a structure in C and C++, or a record in Pascal.

As an example, we'd like to define an Address type consisting, for example of:

flatNumber : String[3];
houseNumber : String[5];
unit : String[2];
streetAddress1 : String[50];
streetAddress2 : String[50];
suburb : String[30];
city : String[30];
postCode : Integer;

Then we could simply have a Person class with an attribute called address.

I know that this sounds like another class, but it need not be. Firstly, if it is a class, then an instance of it must be created and deleted - ie. its lifetime controlled. Secondly, the address should be embedded in the Person object - it has no identity of its own, therefore it shouldn't be an object. Additionally, there are locking and synchronisation issues if we make Address an object.

You'd be able to access its members just like you would with an object, and you'd also be able to have methods too, just like existing primitive types.

Interestingly, JADE already has some composite types built in - the TimeStamp and Point types are simply a Date and Time, and two Integers respectively. The semantics of this new feature should thus mimic the behaviour of these.

Craig.

Return to “Feature Discussions”

Who is online

Users browsing this forum: No registered users and 3 guests

cron