Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Here, here!

Whilst I want my code to be self-documenting, extraneous "little" words in sub and variable names do "little" to enhance this IMO too.

That's probably the strongest argument for properly executed overloading.

if ( $current_token == $token ) {...} where $current_token is an object of a class Token that overloads the == operator and does the right thing would be so much more intuative I think.

To my way of thinking, overloading is more useful than inheritance for giving clarity, especially when the latter is taken too far. Java's propensity to use inheritance rather than attributes combined with the need for (which this practice in part generates) long, unweildy class and method names leading to stuff like

Reader in = BufferedReader( UnbufferedReader( Stream( filename ).getStreamHandle()) );

drives me nuts:^) (That's from memory, inaccurate and an exaggeration, but it makes my point).

It's also part of the reasoning behind my desire for lvalue subs (with appropriate mechanisms for preinspection and rejection of assignment attempts), for use as assessor/mutator methods. Having to write

my $point = new Point(); $point->set_X( 3 ); $point->set_Y( 4 ); .... my $start_point = new Point; $start_point = $point.copy(); $point->set_X( $point->get_X() + 1 ) while $image->get_color_at($point) == RED; my $end_point = new Point(); $end_point = $point->copy(); $image->draw_line_from_to( $start_point, $end_point, BLACK );

When it could be

my $point = new Point(3, 4); ... my $start_point = $point; $point->X++ while $image->color_at($point) == RED; # or even $point-> +X = point->X + 1 my $end_point = $point; $image->line( $start_point, $end_point, BLACK );

seems unnecessarially unweildy to me.


Examine what is said, not who speaks.


In reply to Re: Re: $bad_names eq $bad_design by BrowserUk
in thread $bad_names eq $bad_design by Ovid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-23 15:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found