1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Static function to get a user list [on hold]

Discussão em 'StackOverflow' iniciado por fdantas, Novembro 22, 2017.

  1. fdantas

    fdantas Administrator Moderador

    I have a need to list the users in my database, but being unfamiliar with OOP best practices I am unsure where to implement the method. So far I have come up with two choices:

    • Using my existing User class, create a static method to get users User.GetAllUsers().
    • Create a factory object to create a static method UserFactory.GetAllUsers()

    My question is really is there a best way to do this, and is there any performance differences. Or is this down to application / programmer choice.

    The method may return a collection of generic objects (not necessarily cast as a collection of users). In this instance i would lean to the first method. If i then decided to return a collection of users, I would have thought option two would be better. Furthermore, in future there may be many more methods to get a list of users, which leads me to option 2 again.

    If the way to program this is largely opinion based then that would give me an answer along the lines of "It's up to me to decide". If however there was a very good reason to avoid one of these due to performance then that would also be useful to know.

    Continue reading...

Compartilhe esta Página