Closed GoogleCodeExporter closed 9 years ago
I've currently removed the offending __construct calls to fix the error, but
maybe this topic needs some more discussion to ensure a proper decision is
taken.
So if you're pro or against the introduction of a __construct hierarchy, please
comment.
IMHO:
adding a lot of empty constructor calls is quite useless; it can help you to
ensure that you won't miss to call a parent implementation, but it introduces a
lot of unnecessary overhead. Then, what about a __destruct() hierarchy too?
In reality prefer the c++ approach, where you're forced to have a
constructor/destructor and the parent::* calls are automatically executed; but
this is php, and it's designed to work in a different way.
Original comment by ctrlal...@gmail.com
on 25 Jun 2011 at 10:03
Side note: in ticket http://code.google.com/p/prado3/source/detail?r=2990
javalizard points out a good reason why prado could need a constructor chain.
Original comment by ctrlal...@gmail.com
on 25 Jun 2011 at 10:19
http://code.google.com/p/prado3/issues/detail?id=257
TComponent doesn't have anything in it's constructor _yet_. These changes to
chain the constructor/destructor are in place to enable my next set of check
ins. The next TComponent checkin requires proper constructor/destructor
chaining... it is also proper code form.
If something important were to be place in the TComponent constructor, like I'm
going to be doing very shortly, these seemingly useless functions suddenly
become very useful.
Original comment by javalizard@gmail.com
on 25 Jun 2011 at 4:04
I don't think the empty constructors would really add much overhead, since
Prado's using now cached templates, configuration files, etc., which means that
the overwhelming majority of objects used during the page cycle are now
recontructed (save for the first time the template/page is referred) from
serialized() strings by a call to unserialize(). The latter however does not
call the constructors when re-creating the objects, therefore any overhead
inside the constructors won't really affect Prado's performance - except for
the first pageview and for dynamically constructed object at run-time.
An in-tact constructor chain however is key for proper and easy refactoring of
both core and 3rd party/extension code, ie. where you can simply change the
parent/base class of a derived object to add functionality to it or change it's
behaviour, without having to worry whether the parent class has a constructor
and/or that it gets called properly - because you can and do always call it in
derived classes.
Original comment by google...@pcforum.hu
on 11 Mar 2012 at 1:03
Original comment by ctrlal...@gmail.com
on 25 Jun 2012 at 1:56
r3211 This adds a common constructor function to TComponent. All classes with
__construct need to call "parent::__construct"
Original comment by javalizard@gmail.com
on 7 Nov 2012 at 6:56
Original comment by ctrlal...@gmail.com
on 21 Jan 2013 at 7:03
Original comment by ctrlal...@gmail.com
on 24 Jul 2013 at 1:46
Moved to github: https://github.com/pradosoft/prado/issues
Original comment by ctrlal...@gmail.com
on 1 Oct 2013 at 10:14
Original issue reported on code.google.com by
google...@pcforum.hu
on 25 Jun 2011 at 5:53