On 22 July 2010 15:27, Sebastian Ewert <seb2...@yahoo.de> wrote:
> Jay Blanchard wrote:
>> [snip]
>> Thats exacty the point. In my user class I have functions whitch return
>> object-lists of diffrent users or strings with html-form elements for
>> managing this user account.
>>
>> But if I put all these in a helper class I would anyway need to
>> implement the user object there, because of the other getter functions
>> (getUserName etc.) and the table-objects.
>>
>> I always thought this would be less effective, because I have more
>> instances of objects.
>> [/snip]
>>
>> Sounds like a major refactoring is in order, how reusable is your class?
>>
>> There is not enough room in this e-mail to cover the basic and
>> intermediate practices of OO design but it sounds like you may need to
>> re-think your design. Does this class do one thing and only one thing?
>> Does it do it really well?
>>
>
> Thanks for your advice. I know that I have to go much deeper into
> programm design. I would appreciate if you could send me some links with
> practial examples. I've only read some theoretical and very general
> stuff about it and cannot link everything to the real world.
>
>> Just from what I am reading I see that we have a user class
>> (getUserName) and that class returns lists of users? It sounds as if to
>> me that the user class talks not only about a single user, but perhaps
>> all of the users (object lists of different users).
>>
>
> That was just to generalize things. My user class only returns
> informations for one user. These informations are values of db-fields or
> generated html strings.
>
> But other classes like my message class have functions that return lists
> of instances of their own class. From what you've written I think its
> better to extract these functions into helper classes.
>
> But if you want to get all messages that refer to one specific msg its
> better to leave that function in the message class, isn't it? Or if you
> want to get a list with all friends of a specific user?(friends are not
> implemented yet)
>
>> On the surface that sounds like to classes to me, a user class and a
>> class to manipulate said users.
>>
>>
>
> But back to my first Problem:
>
> Is a class with 850 lines to long?
> If it is should I take all the html genarating functions and put them in
> a helper class?
> If I do so and there is no way to call those functions without
> initalizing the main user object, will there still be an increase of
> performance?
>

It's unlikely to cause you performance problems unless you've got a
huge amount of traffic - and then you could probably fix your problems
easier than refactoring classes.

Personal anecdote: I've worked on classes longer than 3K lines with no
marked performance problem. That doesn't mean I recommend it, though:
bigger classes are a pain to maintain as you loose overview of what's
in the class.

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to