comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@acm.nospam.org>
Subject: Re: Factory Pattern
Date: Thu, 26 Jul 2007 00:51:04 GMT
Date: 2007-07-26T00:51:04+00:00	[thread overview]
Message-ID: <YdSpi.39934$Fc.15226@attbi_s21> (raw)
In-Reply-To: <1185387571.367570.163160@r34g2000hsd.googlegroups.com>

shaunpatterson@gmail.com wrote:
> 
> -- I would like it to work like this...
> function createMessage (type : Integer) return Message_Class is
> begin
>          case type is
>                  when 0 =>
>                       return MessageInteger_Pkg.create (1234);
>                  when others =>
>                        return MessageSomethingElse_Pkg.create
> ("blah");
>          end case
> 
> end createMessage

Obviously this won't work, since Messageinteger_Pkg.Create returns type 
Messageinteger, presumably a tagged record type, not Message_Class, an 
access type.

I would think that an enumeration type would be better than Integer for 
selecting among a few choices. Using Integer probably reflects C/++ 
thinking.

Like all well designed languages, Ada is not case sensitive. We tend to 
avoid camelCase, since the 1st thing people often do is run it through a 
reformatter that will convert it to the de facto Ada standard of 
Camelcase. Instead we separate words with underlines.

Ada's features for programming by extension are somewhat different than 
C++'s, and you need to become familiar with the Ada concepts before 
trying something like this. Once you do, though, you may find you like 
Ada way better. You can have both static and dispatching calls to the 
same subprogram, for example.

-- 
Jeff Carter
"Sheriff murdered, crops burned, stores looted,
people stampeded, and cattle raped."
Blazing Saddles
35



  parent reply	other threads:[~2007-07-26  0:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-25 18:19 Factory Pattern shaunpatterson
2007-07-25 18:28 ` Martin
2007-07-25 18:51 ` Dmitry A. Kazakov
2007-07-25 21:06   ` Georg Bauhaus
2007-07-25 19:27 ` Matthew Heaney
2007-07-26  0:51 ` Jeffrey R. Carter [this message]
2007-07-26  6:44   ` Maciej Sobczak
2007-07-26  8:40     ` Georg Bauhaus
2007-07-26  9:53       ` Dmitry A. Kazakov
2007-07-26 11:01         ` Georg Bauhaus
2007-07-26 13:02           ` Maciej Sobczak
2007-07-26 13:44             ` Dmitry A. Kazakov
2007-07-26 14:58             ` Georg Bauhaus
2007-07-26 22:31             ` Randy Brukardt
2007-07-27 13:07               ` Maciej Sobczak
2007-07-27 14:23                 ` shaunpatterson
2007-07-27 22:23                 ` Randy Brukardt
2007-07-28 18:56                   ` Maciej Sobczak
2007-07-29  7:54                   ` Maciej Sobczak
2007-07-29  8:53                     ` Dmitry A. Kazakov
2007-07-29 10:53                     ` Georg Bauhaus
2007-07-26 16:58         ` Adam Beneschan
2007-07-29 11:38         ` Manuel Gomez
2007-07-27 10:16     ` Jeffrey R. Carter
2007-07-27 12:47       ` Maciej Sobczak
2007-08-26  7:18         ` David Thompson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox