Re: Beginner Tutorials for using CLASSES in PHP4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/9/07, Guillaume Theoret <smokinn@xxxxxxxxx> wrote:
>
> On 10/9/07, Tony Marston <tony@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > ""Nathan Nobbe"" <quickshiftin@xxxxxxxxx> wrote in message
> > news:7dd2dc0b0710091106n7f6f6c20i4997cd1fc606ffb4@xxxxxxxxxxxxxxxxx
> > > On 10/9/07, Tony Marston <tony@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> > >>
> > >>
> > >> ""Nathan Nobbe"" <quickshiftin@xxxxxxxxx> wrote in message
> > >> news:7dd2dc0b0710091015g7c29be93h671aa51bb125198e@xxxxxxxxxxxxxxxxx
> > >> > On 10/9/07, Robert Cummings <robert@xxxxxxxxxxxxx> wrote:
> > >> >>
> > >> >> Why would I use an interface? :)
> > >> >
> > >> > because inheritance is not always optimal.
> > >>
> > >> I have never found a prolem when using an interface was the only
> > >> solution,
> > >> or even ANY kind of solution. The fact that your designs need it
> speaks
> > >> volumes of the problems with your designs.
> > >
> > > im not the one whose been defending my designs  in this conversation;
> you
> > > are.
> >
> > But you are the one who keeps saying that your approach, where all
> member
> > variables are hidden, is far superior. I'm just saying that I do share
> that
> > opinion.
> >
> > > there are plenty of situations where the interface is the more elegant
> > > approach, thats why its here; and thats why it was added in php5.
> > >
> > >> There's your problem, then. You are wasting your time trying to
> implement
> > >> fancy design patterns just because design patterns are supposed to be
> > >> "cool".
> > >
> > > i dont recall reading any suggestions to use design patterns because
> they
> > > are cool.
> >
> > But you are the one who pointed out that interfaces are used in design
> > patterns, therefore they *must* be OK. I am saying that I have never
> seen
> > any advantages from using interfaces, and I don't waste my time with
> design
> > patterns.
> >
> > > infact the advice ive read is to only use them when they make sense.
> >
> > My point is that interfaces do not make anysense to me at all. I can
> access
> > all my class methods without them, so what benefit do they give?
> >
> > > Loader class, Controller Base class, Front Controller - I have none
> > >> of that crap in my code, so I don't encounter the problems you have.
> When
> > >> I
> > >> see code like "$this->load->library('email') " I just thank my lucky
> > >> stars
> > >> that I don't have to maintain it. I think some serious refactoring is
> > >> long
> > >> overdue.
> > >
> > > id have to say code igniter is quite a bit more popular than radicore.
> > > maybe youre the one who has some refactoring to do.
> > >
> > > Perhaps you are trying to implement something from another language
> and
> > >> expecting PHP to be just like that other language, which is always a
> > >> stupid
> > >> mistake. PHP is different, therefore the solution will be different.
> I
> > >> suggest you learn how PHP works and design accordingly, and stop
> trying
> > >> to
> > >> force it into emulating another language.
> > >
> > >
> > > well php has certainly gotten its influence from a number of other
> > > languages.
> > > where do you think the additional features in php5 got their
> inspiration
> > > from?
> >
> > Some of those features were implemented just because some a*sholes who
> are
> > more familiar with other languages keep saying "I can do so-and-so in
> > language X, and I want to do exactly the same thing in PHP". Language X
> has
> > interfaces, so PHP *must* have interfaces, Why? What purpose do they
> serve?
> > What benefits do they bring?
> >
> > > btw;
> > > heres the definition of implement from dictionary.com
> > >
> > > im·ple·ment
> > > <
> https://secure.reference.com/premium/login.html?rd=2&u=http%3A%2F%2Fdictionary.reference.com%2Fbrowse%2Fimplementation
> >
> > >  /n. '?mpl?m?nt; v. '?mpl??m?nt, -m?nt/ Pronunciation Key - Show
> Spelled
> > > Pronunciation[n. *im*-pl*uh*-m*uh*nt; v. *im*-pl*uh*-ment, -m*uh*nt]
> > > Pronunciation
> > > Key - Show IPA Pronunciation -noun 1.any article used in some
> activity,
> > > esp.
> > > an instrument, tool, or utensil: agricultural implements.
> > > notice the use of article; ie data; ie; you are wrong about member
> > > variables
> > > not being part of a classes implementation.
> > > if a variable local to a function can be considered part of its
> > > implementation; then a variable local to a class can be
> > > considered part of its implementation; its that simple.
> >
> > Implementation is still an activity or a procedure. A lawnmower is a
> tool
> > which implements lawnmowing, and it acts upon a lawn. However, the lawn
> is
> > not part of the implementation, it is the subject of the implementation.
> An
> > object may contain both variables and operations, but the data is not
> part
> > of those operations, it is the subject of those operations.
> >
> > --
> > Tony Marston
> > http://www.tonymarston.net
> > http://www.radicore.org
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> In response to:
>
> > My point is that interfaces do not make anysense to me at all. I can
> access
> > all my class methods without them, so what benefit do they give?
>
> We first sought to use interfaces in our new app when we were at the
> Best-Design-Ever stage but scaled them back more and more at each step
> of the development. We have pretty much completed the first version of
> the app (which contains maybe 90% of projected capability) and
> interfaces have pretty much been reduced to shells whose only purpose
> are to fake types to make error checking bearable.
>
> For example we have a rating plugin to which you can pass anything
> that implements the CanBeRated interface. The CanBeRated interface
> looks something like this:
> interface CanBeRated { }
>
> It used to have method definitions and whatnot inside but it was
> causing problems and was all-around useless so it got commented out.
> Implementing CanBeRated is really just saying yeah it makes sense to
> rate this stuff, I haven't passed this to you by accident. The rating
> plugin doesn't actually care what you pass it, it'll just add an entry
> into the ratings switchboard with the id of what was rated, the type
> (which is the class), the rating, who rated it and the date. So you
> can pass it any object really but just to make sure we don't end up
> with bizarre junk in our db we throw InvalidTypeExceptions if whatever
> was given doesn't implement CanBeRated.
>
> We do that in a few other spots too. It's handy to have if you want to
> fake types but not by any means necessary.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
i did this once to patch  up an area of an application is was working on.

i could see the interface being something like rateable with perhaps
a getRating() method or something; but of course i have no clue about
the details of the application.

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux