Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating an Object vs simply storing variables

Enthusiast ,
Oct 09, 2013 Oct 09, 2013

Are there any pro/cons I should be aware of in this case?

My application has users.  I could create a 'user' object with the appropriate properties and methods to hold the logged in user's information, performing things like: user.getName() and user.logout().   But on the other side of the coin, if I wanted to get the name of a user, I could simply have a structure like SESSION.user.name and just retrieve it's value.  And if I wanted to perform a logout, I could simply call the function in my security component and pass the needed info.

I like the idea of using OOP where possible, but is there any issue with going that route vs more simplified non-OOP methodologies?

422
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources