Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Best OOP strategy?

by agentv (Friar)
on Aug 16, 2002 at 20:54 UTC ( [id://190751]=note: print w/replies, xml ) Need Help??


in reply to Best OOP strategy?

...not to flog a limping horse here, but I feel compelled to reiterate a couple of things already said here, and to add a couple of thoughts.

First of all, if your reason for going to OO is speed, forget it. That's not the reason we do it. In fact, most of the time we lose a little bit of efficiency when we use an OO approach because there is typically a level of indirection in the design.

Example: If I simply stat() a file to get some information, it's reasonably fast. If I create an object to help me with this, I call one of my object's methods, it calls stat() on my behalf, it assembles the return values into a data structure that I access through my other object methods. I might need to make two function calls myself, and my object may have to make yet another function call.

There is speed in OO programming, but it's development time speed. You can write your code faster sometimes, and you can usually integrate it or enhance it much more rapidly than with a simple structured linear design.

Perhaps a pithier way to say this is that OO programming won't make your program run faster, but it will make you able to add features faster.

On the other hand, if you are planning to write a system that needs 10000 lines of code, you probably do need to consider taking the Object approach. (Though if you write 10000 lines of good Perl, you should get something as substantial as an operating system in my opinion.)

Read what the others have suggested here. There are good references you can read, not only about how to do OO programming in Perl, but also about the principles of design.

If I could distill it to one phrase, it would be this: "Start with the data." If you do a careful analysis of what your data structures should look like, and what will happen to them, then the code will not necessarily write itself, but it will "lay down real nice-like."

In addition to books and tutorials you can read on the subject, study the code from some good examples (and bad examples) of systems that are developed in this manner. Many such examples are present on this system.

But whatever you do, have fun, and don't be shy about getting started. The best way to figure this stuff out is to do some yourself and inspect good examples of how others have done it.

...All the world looks like -well- all the world, when your hammer is Perl.
---v

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://190751]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2024-04-26 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found