Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Right job for the tool.

by InfiniteSilence (Curate)
on May 28, 2014 at 14:09 UTC ( #1087654=note: print w/replies, xml ) Need Help??

in reply to Right job for the tool.

Aha! Good question (although I probably would have technically classified this as a Meditation).

My answer is this: you use OO programming techniques when the analysis methods you've used to scope the problem at hand make OO implementation a logical choice.

Let me elaborate. Some people believe that they are using OO programming when they are actually only utilizing one of the aspects of OO -- encapsulation. Although this is a good place to start this, by itself, is not OO programming.

There are may different approaches toward decent OO design, but the one that often makes sense to me goes something like this: identification of objects in a use case/story (nouns == objects; verbs == methods); sequence diagramming; and class diagrams. I've learned to despise using graphical tools to do this work so I started diagramming these in dot and most recently have switched to using PlantUML.

Here are a couple of problems doing this in Perl:

  • You shouldn't use heavy OO analysis for every problem. This is typically only necessary when the scope of the problem goes beyond several classes that need to work together or the problem space is fairly unfamiliar so it would be a good idea to do this analysis as an aid to learning.
  • The popular OO design paradigms are unfamiliar with CPAN and, as such, do not stress that you should actually go shopping for modules that fit your bill after identifying your needs but before programming. Evaluating someone else's code takes time which needs to be added to your overall timeframe.
  • Get into the habit of writing tests for your code early and often or you will learn how easy it is to need to make a change in one class that can totally destabilize your system.
  • There is a measure called cyclomatic complexity that can aid in maintainability. For instance, if you insist that all submitted coded methods have a complexity number of fewer than 20 for instance you will find it easier to understand code later on.
  • Alternatives exist to h2xs -XAn for building more complex hierarchies of classes. You might want to research ExtUtils::ModuleMaker or other utilities.
  • Have fun. OO analysis sucks and is boring when compared with writing interesting, terse pieces of code.

Celebrate Intellectual Diversity

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2022-01-25 13:58 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (66 votes). Check out past polls.