Ugly smell: really long symbols/selectors

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Ugly smell: really long symbols/selectors

Guillermo Polito
#'thisIsAVeryLongSelectorAndIfYoureHereWeHaveOnly49ImagineIHaveToWriteAllThisToArriveTo87ThenThisTo100'

(ByteSymbol allInstances select: [ :e | e size > 100 ]) size
  => 36

(ByteSymbol allInstances select: [ :e | e size between: 50 and: 100 ]) size
  => 653


--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: Ugly smell: really long symbols/selectors

Nicolas Cellier
Hi Guile,
have you inspect-ed the list?
I wouldn't be surprise that these are whole sentence acting as specification in unit TestCase,
like whenBrowserReceiveOpenItShouldReturnTheWindowMorph...

2017-08-16 3:51 GMT+02:00 Guillermo Polito <[hidden email]>:
#'thisIsAVeryLongSelectorAndIfYoureHereWeHaveOnly49ImagineIHaveToWriteAllThisToArriveTo87ThenThisTo100'

(ByteSymbol allInstances select: [ :e | e size > 100 ]) size
  => 36

(ByteSymbol allInstances select: [ :e | e size between: 50 and: 100 ]) size
  => 653


--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: <a href="tel:+33%206%2052%2070%2066%2013" value="+33652706613" target="_blank">+33 06 52 70 66 13


Reply | Threaded
Open this post in threaded view
|

Re: Ugly smell: really long symbols/selectors

Guillermo Polito
(ByteSymbol allInstances select: [ :e | e size > 50 ]) size
"638"
(ByteSymbol allInstances select: [ :e | e size > 50 and: [ e beginsWith: 'test' ] ]) size
"200"

Still 438 non test selectors. Some of them are class creation methods (#subclass:instanceVariables:...)

I'm just saying this is a smell, wanted to share some of my catarsis :).

Guille

On Wed, Aug 16, 2017 at 9:35 AM, Nicolas Cellier <[hidden email]> wrote:
Hi Guile,
have you inspect-ed the list?
I wouldn't be surprise that these are whole sentence acting as specification in unit TestCase,
like whenBrowserReceiveOpenItShouldReturnTheWindowMorph...

2017-08-16 3:51 GMT+02:00 Guillermo Polito <[hidden email]>:
#'thisIsAVeryLongSelectorAndIfYoureHereWeHaveOnly49ImagineIHaveToWriteAllThisToArriveTo87ThenThisTo100'

(ByteSymbol allInstances select: [ :e | e size > 100 ]) size
  => 36

(ByteSymbol allInstances select: [ :e | e size between: 50 and: 100 ]) size
  => 653


--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: <a href="tel:+33%206%2052%2070%2066%2013" value="+33652706613" target="_blank">+33 06 52 70 66 13





--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: Ugly smell: really long symbols/selectors

Stephane Ducasse-3
I often use long selectors for tests :)


On Wed, Aug 16, 2017 at 9:49 AM, Guillermo Polito <[hidden email]> wrote:
(ByteSymbol allInstances select: [ :e | e size > 50 ]) size
"638"
(ByteSymbol allInstances select: [ :e | e size > 50 and: [ e beginsWith: 'test' ] ]) size
"200"

Still 438 non test selectors. Some of them are class creation methods (#subclass:instanceVariables:...)

I'm just saying this is a smell, wanted to share some of my catarsis :).

Guille

On Wed, Aug 16, 2017 at 9:35 AM, Nicolas Cellier <[hidden email]> wrote:
Hi Guile,
have you inspect-ed the list?
I wouldn't be surprise that these are whole sentence acting as specification in unit TestCase,
like whenBrowserReceiveOpenItShouldReturnTheWindowMorph...

2017-08-16 3:51 GMT+02:00 Guillermo Polito <[hidden email]>:
#'thisIsAVeryLongSelectorAndIfYoureHereWeHaveOnly49ImagineIHaveToWriteAllThisToArriveTo87ThenThisTo100'

(ByteSymbol allInstances select: [ :e | e size > 100 ]) size
  => 36

(ByteSymbol allInstances select: [ :e | e size between: 50 and: 100 ]) size
  => 653


--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: <a href="tel:+33%206%2052%2070%2066%2013" value="+33652706613" target="_blank">+33 06 52 70 66 13





--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: <a href="tel:+33%206%2052%2070%2066%2013" value="+33652706613" target="_blank">+33 06 52 70 66 13


Reply | Threaded
Open this post in threaded view
|

Re: Ugly smell: really long symbols/selectors

Denis Kudriashov
Which is actually shows that tests as methods are not really good idea. Tests are supposed to be documentation but with classic SUnit we have only two ways (classes and methods) to decompose them which is definitely not enough for docs.
But ignore it. I am just thinking aloud :)

2017-08-16 13:47 GMT+02:00 Stephane Ducasse <[hidden email]>:
I often use long selectors for tests :)


On Wed, Aug 16, 2017 at 9:49 AM, Guillermo Polito <[hidden email]> wrote:
(ByteSymbol allInstances select: [ :e | e size > 50 ]) size
"638"
(ByteSymbol allInstances select: [ :e | e size > 50 and: [ e beginsWith: 'test' ] ]) size
"200"

Still 438 non test selectors. Some of them are class creation methods (#subclass:instanceVariables:...)

I'm just saying this is a smell, wanted to share some of my catarsis :).

Guille

On Wed, Aug 16, 2017 at 9:35 AM, Nicolas Cellier <[hidden email]> wrote:
Hi Guile,
have you inspect-ed the list?
I wouldn't be surprise that these are whole sentence acting as specification in unit TestCase,
like whenBrowserReceiveOpenItShouldReturnTheWindowMorph...

2017-08-16 3:51 GMT+02:00 Guillermo Polito <[hidden email]>:
#'thisIsAVeryLongSelectorAndIfYoureHereWeHaveOnly49ImagineIHaveToWriteAllThisToArriveTo87ThenThisTo100'

(ByteSymbol allInstances select: [ :e | e size > 100 ]) size
  => 36

(ByteSymbol allInstances select: [ :e | e size between: 50 and: 100 ]) size
  => 653


--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: <a href="tel:+33%206%2052%2070%2066%2013" value="+33652706613" target="_blank">+33 06 52 70 66 13





--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: <a href="tel:+33%206%2052%2070%2066%2013" value="+33652706613" target="_blank">+33 06 52 70 66 13



Reply | Threaded
Open this post in threaded view
|

Re: Ugly smell: really long symbols/selectors

Guillermo Polito
but wait, I've just shown that more than 2/3s of them are not test selectors...

On Wed, Aug 16, 2017 at 2:21 PM, Denis Kudriashov <[hidden email]> wrote:
Which is actually shows that tests as methods are not really good idea. Tests are supposed to be documentation but with classic SUnit we have only two ways (classes and methods) to decompose them which is definitely not enough for docs.
But ignore it. I am just thinking aloud :)

2017-08-16 13:47 GMT+02:00 Stephane Ducasse <[hidden email]>:
I often use long selectors for tests :)


On Wed, Aug 16, 2017 at 9:49 AM, Guillermo Polito <[hidden email]> wrote:
(ByteSymbol allInstances select: [ :e | e size > 50 ]) size
"638"
(ByteSymbol allInstances select: [ :e | e size > 50 and: [ e beginsWith: 'test' ] ]) size
"200"

Still 438 non test selectors. Some of them are class creation methods (#subclass:instanceVariables:...)

I'm just saying this is a smell, wanted to share some of my catarsis :).

Guille

On Wed, Aug 16, 2017 at 9:35 AM, Nicolas Cellier <[hidden email]> wrote:
Hi Guile,
have you inspect-ed the list?
I wouldn't be surprise that these are whole sentence acting as specification in unit TestCase,
like whenBrowserReceiveOpenItShouldReturnTheWindowMorph...

2017-08-16 3:51 GMT+02:00 Guillermo Polito <[hidden email]>:
#'thisIsAVeryLongSelectorAndIfYoureHereWeHaveOnly49ImagineIHaveToWriteAllThisToArriveTo87ThenThisTo100'

(ByteSymbol allInstances select: [ :e | e size > 100 ]) size
  => 36

(ByteSymbol allInstances select: [ :e | e size between: 50 and: 100 ]) size
  => 653


--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: <a href="tel:+33%206%2052%2070%2066%2013" value="+33652706613" target="_blank">+33 06 52 70 66 13





--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: <a href="tel:+33%206%2052%2070%2066%2013" value="+33652706613" target="_blank">+33 06 52 70 66 13






--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: Ugly smell: really long symbols/selectors

Richard Sargent
Administrator
Guillermo Polito wrote
but wait, I've just shown that more than 2/3s of them are not test
selectors...
Well, quit teasing us. :-) Show us the list (longest to shortest order).

I agree with you that it is a code smell and you are right to be suspicious. I'm inclined to say that if the method name is a novella, the method is probably doing too much or the method name is trying to explain too much about the method's internals.


On Wed, Aug 16, 2017 at 2:21 PM, Denis Kudriashov <[hidden email]>
wrote:

> Which is actually shows that tests as methods are not really good idea.
> Tests are supposed to be documentation but with classic SUnit we have only
> two ways (classes and methods) to decompose them which is definitely not
> enough for docs.
> But ignore it. I am just thinking aloud :)
>
> 2017-08-16 13:47 GMT+02:00 Stephane Ducasse <[hidden email]>:
>
>> I often use long selectors for tests :)
>>
>>
>> On Wed, Aug 16, 2017 at 9:49 AM, Guillermo Polito <
>> [hidden email]> wrote:
>>
>>> (ByteSymbol allInstances select: [ :e | e size > 50 ]) size
>>> "638"
>>> (ByteSymbol allInstances select: [ :e | e size > 50 and: [ e beginsWith:
>>> 'test' ] ]) size
>>> "200"
>>>
>>> Still 438 non test selectors. Some of them are class creation methods
>>> (#subclass:instanceVariables:...)
>>>
>>> I'm just saying this is a smell, wanted to share some of my catarsis :).
>>>
>>> Guille
>>>
>>> On Wed, Aug 16, 2017 at 9:35 AM, Nicolas Cellier <
>>> [hidden email]> wrote:
>>>
>>>> Hi Guile,
>>>> have you inspect-ed the list?
>>>> I wouldn't be surprise that these are whole sentence acting as
>>>> specification in unit TestCase,
>>>> like whenBrowserReceiveOpenItShouldReturnTheWindowMorph...
>>>>
>>>> 2017-08-16 3:51 GMT+02:00 Guillermo Polito <[hidden email]>:
>>>>
>>>>> #'thisIsAVeryLongSelectorAndIfYoureHereWeHaveOnly49ImagineIH
>>>>> aveToWriteAllThisToArriveTo87ThenThisTo100'
>>>>>
>>>>> (ByteSymbol allInstances select: [ :e | e size > 100 ]) size
>>>>>   => 36
>>>>>
>>>>> (ByteSymbol allInstances select: [ :e | e size between: 50 and: 100 ])
>>>>> size
>>>>>   => 653
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>>
>>>>>
>>>>> Guille Polito
>>>>>
>>>>>
>>>>> Research Engineer
>>>>>
>>>>> French National Center for Scientific Research - *http://www.cnrs.fr*
>>>>> <http://www.cnrs.fr>
>>>>>
>>>>>
>>>>>
>>>>> *Web:* *http://guillep.github.io* <http://guillep.github.io>
>>>>>
>>>>> *Phone: *+33 06 52 70 66 13 <+33%206%2052%2070%2066%2013>
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>>
>>>
>>>
>>> Guille Polito
>>>
>>>
>>> Research Engineer
>>>
>>> French National Center for Scientific Research - *http://www.cnrs.fr*
>>> <http://www.cnrs.fr>
>>>
>>>
>>>
>>> *Web:* *http://guillep.github.io* <http://guillep.github.io>
>>>
>>> *Phone: *+33 06 52 70 66 13 <+33%206%2052%2070%2066%2013>
>>>
>>
>>
>


--



Guille Polito


Research Engineer

French National Center for Scientific Research - *http://www.cnrs.fr*
<http://www.cnrs.fr>



*Web:* *http://guillep.github.io* <http://guillep.github.io>

*Phone: *+33 06 52 70 66 13
Reply | Threaded
Open this post in threaded view
|

Re: Ugly smell: really long symbols/selectors

Sean P. DeNigris
Administrator
In reply to this post by Denis Kudriashov
Denis Kudriashov wrote
Which is actually shows that tests as methods are not really good idea.
Tests are supposed to be documentation but with classic SUnit we have only
two ways (classes and methods) to decompose them which is definitely not
enough for docs.
He he +100. I remember us talking about this a long time ago. I have a vision for something like rspec, but with a domain UI and then have the classes/methods/whatever storage as an implementation detail.
Cheers,
Sean