comp.lang.ada
 help / color / mirror / Atom feed
From: Michael Erdmann <Michael.Erdmann@snafu.de>
Subject: Re: Q: Refactorizing code because Inheritance and Interfaces
Date: Tue, 21 Oct 2003 21:58:04 +0200
Date: 2003-10-21T21:58:04+02:00	[thread overview]
Message-ID: <cnfg61-5hg.ln1@boavista.snafu.de> (raw)
In-Reply-To: uekx7n3ds.fsf@nasa.gov

Stephen Leake wrote:

> Michael Erdmann <Michael.Erdmann@snafu.de> writes:
> 
>> In order to line up the implemenation of the XML_Reader with the
>> Abstract_Reader interface i need to rewrite the complete XML_Reader.
>> Is there any way to avoid such situations?
> 
> In general, no. Refactoring is hard work. That's why it's worth doing :).

Well the code i got a result is not realy nice. The result is now:

1. I had to move the type declaration of the XML Reader into the 
   package body.

2. I needed to define my new type as an implementation of the interface
   is wanted to introdcue.

it looks now like this:

   package ... is

      type Object is new  XX.Interface.Object with private;


   private 
      type Object_Data_Type;

      type Object is new XX.Interface.Object with record
             Data : Object_Data_Access := Initialize;
          end record;

   package


   package body is
  
     type XML_Reader_Type is new SAX ...... with..

     procedure Element_Begin( S : in XML_Reader ....)

     type Object_Type is record
        ....
           Reader : XML_Reader_Type ;
        end record;

   end ..;

This was a lot more refactorizing then i expected! I am now afraid
that i have to spend the effort again, again ......


> 
>> In java i would use   constructs as implements  Sax..,Abstract_Reader.
> 
> Ada 200Y will have interface inheritance similar to Java's. But you
> still need to rewrite the implementation, so I don't see that as
> saving much work.
> 
> You can get something similar to interface inheritance in Ada 95 using
> generic mixins. It depends on the details of what you are doing
> exactly what approach to take.
> 




  reply	other threads:[~2003-10-21 19:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-18  9:10 Q: Refactorizing code because Inheritance and Interfaces Michael Erdmann
2003-10-20 18:57 ` Stephen Leake
2003-10-21 19:58   ` Michael Erdmann [this message]
2003-10-21  5:48 ` Simon Wright
2003-10-21  8:38   ` Marius Amado Alves
2003-10-21 19:50     ` Michael Erdmann
2003-10-25 12:11       ` Georg Bauhaus
2003-10-21 20:01   ` Michael Erdmann
2003-10-23 14:02     ` Jean-Pierre Rosen
  -- strict thread matches above, loose matches on Subject: below --
2003-10-21  9:00 Lionel.DRAGHI
replies disabled

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