Teaching pharo too late yesterday, headache now. I will reply.
Now you probably see that I’m learning and changing my mind :) Stef
|
In reply to this post by Tim Mackinnon
Some examples of testing methods verb prefixes I use:
shouldXxx (#shouldOverwrite) isXxx (#isEmpty #isNil hasXxx (#hasContents) canXxx (#canDeleteProperty) usesXxx (#usesDirectTransfer) containsXxx (#containsPlots) definesXxx (#definesGlobals) didXxx (#didRemoveFiles) willXxx (#willCreateNewAssets) I'm in favor of having more symbols available as binary selectors, but I don't see the use of ? and ! as unary selectors other than the technical challenge of making the change, with the added burden of breaking compatibility. In a perfect world no testing is required and everything is solved by delegation, but we all know that sometimes the added complexity is not worth it. Regards, Esteban A. Maringolo On Fri, Sep 13, 2019 at 9:00 AM Tim Mackinnon <[hidden email]> wrote: > > +1 for #shouldXxx I recall I use it a lot too, and #isXxx where that reads better but am struggling for examples. > > Tim > > Sent from my iPhone > > On 13 Sep 2019, at 02:37, Mariano Martinez Peck <[hidden email]> wrote: > > > > On Wed, Sep 11, 2019 at 4:10 AM ducasse <[hidden email]> wrote: >> >> >> >> > On 11 Sep 2019, at 04:07, James Foster <[hidden email]> wrote: >> > >> > Would use of ? and ! in unary/keyword selectors be convention or somehow required? If simply convention, then we should start with renaming testing methods to be named is* or has*. >> > flag1 := anInteger even. “not good" >> > flag2 := anInteger isEven. “better" >> > flag3 := anInteger even?. “how much better?” >> > flag4 := #(1 2 3) includes?: 2. “how much better?” >> >> I think that I would use ? mainly for unary message >> >> Now I’m sure that if you look carefully some people use >> >> include >> for the action >> includes >> for the tests >> >> I took include as an example and this is super not intention revealing. >> >> >> lineUpBlockBrackets >> >> lineUpBlockBrackets? >> Now I will rewrite them all as shouldLineUpBlockBrackets or isLineUpBlockBrackets and to me for unary message ? makes it a lot better. >> > > Hi Stef, > > I have been facing this ambiguity a lot too. And my workaround, most of the times, was also to prefer the "question" method with #should. #is just doesn't sound right in my cases, but #should does sound good in most of them. I would still like to find a better one, but for the moment, in my recent years, I am stuck with #should. > > -- > Mariano Martinez Peck > Email: [hidden email] > Twitter: @MartinezPeck > LinkedIn: www.linkedin.com/in/mariano-martinez-peck > Blog: https://marianopeck.wordpress.com/ |
> On 13 Sep 2019, at 14:11, Esteban Maringolo <[hidden email]> wrote: > > Some examples of testing methods verb prefixes I use: > > shouldXxx (#shouldOverwrite) > isXxx (#isEmpty #isNil > hasXxx (#hasContents) > canXxx (#canDeleteProperty) > > didXxx (#didRemoveFiles) > willXxx (#willCreateNewAssets) this is for the following ones that I do not like that the only difference between an action and a question is an s > usesXxx (#usesDirectTransfer) > containsXxx (#containsPlots) > definesXxx (#definesGlobals) > > I'm in favor of having more symbols available as binary selectors, but > I don't see the use of ? and ! as unary selectors other than the > technical challenge of making the change, with the added burden of > breaking compatibility. > > In a perfect world no testing is required and everything is solved by > delegation, but we all know that sometimes the added complexity is not > worth it. :) If only For the pretty printer we have around 30 different parameters. I do not imagine my self having 30 classes to which I would delegate something. > > Regards, > > Esteban A. Maringolo > > On Fri, Sep 13, 2019 at 9:00 AM Tim Mackinnon <[hidden email]> wrote: >> >> +1 for #shouldXxx I recall I use it a lot too, and #isXxx where that reads better but am struggling for examples. >> >> Tim >> >> Sent from my iPhone >> >> On 13 Sep 2019, at 02:37, Mariano Martinez Peck <[hidden email]> wrote: >> >> >> >> On Wed, Sep 11, 2019 at 4:10 AM ducasse <[hidden email]> wrote: >>> >>> >>> >>>> On 11 Sep 2019, at 04:07, James Foster <[hidden email]> wrote: >>>> >>>> Would use of ? and ! in unary/keyword selectors be convention or somehow required? If simply convention, then we should start with renaming testing methods to be named is* or has*. >>>> flag1 := anInteger even. “not good" >>>> flag2 := anInteger isEven. “better" >>>> flag3 := anInteger even?. “how much better?” >>>> flag4 := #(1 2 3) includes?: 2. “how much better?” >>> >>> I think that I would use ? mainly for unary message >>> >>> Now I’m sure that if you look carefully some people use >>> >>> include >>> for the action >>> includes >>> for the tests >>> >>> I took include as an example and this is super not intention revealing. >>> >>>>> lineUpBlockBrackets >>> >>> lineUpBlockBrackets? >>> Now I will rewrite them all as shouldLineUpBlockBrackets or isLineUpBlockBrackets and to me for unary message ? makes it a lot better. >>> >> >> Hi Stef, >> >> I have been facing this ambiguity a lot too. And my workaround, most of the times, was also to prefer the "question" method with #should. #is just doesn't sound right in my cases, but #should does sound good in most of them. I would still like to find a better one, but for the moment, in my recent years, I am stuck with #should. >> >> -- >> Mariano Martinez Peck >> Email: [hidden email] >> Twitter: @MartinezPeck >> LinkedIn: www.linkedin.com/in/mariano-martinez-peck >> Blog: https://marianopeck.wordpress.com/ > |
In reply to this post by ducasse
On Wed, 11 Sep 2019 at 15:10, ducasse <[hidden email]> wrote:
Agreed. That could "almost" be construed as converting a 3 to a 2 or 4. > flag2 := anInteger isEven. “better" Agreed. It reads well. > flag3 := anInteger even?. “how much better?” For me, this doesn't read as well as flag2, but even though there is some redundancy, for me a combination reads well... flag3a := anInteger isEven? Perhaps if "?"==>Boolean was a strong convention then there could be a check when the value is returned rather than when it is used (or would that complicate other things?) > flag4 := #(1 2 3) includes?: 2. “how much better?” My first impression is "yuck!", but then I think... "maybe" if there was a definite benefit (i.e. optimization) from strong guarantees about the return value being Boolean.
btw, some alternatives... doBlockBracketsLineUp - reads well but "do" is already a loaded word areBlockBracketsLinedUp - reads well with the past-tense phrasing cheers -ben |
I agree with Ben’s reaction below , however the point that ? ! could be repurposed for something if they weren’t special characters is a good one. Maybe there are other usages we are missing, and that’s the point I guess. Tim Sent from my iPhone
|
I think that it would be nice to think a bit. I like the idea that I do not have to read the code to understand if a method is a predicate. odd? even? Stef
|
Crazy idea inspired by Spanish: ¿even? On Sat, Sep 14, 2019 at 04:38 ducasse <[hidden email]> wrote:
Christopher Fuhrman, P.Eng., PhD Professeur au Département de génie logiciel et des technologies de l'informationÉTS (École de technologie supérieure) http://profs.etsmtl.ca/cfuhrman +1 514 396 8638 L'ÉTS est une constituante de l'Université du Québec |
areBlockBracketsLinedUp - reads well with the past-tense phrasing Technically, that is in present tense but using the passive voice. Passive voice is used to emphasize who receives an action, instead of who performs the action. El sáb., 14 sept. 2019 a las 16:07, Christopher Fuhrman (<[hidden email]>) escribió:
|
Free forum by Nabble | Edit this page |