OOP , new objects and existing objects
Posted: Fri Feb 27, 2009 9:56 am
Hello folks,
I'm learning how to use OOP , and i already know a little bit of how to use them.
But a question remains in my head, It's supposed to retrieve data from the database and put within the object ?
For example, i have a object User that can make some methods like
makeRequest() to request some file and some other methods.
But my user has attributes like name, age etc.
If it's an existing user, you can download the data from the database and put within the attributes of the object.
But the problem arises when we talk of new users. Shall i create only a constructor to receive da data of the new user as arguments and insert in the database ? Because, for me there isn't any sense to create a object user just to add the user to the database.
Thanks
I'm learning how to use OOP , and i already know a little bit of how to use them.
But a question remains in my head, It's supposed to retrieve data from the database and put within the object ?
For example, i have a object User that can make some methods like
makeRequest() to request some file and some other methods.
But my user has attributes like name, age etc.
If it's an existing user, you can download the data from the database and put within the attributes of the object.
But the problem arises when we talk of new users. Shall i create only a constructor to receive da data of the new user as arguments and insert in the database ? Because, for me there isn't any sense to create a object user just to add the user to the database.
Thanks