Monday, October 31, 2005

Conveying intent in tests

here

what is more readable:

testValidateAddressFailsWithMissingStreetName
()
very long "german"-kind-of function name, or:
test_validate_address_fails_with_missing_street_name()

I found the 2nd more readable, i.e. it documents better the intent of the function validate(). Is it right to have a coding style for UnitTests (snake-style) and another style for coding !?

Matz said that for him the 2nd coding style is easier to read. I've got used with camel/Pascal case, but for the cases mentioned above, it is really a pain (in the eye).

I read the whole sentence, than I have to re-read it, to impregnate my brain with its meaning. Maybe we should reconsider Word_Separators.

On the other hand, if the name is too big, is probably a CodeSmell: the function is doing too much, the object knows too much. (DataGridPreferredColumnWidthTypeConverter !?) Maybe another namespace separation is needed?


No comments: