Re: OT::Re: OOP php user system

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

    Re: OT::Re: OOP php user system

    I'm with FutureShock, both of you guys got a little too heated. But it
    livened up my midday a bit, for what it's worth.

    Thomas

    On Nov 10, 10:02 pm, FutureShock <futuresho...@a tt.netwrote:
    Jessica Griego wrote:
    "FutureShoc k" <futuresho...@a tt.netwrote in message
    news:sS4Sk.6670 $c45.2535@nlpi0 65.nbdc.sbc.com ...
    Jessica Griego wrote:
    >"Jerry Stuckle" <jstuck...@attg lobal.netwrote in message
    >>news:gf9pe9$s pc$1@registered .motzarella.org ...
    >>703designs wrote:
    >>>On Nov 10, 11:11 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
    >>>>Jessica Griego wrote:
    >>>>>"Jerry Stuckle" <jstuck...@attg lobal.netwrote in message
    >>>>>>news:gf9j et$nn4$2@regist ered.motzarella .org...
    >>>>>>703design s wrote:
    >>>>>>>On Nov 10, 6:02 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
    >>>>>>>>703desi gns wrote:
    >>>>>>>>>On Nov 9, 11:28 pm, "Jessica Griego" <j...@example.c omwrote:
    >>>>>>>>>>"703d esigns" <thomasmal...@g mail.comwrote in message
    >>>>>>>>>>>news :87a79792-c2b5-477a-8376-774d3951453f@a2 6g2000prf.googl egroups.com...
    >>>>>>>>>>On Nov 9, 10:46 pm, 703designs <thomasmal...@g mail.comwrote:
    >>>>>>>>>>>On Nov 9, 10:37 pm, "Jessica Griego" <j...@example.c omwrote:
    >>>>>>>>>>>>"Yo rian" <yorianbenja... @hotmail.comwro te in message
    >>>>>>>>>>>>>ne ws:8b1c4864-385d-45fa-bb75-3b9d2b736532@t3 9g2000prh.googl egroups.com...
    >>>>>>>>>>>>>He y,
    >>>>>>>>>>>>>Al though I've been using classes and object for quite a while
    >>>>>>>>>>>>>no w
    >>>>>>>>>>>>>I' ve
    >>>>>>>>>>>>>ne ver actually programmed proper OO code yet. It ofcourse
    >>>>>>>>>>>>>de pends
    >>>>>>>>>>>>> on
    >>>>>>>>>>>>>wh at you call proper OO code. I have been seperating parts of
    >>>>>>>>>>>>>th e
    >>>>>>>>>>>>>we bsite. Like a user class, guestbook class, etc. But I've
    >>>>>>>>>>>>>be en
    >>>>>>>>>>>>>pu tting all the code in one single class instead of of
    >>>>>>>>>>>>>sp reiding
    >>>>>>>>>>>>>it .
    >>>>>>>>>>>>>Si nce a short while I've been reading up on OOP and now Iam
    >>>>>>>>>>>>>tr ying
    >>>>>>>>>>>>> to
    >>>>>>>>>>>>>ac tually do things the way they should be done to make a nice
    >>>>>>>>>>>>>ma intainable module. Which in fact means that I'm trying to
    >>>>>>>>>>>>>st ick
    >>>>>>>>>>>>> to
    >>>>>>>>>>>>>so me rules: Don't repeat yourself, seperation of concerns,
    >>>>>>>>>>>>>en capsulation, etc.
    >>>>>>>>>>>>>I' ve created (not finished just started it) a user system,
    >>>>>>>>>>>>>th is
    >>>>>>>>>>>>>ac cording to the mvc pattern. The names for the classes
    >>>>>>>>>>>>>ar en't
    >>>>>>>>>>>>>pe rfect
    >>>>>>>>>>>>>(u ser should actually be named userController, and userData
    >>>>>>>>>>>>>sh ould
    >>>>>>>>>>>>> be
    >>>>>>>>>>>>>na med user, etc.).
    >>>>>>>>>>>>>Co uld any of you guys have a look and see if I'm going inthe
    >>>>>>>>>>>>>ri ght
    >>>>>>>>>>>>>di rection?
    >>>>>>>>>>>>>Th e few classes (put in a single file for the sake of easy
    >>>>>>>>>>>>>re ading)
    >>>>>>>>>>>>>ca n be found here:http://web-develop.nl/user_oop.phps
    >>>>>>>>>>>>>Ho pe you guys can give me some useful comments.
    >>>>>>>>>>>>T he thing I like most, Yorian, is that it is well formatted! I
    >>>>>>>>>>>>don 't
    >>>>>>>>>>>>kno w
    >>>>>>>>>>>>wha t language the comments are in, however I do recognize
    >>>>>>>>>>>>'si ngleton'.
    >>>>>>>>>>>>F or
    >>>>>>>>>>>>t he classes that are singletons, you need to make the
    >>>>>>>>>>>>__c onstructor
    >>>>>>>>>>>>a
    >>>>>>>>>>>>pri vate function and use the 'static' keyword for the other
    >>>>>>>>>>>>fun ctions/variables in the class. You'd necissarily need away
    >>>>>>>>>>>>t o
    >>>>>>>>>>>>sup ply
    >>>>>>>>>>>>tho se singletons the constructor args. You can either let the
    >>>>>>>>>>>>cal ler
    >>>>>>>>>>>>s et
    >>>>>>>>>>>>t he
    >>>>>>>>>>>>val ues via 'setters' and/or create a static function, like
    >>>>>>>>>>>>'in itialize',
    >>>>>>>>>>>>tha t essentially carries out the responsibility of
    >>>>>>>>>>>>__c onstruct. You
    >>>>>>>>>>>>sho uld
    >>>>>>>>>>>>als o think about defining __clone, __copy, etc. specifically
    >>>>>>>>>>>>a s
    >>>>>>>>>>>>pri vate
    >>>>>>>>>>>>s o
    >>>>>>>>>>>>tha t you are guaranteed not to have more than one instanceof
    >>>>>>>>>>>>t he
    >>>>>>>>>>>>sin gleton.
    >>>>>>>>>>>>Aga in, I like the code most because I can readily tell what it
    >>>>>>>>>>>>i s
    >>>>>>>>>>>>doi ng...because it is well formatted. Above all, that will
    >>>>>>>>>>>>sav e
    >>>>>>>>>>>>tim e,
    >>>>>>>>>>>>mon ey,
    >>>>>>>>>>>>a nd frustration when you need to add to it or modify it in
    >>>>>>>>>>>>som e way
    >>>>>>>>>>>>i n
    >>>>>>>>>>>>t he
    >>>>>>>>>>>>fut ure.
    >>>>>>>>>>>>Che ers
    >>>>>>>>>>>Inst ead of using all of those getAttribute methods, you could
    >>>>>>>>>>>us e a
    >>>>>>>>>>>gene ric __get method that returns the attribute.
    >>>>>>>>>>>Thom as
    >>>>>>>>>>Ah, my fault, it's late. I meant that you can use __get to point
    >>>>>>>>>>to
    >>>>>>>>>>tho se methods automatically using call_user_func. So that
    >>>>>>>>>>$user Instance->last_name would call that method.
    >>>>>>>>>>===== ===
    >>>>>>>>>>IMO , that's very bad advice. __get and __set only get executed
    >>>>>>>>>>whe n a
    >>>>>>>>>>calle r
    >>>>>>>>>>tri es to access an *undefined* interface. You're abusing the
    >>>>>>>>>>actua l
    >>>>>>>>>>inten t
    >>>>>>>>>>of __get/set. It makes it terribly hard to debug and manage.It
    >>>>>>>>>>doesn 't
    >>>>>>>>>>all ow you to strongly type the input(s) or output(s). It's also
    >>>>>>>>>>a
    >>>>>>>>>>perfo rmance hit. Further, you should notice tools like php
    >>>>>>>>>>docum entor
    >>>>>>>>>>and
    >>>>>>>>>>any screen dump of the object would not accurately show any
    >>>>>>>>>>valid ation
    >>>>>>>>>>for
    >>>>>>>>>>the properties being set. I'd think about always being specific
    >>>>>>>>>>and
    >>>>>>>>>>not try
    >>>>>>>>>>to rig the jury to obtain the get/set functionality that is
    >>>>>>>>>>suppl ied
    >>>>>>>>>>by
    >>>>>>>>>>oth er oop languages. __get and __set are NOT php's version of
    >>>>>>>>>>oth er
    >>>>>>>>>>langu ages' get/set construct.
    >>>>>>>>>Sorr y, Python's my first language and this sort of thing works
    >>>>>>>>>very
    >>>>>>>>>cleanl y there. I'll keep these drawbacks in mind: I guess that
    >>>>>>>>>__get' s
    >>>>>>>>>not quite ready for primetime.
    >>>>>>>>>Thom as
    >>>>>>>>In addition, the generic __get and __set methods are contrary to
    >>>>>>>>good OO
    >>>>>>>>desig n, even in Python.
    >>>>>>>>Part of good OO design is to keep separate things separate - that
    >>>>>>>>include s attributes.  Independent getter and setter methods,while
    >>>>>>>>a
    >>>>>>>>paid to code, do this quite nicely.  They also allow for easier
    >>>>>>>>validat ion/massage of the data.  A single __get/__set methodpair
    >>>>>>>>does
    >>>>>>>>not do this.
    >>>>>>>>--
    >>>>>>>>======= ===========
    >>>>>>>>Remov e the "x" from my email address
    >>>>>>>>Jerry Stuckle
    >>>>>>>>JDS Computer Training Corp.
    >>>>>>>>jstuck. ..@attglobal.ne t
    >>>>>>>>======= ===========
    >>>>>>>I never said that a single get/set pair should do that. Another
    >>>>>>>part
    >>>>>>>of good OO design is to not reference object attributes directly,
    >>>>>>>but
    >>>>>>>rather to always have getter and setter methods.
    >>>>>>>Thomas
    >>>>>>Then if each attribute has it's own get/set pair (as in good OO
    >>>>>>design) ,
    >>>>>>there is no need for the __get/__set methods.
    >>>>>>That's why you won't find them in good OO languages such as
    >>>>>>SmallTalk ,
    >>>>>>Java and even C++.
    >>>>>Jerry, Jerry, Jerry!
    >>>>>The 'need' could be as simple as convenience! OOP languages bind
    >>>>>getters and
    >>>>>setters directly into the properties available to the caller...such
    >>>>>that:
    >>>>Convenien ce != good design!  There is nothing to replace a good
    >>>>design.
    >>>>  Your "convenienc e" is just plain laziness.
    >
    >>>>>object.pro perty = something // initiates a __set
    >>>>>and
    >>>>>print object.property       // initiates a __get
    >>>>Good OO design does not allow such actions.
    >
    >>>>>That's not so hard to understand! And while Java and C++ fit the
    >>>>>bill, I
    >>>>>hardly would hold SmallTalk up as a beacon for OOP! However, ALL of
    >>>>>those
    >>>>>language s operate in the way I've just displayed. Thomas is simply
    >>>>>trying to
    >>>>>coerse php to do what the rest of us hope it eventually will...give
    >>>>>us the
    >>>>>same or similar constructs.
    >>>>SmallTalk is a good OO language.  But NONE of them operate in the way
    >>>>you would like.  If property is private, as it should be, then
    >>>>object.prop erty (unless in a member function) will cause a compile
    >>>>time
    >>>>error.
    >
    >>>>>BTW, quit accusing Thomas of bad design! If you read his suggestion,
    >>>>>you'd
    >>>>>have noticed that he's not balling up all of his validation in
    >>>>>__get/set as
    >>>>>you've twice accused him of. He suggested using php's call user func
    >>>>>function.. .I said it could be as easy as a switch statement and a
    >>>>>direct
    >>>>>call to the getter/setter. Thus far, your arguments are MOOT. You've
    >>>>>only to
    >>>>>state that "there is no need for the __get/__set methods" (if you've
    >>>>>already
    >>>>>defined getters/setters). Ok then! Statement noted.
    >>>>We already know how you program.  Your previous "answer" is proof of
    >>>>that.
    >
    >>>>>Do you ever offer advice that actually further's someone's
    >>>>>understand ing of
    >>>>>php or help better the content of a thread in which you've posted,
    >>>>>Jerry? I
    >>>>>can't see that you do.
    >>>>ROFLMAO.  This from some newbie who doesn't have any idea what good
    >>>>programmi ng is all about.
    >
    >>>>--
    >>>>=========== =======
    >>>>Remove the "x" from my email address
    >>>>Jerry Stuckle
    >>>>JDS Computer Training Corp.
    >>>>jstuck...@a ttglobal.net
    >>>>=========== =======
    >>>First of all, don't go flinging crap like "newbie" around here. You'll
    >>>only piss others off.
    >
    >>So show me...
    >
    read more »
Working...