I always write modules with OO interfaces (instead of exporting functions), but I find that only about 1/5 of my modules actually count as real OO. What does this mean? It means I use new and self, but other than keeping track of instance data, I'm not using any major OO constructs. Just using new means I don't have to pass the same datastructure argument to each function in my module each time. So that's pretty basic. My modules are usually more indicative of functional (do *not* read as "procedural") programming than OO itself.
Code-reuse is not really something that is unique to object oriented development, and it's a shame that people think OO invented code-reuse. It did not. In the wrong hands, OO subclassing actually allows for reuse-avoidance, or even copy-and-paste development in a politically correct format. Furthermore, it is a shame that the philosophy-of-uber-inheritance is so tightly coupled with OO thought that most OO programs instantly grow a tremendous class-hierachy. This too, need not be the case.
Anyhow, OO is fine -- but don't think it's about reuse or maintainability or massive inheritance hierachies or anything like that. It's mostly about state and clean interfaces -- or, at least -- that's how it SHOULD be. The number of real world problems correctly modelled by massive inheritance trees are few and far between.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|