Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
The details are pretty meaningless, but it's a small SQL database containing Quotes of the Day kind of thing.
All that's needed is to connect to an SQL DB, and edit, save, add and delete quotes via a web front end.
It would normally take me a couple of hours to fix the whole thing up, but the person I'm writing it for likes the code to be object-oriented.
I don't need details of exactly the code I'd use, but I have to admit I still don't really get the OO philosophy.
Here's what I'd probably do for a script like that:
- create a script
- feed it a "mode" via the form/query string every time like "if($mode eq 'edit'){ open the db, get record x, populate the fields }" or "if($mode eq 'save'){ open the db, put the field contents into record x}" and so on, the default mode being "none of the above" or start-up mode.
- create the right forms and HTML code for each "mode".
What's the OO way to approach a simple task like that? I need to make everything into a function, essentially, and then call the functions as methods of the objects? So what are my objects?
As you can see, I've got a mental block about this -- I really see the whole thing as procedures, so I'm hoping my fellow monks can help me translate that into Objects with Methods.
--
($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;