a k wrote:
In the process of writing an Action class, I realized that it needs
some application functionality (not general utility kinda
functionality) that is already part of a method in a different Action
class.
So, Action MyAction1 needs to access method myMethod2 in Action
MyAction2. Here are the options that I could think of:
IMHO this breaks OO principle: a class to have one and only one purpose.
So instantiate MyAction2 just to use one of it's methods is a bad practice.
1. Instantiate the MyAction2 class manually and access the myMethod2.
2. Create a Helper class and move the funcationality there so that
both the classes could use it.
I cannot put this in a separate parent class and extend MyAction1 and
MyAction2 from it because I already have another Action class that all
Actions extend from and I would like to adhere to it...if possible.
So why not to put this myMethod2 in this base class. But there is other
good rule of thumb: composition instead of inheritance, so I'm
definitely for option 2 - helper class.
What is a better way in this scenario? In particular, is it bad to
manually instantiate Action classes?
Thanks!
Regards
Borislav
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]