OOP php user system

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yorian

    #31
    Re: OOP php user system

    On Nov 15, 12:34 pm, Gordon <gordon.mc...@n tlworld.comwrot e:
    On Nov 9, 1:08 pm, Yorian <yorianbenja... @hotmail.comwro te:
    >
    >
    >
    Hey,
    >
    Although I've been using classes and object for quite a while now I've
    never actually programmed proper OO code yet. It ofcourse depends on
    what you call proper OO code. I have been seperating parts of the
    website. Like a user class, guestbook class, etc. But I've been
    putting all the code in one single class instead of of spreiding it.
    >
    Since a short while I've been reading up on OOP and now I am trying to
    actually do things the way they should be done to make a nice
    maintainable module. Which in fact means that I'm trying to stick to
    some rules: Don't repeat yourself, seperation of concerns,
    encapsulation, etc.
    >
    I've created (not finished just started it) a user system, this
    according to the mvc pattern. The names for the classes aren't perfect
    (user should actually be named userController, and userData should be
    named user, etc.).
    >
    Could any of you guys have a look and see if I'm going in the right
    direction?
    >
    The few classes (put in a single file for the sake of easy reading)
    can be found here:http://web-develop.nl/user_oop.phps
    >
    Hope you guys can give me some useful comments.
    >
    Thanks
    >
    I noticed with an (admittedly quick) glance at your code that you have
    a couple of functions with switch statements that contain long blocks
    of inline code.  May I suggest instead of having that code inline you
    move the content of each case statement into its own private
    function?  That way if you need to do the task associated with each
    case somewhere else in the class you can just call the function
    instead of duplicating code, and if a need arises later on for some
    other part of the program to do that task you can change the function
    to protected or public.  Also, from a purely aesthetic point of view I
    tend to favour shorter functions, but that's just my personal taste. :)
    Thnx Gordon,

    that's not such a bad idea, I will have a look at it.

    Comment

    Working...