On 03.07.2013 20:48, Sanford Whiteman wrote: >> Most often if I need a super __construct(), I don't need it exactly >> before or exactly after the bottom constructor but at a specific point >> where I can setup super's input data and do stuff to its output. > > I've most often seen, or reluctantly implemented, the Call Super > antipattern by putting the call at the bottom of sub code. > > It's true that it's an antipattern regardless of "advisory" placement. > But to me, somewhere-in-the-middle is even smellier than usual, since > in human hands that's got to be more prone to failure. > > I think if Contractual Call Super were considered for the language it > should have before and after variants, not just after. There isn't a > practical way to declare "at some point," is there, even if you wanted > it?
No, that's why I am asking. Why is it an anti-pattern to call a known super constructor? Not knowing the implementation details, I still know the documented api (which is all a class should ask for). >> What is the typical use case for calling all supers (before or after the >> class' __construct itself) ? > > I can't think of a valid case in my memory for _all_ supers. Typically > you mean to call the immediate super _or_ the root super. Which is of > course the problem with the "advisory" form of this pattern, since > innocently inserting an intermediate class breaks your code. This makes it more complicated. Do you mean next super or root super (or root-1 as any class object is an "object" ? I don't mean to disrupt any ideas. I just think how I would use or expect to use the feature. > If this feature were introduced, I see no reason for it to be allowed > to call more than one method for each occurrence of 'sequential' > keyword. > > That is, > > class A { sequentialBefore function __construct() {} } > class Asub extends A { function __construct() {} } > class Asubsub extends Asub { function __construct() {} } > > would run A::__construct and then Asubsub::construct() > > class A { sequentialBefore function __construct() {} } > class Asub extends A { sequentialBefore function __construct() {} } > class Asubsub extends Asub { function __construct() {} } > > would run A::__construct, Asub::__construct, Asubsub::__construct > > class A { sequentialBefore function __construct() {} } > class Asub extends A { sequentialAfter function __construct() {} } > class Asubsub extends Asub { function __construct() {} } > > would run A::__construct, Asubsub::construct(), Asub::__construct > I'm not particularly cheering for this feature but enjoy thinking > about how it might work. If you see my notes on the previous thread > you can see I'm pretty adamant about Call Super being very bad > _unless_ it's baked into the language in an interesting way. Not that it would be an argument but just for understanding: Do you know any scripting language which has this? This would help me seeing the idea as I know some of them. -- Ralf Lang Linux Consultant / Developer Mail: l...@b1-systems.de B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
signature.asc
Description: OpenPGP digital signature