Re^5: How do I go from procedural to object oriented programming?
by jeffa (Bishop) on Apr 22, 2015 at 15:23 UTC
|
"Lady_Aleena is writing code to run under CGI ..."
I was wondering what you were on about there. My code is not meant to replace what the OP already has. This code is meant to demonstrate just one of the many ways you can translate the original code into objects. You don't have to use Moose. The OP doesn't have to use Moose. CGI was never mentioned and the only reason i chose to use Moose is because i am familiar and comfortable with it and i have no problem writing scalable applications with it. To borrow a quote: "In other words, I saw no good reason to expose novices to the core mechanism of object orientation."
Additionally, rather than merely dismissing a technology you should offer at least two replacements. You could have mentioned Moo or Mouse, or Class::Tiny or Role::Tiny ... but you offered no alternatives. You didn't even discuss using "the core mechanism," AKA:
package Object;
sub new { bless {}, shift }
1;
One of the key components in great software design is loose coupling -- if you think about, you are practicing tight coupling by adhering to some artificial requirement that the OP has to use CGI. That is 20th century technology and we are indeed living in the 21st century. Care to join us?
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
| [reply] [d/l] |
|
| [reply] |
|
| [reply] |
|
|
|
Re^5: How do I go from PROCEDURAL to object oriented programming?
by Anonymous Monk on Apr 22, 2015 at 03:10 UTC
|
| [reply] |
|
Eschew new technology so that you may cling to the past. That is not wise. http://perldancer.org There. Problem solved. :D What does that have to do with the bloat that is Moose?
The future runs on old technology, upgrades aren't free, pretending constraints don't exist is boring
| [reply] |
|
Anonymous Monk, my only constraints are Perl 5.8.8*, current versions of modules which still work with 5.8.8., and my own understanding of perl and programming in general. My goals for the present of still the same as you see on my home node and the list of things I need to get a grip on on my scratchpad.
* I have begged my web host and cPanel to use a newer version of Perl to no avail. Even 5.10 would be a big improvement. I loathe having to work under 5.8.8.
No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
Lady Aleena
| [reply] |
|
Perhaps YOUR future runs on old technology, but my future is so bright that I gotta wear shades.
Your attitude works well against Perl, by the way. In case you didn't notice those antiquated (and most likely monolithic) CGI scripts are being replaced around the globe with technologies based on Java, Python, Ruby and C#. What you suggest would further cause Perl to lose market share.
How you like them constraints?
| [reply] |
|
|
|
A reply falls below the community's threshold of quality. You may see it by logging in.
|
Re^5: How do I go from PROCEDURAL to object oriented programming?
by Anonymous Monk on Apr 22, 2015 at 16:15 UTC
|
"Lady_Aleena is writing code to run under CGI, Moose is too slow when run under CGI"
Her code just spits out HTML using methods that she wrote. The only time she actually uses CGI.pm is to gather query params, which is done by instantiating an OBJECT (oh the irony), not by importing into her namespace. She avoids CGI.pm generation methods in favor of her own home rolled ones -- which have a high potential for being more of a bottleneck than Moose under CGI. Moose under CGI is not going to have anywhere near the negative impact you are suggesting on her code. Making your classes immutable can often speed things up, by the way. The suggestion to use Dancer was spot-on.
Really -- what you should be preaching is: JUST SAY NO TO CGI.pm | [reply] |
|
| [reply] |
|
| [reply] |
|
|
|
|
... the only time she actually uses CGI.pm is to gather query params ... Who mentioned CGI.pm?
I was talking about Common Gateway Interface, the non-persistent execution environment
| [reply] |
|
You meant something barely anyone uses anymore and no one should use for at least ten years already.
Using Common Gateway Interface, the non-persistent execution environment, should be considered a misconfiguration.
Jenda
Enoch was right!
Enjoy the last years of Rome.
| [reply] |
|
You did. You clearly never mentioned Plack, which is where everyone now is.
| [reply] |
|
|
|