OO and Inheritance

  • Thread starter WelkinConsulting
  • Start date
W

WelkinConsulting

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
 
J

John Bokma

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 Abstract Factory/>
<http://www.pasteur.fr/formation/infobio/python/ch18s06.html>
 
W

WelkinConsulting

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 said:
-----------------------------------^^^^^^^^^^^^^^^^^^^
That can be remedied with the book "Object Oriented Perl" by Conway.

...
--
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
=----
 
W

WelkinConsulting

Thanks.

I make calls like

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

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

Andrew S

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.
 
J

John Bokma

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 :)

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,141
Latest member
BlissKeto
Top