Arbitrary abbreviations in phobos considered ridiculous

Marco Leise Marco.Leise at gmx.de
Wed Mar 7 05:56:33 PST 2012


Am 06.03.2012, 23:50 Uhr, schrieb James Miller <james at aatch.net>:

> On 7 March 2012 10:30, deadalnix <deadalnix at gmail.com> wrote:
>> Le 06/03/2012 21:00, Timon Gehr a écrit :
>>
>>> On 03/06/2012 07:13 PM, Alex Rønne Petersen wrote:
>>>>
>>>> (Also, seriously, I think you're over-dramatizing the Java variable
>>>> naming thing; I rarely see names that are as bad as you claim...)
>>>>
>>>
>>> It is not only about single names, but also about how many times you
>>> have to spell them out in short intervals.
>>>
>>> try{
>>> SqlConstraintViolatedExceptionFactoryWrapper
>>> sqlConstraintViolatedExceptionFactoryWrapper = new
>>> SqlConstraintViolatedExceptionFactoryWrapper(new
>>> SqlConstraintViolatedExceptionFactory(...));
>>> SqlConstraintViolatedException sqlConstraintViolatedException =
>>>
>>> sqlConstraintViolatedExceptionFactory.createSqlConstraintViolatedException(...);
>>>
>>> throw sqlConstraintViolatedException;
>>> }catch(SqlConstraintViolatedExceptionFactoryWrapperException e){
>>> // ...
>>> }catch(SqlConstraintViolatedExceptionFactoryException e){
>>> // ...
>>> }
>>>
>>> Deliberately over-dramatized.

I have used Java commercially in Eclipse and I have to make a point for the combination of IDE and language here. What you really *type* for that is (<cs> meaning ctrl+space):

SCVEFW<cs><↓><enter> <cs><↓><↓><↓><enter> = new <cs><enter>new <cs><enter><tab>;<ctrl+1><↓><enter><↑><end>
SCVE<cs><↓><enter> <cs><↓><↓><enter> = <cs><↓><↓><↓><enter>.<enter>;
throw <cs><↓><enter>;

resulting in the following code:

	try {
		SqlConstraintViolatedExceptionFactoryWrapper sqlConstraintViolatedExceptionFactoryWrapper = new SqlConstraintViolatedExceptionFactoryWrapper(new SqlConstraintViolatedExceptionFactory());
		SqlConstraintViolatedException sqlConstraintViolatedException = sqlConstraintViolatedExceptionFactoryWrapper.createSqlConstraintViolatedException();
		throw sqlConstraintViolatedException;
	} catch (SqlConstraintViolatedExceptionFactoryWrapperException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	} catch (SqlConstraintViolatedExceptionFactoryException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

That is 72 key strokes instead of 519. So the spelling (as in typing) itself is not a problem with camel-case auto-complete, variable name and type based parameter guessing.

> "dur" should be "duration" because its silly otherwise. Seconds should
> be either "secs" /or/ "seconds", but should be consistent, I'd say
> "secs" because it meshes well with the other, sub-second, times
> ("nsecs", "usecs" etc) and writing out "microseconds" is a bit
> verbose, especially when you're probably outputting them as "12 us"
> anyway...
>
> --
> James Miller

+1
I tried to use "secs", at least two times. It is one of these cases where a minor annoyance adds up until someone eventually starts a rant about it. And a lot of people realize that they found the situation odd as well, but not an issue. I can see the reasoning behind making templated functions short, as in "dur", but it is inconsistent with Duration and almost like foo() and bar() :)


More information about the Digitalmars-d mailing list