Jump to content

Question about OOP and PHP


Joe Haley

Recommended Posts

Im wondering where to draw the line of "make it its own object / class"

Like with the user system im making:

Got your class "user", with propertys to define things like his username, and methods to do things like log him in and out.
Should password be its own class? (as one wants to encrypt and compare passwords, and functions would be the way to go for that.)

How much overhead is created by making nearly everything into objects? (for the purposes of abstraction, and a fancy "OOP PHP Programer" on the ol' resume)

Is it worth, in your oppinion, to do such things?
Link to comment
https://forums.phpfreaks.com/topic/14761-question-about-oop-and-php/
Share on other sites

Memory isnt so much an issue as the time it takes the compiler to deal with objects as opposed to variables. (small, i know. But stuff adds up...)

And beyond the overhead, look at it from a design standpoint.

(im relativly new to complex system design)
first of all, this user object is store in server, via session, so, user had no way to access this object.  Suppose the password is a member var of this user class, the password should already encrypted.  I don't see any reason to make an own class for password.
If you're familiar with OOP, it'll just be very similar in PHP.

you can create a member function for user class to compare the password.
yeah, you have to went thru the same encryption mechanism.  Normally, we used md5 hashing.  If you still feel unsecure with md5, you can add a salt.  Yes, PHP took care most of the complex works.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.