Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

calling overriden method from outside of class

 
   Database Help (Home) -> PHP RSS
Next:  MY EMAIL  
Author Message
Delirium tremens

External


Since: Nov 27, 2008
Posts: 21



(Msg. 1) Posted: Fri Dec 26, 2008 4:48 pm
Post subject: calling overriden method from outside of class
Archived from groups: comp>lang>php (more info?)

I created a FormChecker class and an AntiCracker class extending the
FormChecker class. I want to use the aFiller method from AntiCracker,
but I want to use the aFiller method from FormChecker too. If I create
$fc->aMethod and call AntiCracker::aFiller, are the two "aFiller"s
going to use the same properties? When you need to the methods from
the parent and child classes to use the same properties, what do you
do? Is this a normal situation or a design pattern error???

 >> Stay informed about: calling overriden method from outside of class 
Back to top
Login to vote
Delirium tremens

External


Since: Nov 27, 2008
Posts: 21



(Msg. 2) Posted: Fri Dec 26, 2008 4:57 pm
Post subject: Re: calling overriden method from outside of class [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 26 dez, 22:48, Delirium tremens wrote:
> I created a FormChecker class and an AntiCracker class extending the
> FormChecker class. I want to use the aFiller method from AntiCracker,
> but I want to use the aFiller method from FormChecker too. If I create
> $fc->aMethod and call AntiCracker::aFiller, are the two "aFiller"s
> going to use the same properties? When you need to the methods from
> the parent and child classes to use the same properties, what do you
> do? Is this a normal situation or a design pattern error???

Two related topics.

http://groups.google.com/group/comp.lang.php/browse_thread/thread/43cb...d0a2510

http://groups.google.com/group/comp.lang.php/browse_thread/thread/4388...db2ad3d

If it is a design pattern, what should I do???

 >> Stay informed about: calling overriden method from outside of class 
Back to top
Login to vote
Delirium tremens

External


Since: Nov 27, 2008
Posts: 21



(Msg. 3) Posted: Fri Dec 26, 2008 4:59 pm
Post subject: Re: calling overriden method from outside of class [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 26 dez, 22:48, Delirium tremens wrote:
> I created a FormChecker class and an AntiCracker class extending the
> FormChecker class. I want to use the aFiller method from AntiCracker,
> but I want to use the aFiller method from FormChecker too. If I create
> $fc->aMethod and call AntiCracker::aFiller, are the two "aFiller"s
> going to use the same properties? When you need to the methods from
> the parent and child classes to use the same properties, what do you
> do? Is this a normal situation or a design pattern error???

Two related topics.

http://groups.google.com/group/comp.lang.php/browse_thread/thread/43c...

http://groups.google.com/group/comp.lang.php/browse_thread/thread/438...

If it is a design pattern error, what should I do?
 >> Stay informed about: calling overriden method from outside of class 
Back to top
Login to vote
Jerry Stuckle

External


Since: Aug 11, 2004
Posts: 3780



(Msg. 4) Posted: Fri Dec 26, 2008 5:53 pm
Post subject: Re: calling overriden method from outside of class [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Delirium tremens wrote:
> I created a FormChecker class and an AntiCracker class extending the
> FormChecker class. I want to use the aFiller method from AntiCracker,
> but I want to use the aFiller method from FormChecker too. If I create
> $fc->aMethod and call AntiCracker::aFiller, are the two "aFiller"s
> going to use the same properties? When you need to the methods from
> the parent and child classes to use the same properties, what do you
> do? Is this a normal situation or a design pattern error???

The base class method will only access members of the base class.
Derived class methods can access base derived class members, or base
class members which are public (very bad) or protected (only slightly
better).

Generally, derived class members access members of their own class
directly; if they need to access base class members (not necessarily a
design problem), they often do it through access functions.

These access functions may be protected or public; one should be careful
not to make any variables in either class public (or protected, if you
can help it).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.TakeThisOut@attglobal.net
==================
 >> Stay informed about: calling overriden method from outside of class 
Back to top
Login to vote
Delirium tremens

External


Since: Nov 27, 2008
Posts: 21



(Msg. 5) Posted: Sat Dec 27, 2008 12:32 am
Post subject: Re: calling overriden method from outside of class [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 26 dez, 20:53, Jerry Stuckle wrote:
> Delirium tremens wrote:
> > I created a FormChecker class and an AntiCracker class extending the
> > FormChecker class. I want to use the aFiller method from AntiCracker,
> > but I want to use the aFiller method from FormChecker too. If I create
> > $fc->aMethod and call AntiCracker::aFiller, are the two "aFiller"s
> > going to use the same properties? When you need to the methods from
> > the parent and child classes to use the same properties, what do you
> > do? Is this a normal situation or a design pattern error???
>
> The base class method will only access members of the base class.
> Derived class methods can access base derived class members, or base
> class members which are public (very bad) or protected (only slightly
> better).
>
> Generally, derived class members access members of their own class
> directly; if they need to access base class members (not necessarily a
> design problem), they often do it through access functions.
>
> These access functions may be protected or public; one should be careful
> not to make any variables in either class public (or protected, if you
> can help it).
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck... DeleteThis @attglobal.net
> ==================

Storing all properties in, setting all properties to and getting all
properties from one class is the solution. That is what a model is
for. The "business logic" meaning is clear now.
 >> Stay informed about: calling overriden method from outside of class 
Back to top
Login to vote
Delirium tremens

External


Since: Nov 27, 2008
Posts: 21



(Msg. 6) Posted: Sat Dec 27, 2008 12:36 am
Post subject: Re: calling overriden method from outside of class [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 27 dez, 06:32, Delirium tremens wrote:
> On 26 dez, 20:53, Jerry Stuckle wrote:
>
>
>
> > Delirium tremens wrote:
> > > I created a FormChecker class and an AntiCracker class extending the
> > > FormChecker class. I want to use the aFiller method from AntiCracker,
> > > but I want to use the aFiller method from FormChecker too. If I create
> > > $fc->aMethod and call AntiCracker::aFiller, are the two "aFiller"s
> > > going to use the same properties? When you need to the methods from
> > > the parent and child classes to use the same properties, what do you
> > > do? Is this a normal situation or a design pattern error???
>
> > The base class method will only access members of the base class.
> > Derived class methods can access base derived class members, or base
> > class members which are public (very bad) or protected (only slightly
> > better).
>
> > Generally, derived class members access members of their own class
> > directly; if they need to access base class members (not necessarily a
> > design problem), they often do it through access functions.
>
> > These access functions may be protected or public; one should be careful
> > not to make any variables in either class public (or protected, if you
> > can help it).
>
> > --
> > ==================
> > Remove the "x" from my email address
> > Jerry Stuckle
> > JDS Computer Training Corp.
> > jstuck... RemoveThis @attglobal.net
> > ==================
>
> Storing all properties in, setting all properties to and getting all
> properties from one class is the solution. That is what a model is
> for. The "business logic" meaning is clear now.

I am not sure about setting all properties to. it may be just storing
and getting.
 >> Stay informed about: calling overriden method from outside of class 
Back to top
Login to vote
Jerry Stuckle

External


Since: Aug 11, 2004
Posts: 3780



(Msg. 7) Posted: Sat Dec 27, 2008 5:33 am
Post subject: Re: calling overriden method from outside of class [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Delirium tremens wrote:
> On 26 dez, 20:53, Jerry Stuckle wrote:
>> Delirium tremens wrote:
>>> I created a FormChecker class and an AntiCracker class extending the
>>> FormChecker class. I want to use the aFiller method from AntiCracker,
>>> but I want to use the aFiller method from FormChecker too. If I create
>>> $fc->aMethod and call AntiCracker::aFiller, are the two "aFiller"s
>>> going to use the same properties? When you need to the methods from
>>> the parent and child classes to use the same properties, what do you
>>> do? Is this a normal situation or a design pattern error???
>> The base class method will only access members of the base class.
>> Derived class methods can access base derived class members, or base
>> class members which are public (very bad) or protected (only slightly
>> better).
>>
>> Generally, derived class members access members of their own class
>> directly; if they need to access base class members (not necessarily a
>> design problem), they often do it through access functions.
>>
>> These access functions may be protected or public; one should be careful
>> not to make any variables in either class public (or protected, if you
>> can help it).
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck....RemoveThis@attglobal.net
>> ==================
>
> Storing all properties in, setting all properties to and getting all
> properties from one class is the solution. That is what a model is
> for. The "business logic" meaning is clear now.

No, it is not the solution. There are very valid reasons for having
properties in derived classes.

The solution is to have the properties in the classes where they are
needed.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex.RemoveThis@attglobal.net
==================
 >> Stay informed about: calling overriden method from outside of class 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
name of the calling method - Hi, I'd like to get the name of the calling method. I can't find the solution. For example : function MyFct() { return TheOtherFct() ; } function TheOtherFct() { echo "Hi, the calling method is ..." ; return true ; } MyFct() ; ...

Get calling class - I have the following: class A { function something($args) { print $CLASS_THAT_IS_CALLING_THIS_FUNCTION; } } class B { function execute($args) { $a = new A(); $a->something($args); } } When executing B::execute($args), it should print B. I...

Adding a method to a class - Hi, do you know how can I add a method to a class? For example, I have a class named Dummy. I want to add a method "stupid". How can I use create_function or others to do this? Thanks -- Staff elive.it www.elive.it Gli eventi live a portata ...

preg_replace_callback, class method? - I tried to use a class member function as a callback in preg_replace_callback, but failed. It announces: " Warning: preg_replace_callback() [function.preg-replace-callback]: requires argument 2, 'myclass::myfunction', to be a valid callback in .....

Accessing Class Method - I have the following code: index.php: class main_class { public $database = new DAL; public $html = new HTML; } dal.php: class DAL { function method() { # Code } } class HTML { function method() { # Code # HOW TO CALL DAL'S METHOD? # Code } } A...
   Database Help (Home) -> PHP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]