Re: Code generation



Nick Hodges (CodeGear) wrote:

Brad White wrote:

You would put the event handlers that you write
in the parent class that is autogenerated?

No, you'd put the code to link up the methods to the events in the
parent class -- if that is the way your component peristence worked.

I'm really saying in the general case, partial classes aren't
necessary, because an inheritence relationship can accomplish the same
thing.

Actually it can't. It will give the "B' does not inherit A'" sydrome.

Imagine two "real" classes, A and B, where B inherits from A.

As a (nowdays popular through NHibernate) trick you subclass them, at
codegen time or magically at runtime, into A?and B? to inject behaviour.

At this point, in terms of the actual runtime classes, B' does not
inherit A'.

This is usually not a problem, since B' does inhert A. And since the
user thinks he has a B, not a B', it mostly works out.

However, many legitimate uses including reflection and runtime checking
of types and subtypes give what can politely be referred to as
unexpected behaviour.

As an example, checking if two instances are are assignement compatible
will fail. You must know about the runtime subtyping, and check for
compatibility of the ancestors one step up.


--
Jan Nordén, ECO Architect
CapableObjects AB
email: <firstname>.<lastname without accent over e>@capableobjects.com
http://www.capableobjects.com
.



Relevant Pages

  • Re: CLOS question
    ... If you don't want to inherit these ... you simply don't mix the parent class into your class. ... indeed a pain ... ... :after methods to appear only under a call-next-method. ...
    (comp.lang.lisp)
  • Re: Class Inheritance
    ... One suggestion was to have a parent class that ... Class A and Class B both inherit from and have the property in question be ... properties of the parent class? ... Btw, I'm coding in C#, in ...
    (microsoft.public.dotnet.general)
  • Handling a network reply - best method?
    ... connect dependant on the sent request from the client. ... I want all the network code i have done to be in one class and then i want ... to inherit that class for a new class which i will put all my application ... function when the parent class gets a datareceive? ...
    (microsoft.public.win32.programmer.networks)
  • Re: Modules in rails? ( controllers or models?)
    ... So I am thinking to create a parent class and then the sub ... But rails already inherits from ActiveRecord ... So how can I inherit from others classes. ...
    (comp.lang.ruby)
  • Re: Wahoo!
    ... John Wester wrote: ... CodeGear:= TCompany.Create; ... I don't think they should inherit too much Borland-ness. ...
    (borland.public.delphi.non-technical)