As for context ... context objects, imho, should be used only when there is no other option. They are basically global variables, with all the pitfalls that entails without any of the benefits. Plus, there's a ton of bookkeeping involved and every single object needs to know about it, and possibly every single method. It is messy, dangerous, and ugly.
That depends on the implementation. If used correctly, a context object is just like a fancy OO way of giving arguments, one that allows you to do some more interesting stuff. Otherwise, you're definitely right.
For example, the MovableType guys created a 'stash' in their context object, that allows just anyone to put stuff in it, making it exactly the pitfall you described.
I'll say again that I only put it in the tutorial to 'float a phrase' and show what it might look like.
perl -e'$b=unpack"b*",pack"H*","59dfce2d6b1664d3b26cd9969503";\
for(;$a<length$b;$a+=9){print+pack"b8",substr$b,$a,8;}'
My public key
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|