Jump to content

Archived

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

Joe Haley

Question about OOP and PHP

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?

Share this post


Link to post
Share on other sites
is there a good reason why should you concern about this issue?
it's a script, run and exit, load and unload.  Memory is not a big issue.

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Yes, but where would one stick the functions to encrypt and compare a password?

And its not just this specifically, its generally. Is there some sort of rule of thumb, or just mess with it till it works and still makes sense? x)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.