![]() |
|
Perl-Sensitive Sunglasses | |
PerlMonks |
Re^18: eval to replace die?by mithaldu (Monk) |
on Oct 09, 2010 at 16:02 UTC ( [id://864398]=note: print w/replies, xml ) | Need Help?? |
Just a simple real life example, derived from my day to day work: An application that deals with item prices delivered by third party servers (so, unknown ahead of time) and does a change check before each action that has to do with actual cash. If the price changes, it backs out and tells the user, with the message highlighted in red or green. Prices are displayed in full euro values at all times for brevity. With exceptions: die { type => 'PriceChange', amount => -123 }; The exception handler can recognize it by eq'ing the type and derive the direction from doing a numerical inspection of the amount and then shunt the whole thing through a template generator. With strings: die "PriceChange: The price changed by -123 Euro."; The exception handler does:
Both work fine. Now management decides: "We want the decimals displayed!" So the die errors get changed: die { type => 'PriceChange', amount => -123.45 }; die "PriceChange: The price changed by -123.45 Euro."; You see what happens, right? And just in case you try to argue "this code is dumb", yes it is. But let me assure you it's tame against the shit i've seen in production over the years. And lastly, i'm not going to try and address your wall of text at the bottom there. I dislike Java as well, i dislike OO as well and only use it when i can't think of a lispy way to do something. But i never labeled you as an OO-hater, you made that up on your own. I merely said that i think you're too busy hating Java to allow yourself to see that E::C has little to do with it at the core.
In Section
Seekers of Perl Wisdom
|
|