From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,30e368bdb3310fe5 X-Google-Attributes: gid109fba,public X-Google-Thread: fac41,af40e09e753872c X-Google-Attributes: gidfac41,public X-Google-Thread: f8c65,30e368bdb3310fe5 X-Google-Attributes: gidf8c65,public X-Google-Thread: 1014db,30e368bdb3310fe5 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,30e368bdb3310fe5 X-Google-Attributes: gid103376,public X-Google-Thread: 10db24,30e368bdb3310fe5 X-Google-Attributes: gid10db24,public X-Google-Thread: 1008e3,30e368bdb3310fe5 X-Google-Attributes: gid1008e3,public From: feathers@gate.net (Michael Feathers) Subject: Re: Hungarian notation Date: 1996/01/09 Message-ID: <4ctomq$1pi8@hopi.gate.net>#1/1 X-Deja-AN: 134548093 references: <30C40F77.53B5@swsbbs.com> <30EF0415.6FE1@tus.ssi1.com> <1996Jan7.045815.8676@ohstpy> <4cpb00$nqk@news.xmission.com> <4crm6i$24mi@navajo.gate.net> <4csi2t$gsa@news.xmission.com> followup-to: comp.lang.eiffel,comp.lang.ada,comp.edu,comp.lang.c,comp.lang.c++,comp.lang.modula2,comp.lang.modula3 organization: CyberGate, Inc. newsgroups: comp.lang.eiffel,comp.lang.ada,comp.edu,comp.lang.c,comp.lang.c++,comp.lang.modula2,comp.lang.modula3 Date: 1996-01-09T00:00:00+00:00 List-Id: Todd Knarr (tknarr@xmission.com) wrote: : In <4crm6i$24mi@navajo.gate.net>, feathers@gate.net (Michael Feathers) writes: : >I've never seen a variable that can be any of 9 different types in C++. : >All variables have a type. Period. A type can be a union or a base : >class, but all variables have one and only one type in C++. If you don't : >believe me, check the ARM. : : You haven't worked with polymorphic classes as reference arguments or : pointers much, then. I have the following class heirarchy: Yeah, I have. In your example (deleted for space) you mention that a reference can stand in place for objects of any of its derived types. I said that all variables have one-and-only-one-type. The reference itself is a variable (as pointers are) and it has a type. This may seem like a quibbling point, but in OOP it should be a natural assumption (because of polymorphism) that all objects of derived classes should perform in a manner appropriate to their class in the context of their base classes interfaces. This is information hiding, in much the same way as function names hide implementation yet provide semantic information. If this is not the case, then the inheritance should be suspect. : Give me an HN prefix that tells me that, in the following prototype : : Stall *HardwareChangeSignalled( Stall& ExistingStall, int ByteCount, : unsigned char *aHardwareData ); : : the ExistingStall argument is one of the 9 subclasses and never a Stall, : and the returned pointer is one of the 9 subclasses and never a pointer to : Stall. Why never a Stall? If Stall's interface is present in any of its derived classes, Stall calls should be resolved. : Without such a prefix, you can readily get the obnoxious situation of a new : programmer depending on the prefix and not realizing that he is dealing with : a polymorphic type. This can cause him problems if he refers to the source : code for Stall, depending on the HN prefix to be the actual type. True enough, but I think that new OOP programmers should drill it into their heads that references==pointers as far as polymorphism goes (and in other ways too). Polymorphism has to change the way that you understand code. We are not in Kansas any more.