Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > OO and Inheritance

Reply
Thread Tools

OO and Inheritance

 
 
WelkinConsulting@gmail.com
Guest
Posts: n/a
 
      04-07-2005
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

 
Reply With Quote
 
 
 
 
John Bokma
Guest
Posts: n/a
 
      04-07-2005
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

 
Reply With Quote
 
 
 
 
WelkinConsulting@gmail.com
Guest
Posts: n/a
 
      04-07-2005
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:
> http://www.velocityreviews.com/forums/(E-Mail Removed) 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

=----

 
Reply With Quote
 
WelkinConsulting@gmail.com
Guest
Posts: n/a
 
      04-07-2005
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


 
Reply With Quote
 
Andrew S
Guest
Posts: n/a
 
      04-07-2005
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.

 
Reply With Quote
 
John Bokma
Guest
Posts: n/a
 
      04-08-2005
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 .

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
inheritance, multiple inheritance and the weaklist and instance dictionaries Rouslan Korneychuk Python 8 02-10-2011 04:02 AM
Interface inheritance vs Implementation inheritance. Daniel Pitts Java 27 02-27-2008 01:37 AM
Private Inheritance and Publice Inheritance karthikbalaguru C++ 9 09-10-2007 01:05 PM
mul. inheritance & overloading operator new/delete solved by virtual base inheritance? cppsks C++ 0 10-27-2004 07:49 PM
Private access modifier and Inheritance (Inheritance implementation in Java) maxw_cc Java 1 12-21-2003 11:38 AM



Advertisments