How do you know when to split an object method into 2 or more other methods?
Posted
by
blacktie24
on Programmers
See other posts from Programmers
or by blacktie24
Published on 2011-03-06T23:53:55Z
Indexed on
2011/03/07
16:18 UTC
Read the original article
Hit count: 211
Hi, I know this is a very basic question, but I sometimes find myself struggling to figure out when to split a single object method into multiple methods. For example, I am trying to set up an ACL using Zend_Acl and Zend_Auth, as shown in this tutorial: http://devzone.zend.com/article/1665. However, I am wondering if the My_Plugin_Auth::preDispatch() method should invoke calls to a method called authenticate() and a method called authorize(), instead of having everything lumped in under preDispatch(). I was thinking that this would make the code more readable and encapsulate the logic into its smaller parts, but i'm not sure if this is reason enough.
© Programmers or respective owner