[Newbies] names for boolean keyword arguments
Norbert Hartl
norbert at hartl.name
Sat Sep 27 01:19:55 UTC 2008
On Fri, 2008-09-26 at 18:05 -0700, Randal L. Schwartz wrote:
> >>>>> "Norbert" == Norbert Hartl <norbert at hartl.name> writes:
>
> Norbert> There is no strict rule to it but I think here the majority
> Norbert> follows some "hint what to expect" rule. That means you name
> Norbert> the argument after the class of the argument.
>
> Norbert> expensive: anExpensive
>
> If I recall, according to Smalltalk Best Practice Patterns (the seminal
> patterns book for Smalltalk), you want the attribute to be of the form
> "isProperty":
>
> isExpensive := true.
>
> which means that "expensive:" shouldn't be a setter. In fact, said book
> states that you should have "be" methods:
>
> anObject beExpensive
> anObject beCheap
>
> which would likely set isExpensive to true and false respectively, perhaps,
> or even 2 states out of a 3-state variable. Encapsulation! Because
> then you also have tests:
>
> anObject isExpensive ifTrue: [ ... ]
>
> or even (if you use it a lot):
>
> anObject ifExpensive: [ ... ]
>
> I've often argued that automatic creation of getters and setters is wrong.
> This is clearly an example of where automatic getters and setters lead you to
> bizarre code.
>
Yes and even the grammar was bad :) I was just answering his question.
Did you read at least the subject?
Norbert
More information about the Beginners
mailing list