From: Marek Janukowicz <marek@janukowicz.net>
Subject: Re: Design problem: generic package vs tagged subtype
Date: Thu, 01 Jul 2010 00:33:40 +0200
Date: 2010-07-01T00:33:40+02:00 [thread overview]
Message-ID: <i0ggo1$1ejm$1@adenine.netfront.net> (raw)
In-Reply-To: m2wrtgxr28.fsf@pushface.org
Simon Wright wrote:
>> For Model I use a tagged type wrapped into generic package:
>> generic
>> Tbl_Name : String;
>> type Attribute_Type is (<>);
>> type Attribute_Type_Array is array (Attribute_Type range <>) of
>
> Does this have to be an unconstrained array? If it wasn't, you wouldn't
> need to worry about whether Attribute_Types covered the range of
> Attribute_Type.
The only reason it was an unconstrained array is that my Ada skills are
extremely poor and I didn't know it would work this way :) I'm a bit lost in
this subject in general: could anyone tell me the exact difference between:
- array (Attribute_Type)
- array (Attribute_Type range <>)
- array (Attribute_Type'Range)
>> Attribute_Type_Type;
>> Attribute_Types : Attribute_Type_Array;
>> package Dar.Models.Base is
>>
>> type Model is abstract tagged limited record
>
> type Model is new Abstract_Base with ...
>
>> ...
>>
>> For associations I also use a generic package:
>> generic
>> with package Source_Model is new Dar.Models.Base(<>);
>> with package Target_Model is new Dar.Models.Base(<>);
>> Foreign_Key : String;
>> package Dar.Models.Associations is
>> function Find
>> ...
>
> ... then the association can be between objects of type
> Abstract_Base_Class'Class (though I don't see how you'd express the
> actual relationship, not clear how Foreign_Key enters the picture).
That's how I really have it implemented, didn't want to go that much into
the details. Generally, I need to figure out what's really my problem here
and then ask again :)
>> 2. I have a type Attribute_Type_Type used to specify types of attributes
>> (Integer, Date, String etc.). I then have a variant record:
>> type Attribute_Value( Attr_Type : Attribute_Type_Type ) is
>> record
>> case Attr_Type is
>> when Attr_Date =>
>> Date_Value : APQ_Date;
>> when Attr_Time =>
>> Time_Value : APQ_Time;
>> ...
>> Is there any way to use builtin types here instead of Attr_Date,
>> Attr_Integer, etc? Note that I need to specify type of each attribute in
>> one array.
>
> I don't believe so.
>
> As a side note I really dislike the name Attribute_Type_Type. It seems
> to me that what you've called Attribute_Type is much more like a Name
> than a Type.
Yeah, you might be right on that. I still need to find out what a good
naming convention would be. I wouldn't like to use:
type Attribute_Name_Type is (Id, Username, ...)
but if I call the type Attribute_Name I'll have problems naming variables of
that type (because Attribute_Name seems to be the best name for them as
well).
That's one of the things I dislike in Ada - everything (types, variables,
packages, operations) follows exactly the same naming convention and doesn't
use any special character/whatever to distinguish between them, so you run
out of good names in no time...
--
Marek Janukowicz
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
next prev parent reply other threads:[~2010-06-30 22:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-30 17:52 Design problem: generic package vs tagged subtype Marek Janukowicz
2010-06-30 19:23 ` Simon Wright
2010-06-30 22:33 ` Marek Janukowicz [this message]
2010-07-01 4:13 ` naming, was " tmoran
2010-07-01 9:49 ` J-P. Rosen
2010-07-01 15:48 ` Marcelo Coraça de Freitas
2010-07-01 5:57 ` Simon Wright
2010-07-01 18:30 ` Jeffrey R. Carter
2010-07-01 19:28 ` Simon Wright
2010-07-01 19:59 ` Jeffrey R. Carter
2010-07-01 21:14 ` Per Sandberg
2010-07-02 9:25 ` Stephen Leake
2010-07-02 10:50 ` Georg Bauhaus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox