From: Andy C. <bng...@gm...> - 2009-09-02 18:16:51
|
As much as I might not approve of the last example you gave, it should work. In your example in your first message: $Profile = new Profile(); both names are in upper case. In the second example you gave: $profile = new Profile() they have different case so it should work. Just an observation. Do what you gotta do. PEACE!!!!!, Andy Carlson Carlson Technology (815) 200-9303 41° 22' 35" N 89° 28' 10" W --------------------------------------------------- "Man's conquest of Nature turns out, in the moment of its consummation, to be Nature's conquest of Man." -- C.S. Lewis --------------------------------------------------- "The ubiquity of the Internet is more important than the technology of the Internet" -- Jeff Bezos --------------------------------------------------- try { succeed(); } catch(E) { tryAgain(); } finally { readManual(); } On Wed, Sep 2, 2009 at 11:33 AM, Arlo Leach <ar...@ar...> wrote: > > It'd be really confusing code with those similar names. > > > Yes, it is kind of crazy: you're deliberately obfuscating your own code. > > Using the same name two different ways is shooting yourself in the > > foot. I'm a lousy typist myself, but it would never occur to me to > > try something like this. > > All right, thanks for the sanity check. I could to something like > $objProfile or $obj_profile, but I've always stayed away from that > Hungarian > notation kind of approach. > > The most common situation I've run into is that one variable name describes > both an object and a member in a related class. For example, I have > subscribers and some subscribers have profiles. Here's a super-simplified > example: > > $subscriber = new Subscriber(); > $profile = $subscriber->getValue("profile"); > $profile = new Profile($profile); // oops, now $profile is ambiguous > > Since the profile member in the Subscriber class is a pointer to a separate > Profile record, I guess most people would call that $profile_id. That's > almost like Hungarian notation to me and I've never had the need to do that > before. But now that I'm using objects a lot, my namespace has to > accommodate one more type of data than before, so something has to give. > > By the way, I could just access $subscriber->profile rather than creating a > local variable for $profile, but I like making the class members protected > so I'm not tempted to set them directly and bypass any internal > functionality in the class. If I could make the members read-only, that > would work -- but PHP doesn't offer that, right? > > Cheers, > -Arlo > > _______________________________ > > Arlo Leach > 773.769.6106 > http://arlomedia.com > > > > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > chiPHPug-discuss mailing list > chi...@li... > https://lists.sourceforge.net/lists/listinfo/chiphpug-discuss > |