Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: How do I go from procedural to object oriented programming?

by choroba (Cardinal)
on Apr 22, 2015 at 07:59 UTC ( [id://1124232]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How do I go from procedural to object oriented programming?
in thread How do I go from procedural to object oriented programming?

  1. My example was not a module, it was a script with an embedded package. package has a block scope, so to create a real module, only save the portion of the script that defines the package. The rest (including the %movies_data hash) belongs to the main package, i.e. to the script.
  2. I prefer to constrain values. You can add any values you need, but checking they belong to a given set can still help you: it will catch typos in newly added data and provide a list of all possible values when you're not sure what category to use.
  3. The same way as your code, i.e. there's no particular code related to the case (maybe because there's no such movie in the data?).
  4. It's possible. It can take some time, but it isn't hard.
  5. I haven't tested it, but I think so. I'm not aware of any 5.10+ features used in the code.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re^3: How do I go from procedural to object oriented programming?

Replies are listed 'Best First'.
Re^4: How do I go from procedural to object oriented programming?
by Lady_Aleena (Priest) on Apr 22, 2015 at 08:33 UTC
    1. Sorry, I thought you wrote a module and script. I did not realize it was only a script. It would be very painful to have to copy and paste almost everything from line 8 to line 213 (nearly 6kb) in the current module to every script which uses the 5 hash subroutines the module currently exports. Oh guh...
    2. I had not thought about setting things up within the subroutines to check for spelling errors. I usually do that with a scratchpad script to find things which do not not belong.
    3. *blushes* I did not think to add a movie with a tbd start date.
    4. So Moo has the path from regular OO to Moo in the docs which I can reverse engineer?

    Thank you very much.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
      Ad 1: I just tried to show an example. I certainly don't advise to copy and paste the same code into different places. In real life, you can have a module that populates the database, or whatever else solution you can think of.

      Ad 4: Once you understand Moo, you see the path. I doubt there's a step by step procedure described anywhere how to deMooify code.

      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      From your reply above: "It would be very painful to have to copy and paste almost everything from line 8 to line 213 (nearly 6kb) in the current module to every script which uses the 5 hash subroutines the module currently exports. Oh guh..."

      From your homepage: "I would like this to be the last time I have to defend my use of separated values. I try to stay away from the database topic as much as possible these days whenever it comes up."

      This is where databases fit into the picture. Start kicking and screaming.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2024-04-23 08:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found