For now, I propose the following model be inserted into the datatype subsystem of the * UML metamodel.
If you don't have an image resizer plugin (firefox) the diagrams might be hard to read. I'm new to the blog - writely technology and haven't figured out the easiest way to insert readable model fragments. I will post the full pdf and BridgePoint files on the sourceforge site, though. Probably in a separate file package.
Here I just want to excerpt and explain what I have so far. This is only a model of data type structure, not data type operations. The model is best explained in two pieces: core and user data types. Then I will construct the Position data type to show how the model works.
Core Data Types
First let's examine the left side - the core data types.Nothing mysterious here. I have superclassed the Real and Integer Numeric types because they each may specify units.
Note that the max/min values on Integer and Real are kept in the subclasses since the types are not the same. The real type also specifies a precision as a positive integer representing decimal places to the right.
The Enumerated data type consists of a set of Symbols, each of which has a Value.
Finally, String has a positive integer maximum length. Now let's flip over to the right side.
User Data Types
A Vector is simply a collection of one or more values (as determined by Vector.Scale) all specified by the same Datatype. Since the Datatype can be either User or Core we can set up a hierarchical structure. Since Vector.Scale can be 1 or more we can build an N-dimensional matrix at any level of the hierarchy. Let's review the examples mentioned in my earlier post.
First we'll work from the bottom up to define the Position data type. Since minutes and seconds are the same in both latitude and longitude, let's define those.
Minutes
Our specification for Minutes is:Name: Minutes
Core Type: Integer
Min_value: 0
Max_value: 59
Units: minutes
So this gives us an instance each of: Integer, Numeric, Core Data Type and Data Type
Seconds
Using a more compact syntax, we specify:Seconds: real[0..60] prec 2 units seconds
This gives us an instance each of: Real, Numeric, Core Data Type and Data Type
Degrees Latitude
Lat_Degrees: int[-90..90] units degreesDegrees Longitude
Long_Degrees: int[-180..180] units degreesUnlike thte earlier post I am using negative degrees to avoid defining an enumerated type for [N | S] and [W | E].
No particular reason - just lazy. Also the max Minutes is 59 while max Seconds is 60 (59.999...). Seems like it is better to say "60". Otherwise you end up redundantly specifying the precision with a sequence of trailing nine's.
Latitude and Longitude
Now we start creating User Data Types as we work our way up the hierarchy.Name: Latitude
Vector: name Degrees, scale 1, value_datatype Lat_Degrees
Vector: name Minutes, scale 1, value_datatype Minutes
Vector: name Seconds, scale 1, value_datatype Seconds
Name: Longitude
Vector: name Degrees, scale 1, value_datatype Long_Degrees
Vector: name Minutes, scale 1, value_datatype Minutes
Vector: name Seconds, scale 1, value_datatype Seconds
Position
Name: Position
Vector: name Latitude, scale 1, value_datatype Latitude
Vector: name Longitude, scale 1, value_datatype Longitude
Matrix example
Now if, for some reason, we wanted a 5x10 matrix of Position data we could do this:
Name: Position_Column
Vector: name Position, scale 10, value_datatype Position
Name: Position_Matrix
Vector: name Position_Rows, scale 5, value_datatype Position_Column
Moving on
Okay, that's it for now. I might shelve the data type subsystem for a few days while I get some other tasks under control. Namely: Publish up a project roadmap, resume work on the model build script parser, sketch out key parts of the action language subsystem.
Stay tuned!
- Leon
No comments:
Post a Comment