OO and Inheritance

Discussion in 'Perl Misc' started by WelkinConsulting@gmail.com, Apr 7, 2005.

  1. Guest

    I have a question either about OO in general, or its implementation in
    Perl--I'm not sure which because I don't know enough.

    I've created the module Net::Browser::InternetExplorer. It drives an
    IE instance.

    I want to eventually create modules for driving other browsers--like
    Net::Browser::FireFox . I would like to be able to say, therefore:

    my $browser = Net::Browser->new( flavor => 'InternetExplorer', $URL );

    or

    my $browser = Net::Browser->new( flavor => 'FireFox', $URL );

    I've tried to figure out myself how to implement this, but I don't even
    know which OO concept or catchphrase I should be looking for! Thanks
    in advance for any references or examples.

    Andrew
    , Apr 7, 2005
    #1
    1. Advertising

  2. John Bokma Guest

    wrote:

    > I have a question either about OO in general, or its implementation in
    > Perl--I'm not sure which because I don't know enough.
    >
    > I've created the module Net::Browser::InternetExplorer. It drives an
    > IE instance.
    >
    > I want to eventually create modules for driving other browsers--like
    > Net::Browser::FireFox . I would like to be able to say, therefore:
    >
    > my $browser = Net::Browser->new( flavor => 'InternetExplorer', $URL );
    >
    > or
    >
    > my $browser = Net::Browser->new( flavor => 'FireFox', $URL );


    Or

    my $browser = Net::Browser::Firefox( $url );
    my $browser = Net::Browser::InternetExplorer( $url );

    Is there a reason why you want to pass it as a parameter? If so, it
    sounds like you want to do something with plug ins, e.g.

    Otherwise, in the new of Net::Browser you try to use
    Net::Browser::YourBrowser, if ok, you call new, and return the instance.

    > know which OO concept or catchphrase I should be looking for!


    Factory:

    <http://www.vico.org/pages/PatronsDisseny/Pattern%20Abstract%20Factory/>
    <http://www.pasteur.fr/formation/infobio/python/ch18s06.html>

    --
    John Small Perl scripts: http://johnbokma.com/perl/
    Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
    John Bokma, Apr 7, 2005
    #2
    1. Advertising

  3. Guest

    OK. Let's say I read that book cover to cover (I have read bits and
    pieces of it). Which sections or concepts should I pay particular
    attention to?

    Thanks.

    Andrew

    Bob Walton wrote:
    > wrote:
    >
    > > I have a question either about OO in general, or its implementation

    in
    > > Perl--I'm not sure which because I don't know enough.

    > -----------------------------------^^^^^^^^^^^^^^^^^^^
    > That can be remedied with the book "Object Oriented Perl" by Conway.
    >
    > ...
    > > Andrew

    > --
    > Bob Walton
    > Email: http://bwalton.com/cgi-bin/emailbob.pl
    >
    > ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet

    News==----
    > http://www.newsfeeds.com The #1 Newsgroup Service in the World!

    120,000+ Newsgroups
    > ----= East and West-Coast Server Farms - Total Privacy via Encryption

    =----
    , Apr 7, 2005
    #3
  4. Guest

    Thanks.

    I make calls like

    my $browser = Net::Browser::InternetExplorer( $url );

    presently--I just thought that passing in the browser variety would be
    cleaner.


    John Bokma wrote:
    > wrote:
    >
    > > I have a question either about OO in general, or its implementation

    in
    > > Perl--I'm not sure which because I don't know enough.
    > >
    > > I've created the module Net::Browser::InternetExplorer. It drives

    an
    > > IE instance.
    > >
    > > I want to eventually create modules for driving other

    browsers--like
    > > Net::Browser::FireFox . I would like to be able to say, therefore:
    > >
    > > my $browser = Net::Browser->new( flavor => 'InternetExplorer', $URL

    );
    > >
    > > or
    > >
    > > my $browser = Net::Browser->new( flavor => 'FireFox', $URL );

    >
    > Or
    >
    > my $browser = Net::Browser::Firefox( $url );
    > my $browser = Net::Browser::InternetExplorer( $url );
    >
    > Is there a reason why you want to pass it as a parameter? If so, it
    > sounds like you want to do something with plug ins, e.g.
    >
    > Otherwise, in the new of Net::Browser you try to use
    > Net::Browser::YourBrowser, if ok, you call new, and return the

    instance.
    >
    > > know which OO concept or catchphrase I should be looking for!

    >
    > Factory:
    >
    >

    <http://www.vico.org/pages/PatronsDisseny/Pattern%20Abstract%20Factory/>
    > <http://www.pasteur.fr/formation/infobio/python/ch18s06.html>
    >
    > --
    > John Small Perl scripts: http://johnbokma.com/perl/
    > Perl programmer available: http://castleamber.com/
    > Happy Customers: http://castleamber.com/testimonials.html
    , Apr 7, 2005
    #4
  5. Andrew S Guest

    Create a base class called Net::Browser::Base with default methods.
    Then write Net::Browser::InternetExplorer to inherit from
    Net::Browser::Base and override pertinent defaults. At that point you
    can write Net::Browser::FireFox and override the defaults in different
    ways.

    Read all the Perl documentation on object oriented programming. Pay
    attention to the parts that you understand. Then go back and read it
    again, paying attention to the parts that you understand better in
    light of your first reading. Then read it again. In between readings,
    do as much programming as you can.
    Andrew S, Apr 7, 2005
    #5
  6. John Bokma Guest

    wrote:

    > OK. Let's say I read that book cover to cover (I have read bits and
    > pieces of it). Which sections or concepts should I pay particular
    > attention to?


    The part talking about Netiquette. Ah! You are not talking about a book on
    Usenet :)

    >> That can be remedied with the book "Object Oriented Perl" by Conway.


    I normally recommend to read a book cover to cover, not bits and pieces.
    And then read it again and make notes :-D.

    --
    John Small Perl scripts: http://johnbokma.com/perl/
    Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
    John Bokma, Apr 8, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. maxw_cc
    Replies:
    1
    Views:
    3,116
    Martijn van Steenbergen
    Dec 21, 2003
  2. cppsks
    Replies:
    0
    Views:
    802
    cppsks
    Oct 27, 2004
  3. karthikbalaguru
    Replies:
    9
    Views:
    1,025
  4. Daniel Pitts
    Replies:
    27
    Views:
    1,873
    Mike Schilling
    Feb 27, 2008
  5. Rouslan Korneychuk
    Replies:
    8
    Views:
    586
    Rouslan Korneychuk
    Feb 10, 2011
Loading...

Share This Page