The Artima Developer Community
Sponsored Link

Agile Buzz Forum
A Comment on Arguments

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
A Comment on Arguments Posted: May 20, 2004 6:14 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: A Comment on Arguments
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement
One of the fragments that started in Have Compiler Will Travel the other day was this thing about reflectively documenting code. Lots of things to lots of people. And a whole holy war waiting in the wings as to how to do it and what worth it is. Let's avoid that here.

What it caused me to think about was method argument names. I sat and pondered what kinds of things a tool could infer from argument names. Kind of like how the class reporter used to use the class comment to figure things out about the use of its ivars IF you adhered to a certain syntax in your class comment. I realized I might be able to write a simple tool that extracted info from 90% of my method argument names if I so desired (no clue what I'd do with the information, but that's beside the point).

I write nearly all of my method argument names with a leading indefinite article (either "a" or "an"). And at the end, I almost always put a type. For example:

name: aString
	name := aString

or

getPngOr: aBlock
	^[self getPng] on: Error do: [:ex | ex returnWith: aBlock value]

Sometimes, I'm presented with a two arg method where the type is the same. So if I can, I might squeeze an "intent" word in there. Such as:

between: aLowNumber and: aHighNumber
	^self >= aLowNumber and: [self <= aHighNumber]

I've been known to be lazy and use A, B, C in place of the "intent" inserts too. Finally there's things where the arugment is a Collection of somethings. Usually in that I case I do something like:

longestUserNameIn: aCollectionOfStrings
	^aCollectionOfStrings inject: '' into: [:accum :each | accum size > each size ifTrue: [accum] ifFalse: [each]]

How do you name your arguments? Do you do something similiar? What--if any--value would be derived from being able to suck this information out? To me it seems that the variable is self documenting, but maybe someone's grand documentation unification schemes could benefit from something like this.

Read: A Comment on Arguments

Topic: NBC - hand them a cluestick Previous Topic   Next Topic Topic: Nifty Smalltalk projects

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use