Page 1 of 1

Using multiple functions for returning or one main function

Posted: Sat May 03, 2008 10:51 pm
by parka
Let's say I have a User class.

This User class has some variables, namely id, name, date_of_birth, username etc.

Should I just create one separate function to return each attribute?
Or would it be better to create just one main function and return all the User variables as array items?

I'm guessing the first one should be less taxing for the database. But requires a lot more coding.

Re: Using multiple functions for returning or one main function

Posted: Sun May 04, 2008 12:07 am
by yacahuma
I will say the standard is to have setters and getters for each member function.

One reason that comes tom mind is to help prevents bugs

if you do a get('firstname')

you could , by mistake, type get('firsttname') and you will not get the data