DeX Posted June 9, 2022 Share Posted June 9, 2022 I have models for all of my database objects. For instance, I have a User class and in that class I have functions like so: getFirstName() getLastName() getAddress() And of course I have setters for each as well. My question is whether I should also have some helper functions inside this model for something like getFullName() which will return a concatenation of getFirstName() and getLastName() or if we should simply concatenate the data every time we want to display it on each page. So we will be displaying the user's name on the top of each page, in their account profile and maybe some other places of this portal type system. Is it proper object oriented programming to use helper functions like this? Should they go into the controller? Should we create separate logic namespaces for each model to control this logic? Another example would be if I wanted to get the most recent user that signed up, where would this function go? In the user model? In the controller? Thanks. Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.