Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

IntelliJ has inspections for long class and method names. A lot of Java devs run that. Long names are frequently derided in the Ruby community as being Java-like. I can't speak to Haskell at all. But generally whenever something needs to be typed frequently, it tends to be shortened. My favorite is when vowels are deemed too onerous.


While I was writing that, I realised that it may come down to the definition of what constitutes a long method / variable / class name.

I have usually found that the IntelliJ defaults are enough to make the names meaningful. For Ruby, the inspection kicks in at 30 characters. Interestingly, it's referenced from the ruby style guide here: https://github.com/bbatsov/ruby-style-guide where I can't find a recommended maximum length.

We're somewhat sidetracked from the main discussion. I'm generally in favour of trying to write code that is as readable as possible. Ideally in such a way that it is understandable even without the comments.

That said, I do think that good comments are helpful and essential if you're building a library. The Spring Framework comes to mind as a project that has a great set of documentation built from the comments (but also has very readable code, along with long method, variable and class names).


I can get on board with common sense decision making :-)


Haskell is a special beast, in the sense that it uses single letters a lot for generic types in signatures. Eg:

  doFoo :: a -> a
where doFoo will take any type a and return something of the same type. Due to the density of the language, you'll often find plenty of small, commented functions.


Compare

doubleCompose binary_func transformation first_arg second_arg = binary_func (transformation first_arg) (transformation second_arg)

vs doubleCompose (b -> b -> c) -> (a -> b) -> a -> a -> c doubleCompose (+) f x y = (f x) + (f y)

(also known as the `on` function). There's hardly any good names for x and y, since they can be anything at all.


Our guidelines at work are: The more polymorphic a variables type, the shorter its name can be.


Your verbose version is just the core of the function, not the type signature. I'm not really sure of what you want to demonstrate here. That short names are good ?


The Haskell community certainly love their infix non-alphanumeric functions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: