News for hackers. Stuff that matters.
Re:On F# code readability by MichaelGG on Monday March 04, 2013 @01:16PM (#5319544)
Preferring head::tail over x::xs sorta indicates they have read little functional code. Using x and xs (plural) is pretty common and straightforward. head::tail doesn't help at all.

Edit: Also, even in C#, the whole "one class per file" is often unwise. So many times I come across projects that have a bunch of bloody files to define interfaces with a handful of members. And then a bunch of implementations that have 2-line implementations. It's sorta ridiculous. I think it's a holdover from Java's idiotic "tie the filesystem directly into the compilation output" approach.

Re:On F# code readability by NateDad on Monday March 04, 2013 @01:41PM (#5319761)
Actually, if you're browsing the code in Visual Studio, it's a hell of a lot easier to jump around the code if you have one class per file. All the main navigation UI is geared to the file level - the tree in solution explorer is all files. The tabs in the editor are lists of files. ctrl-tab brings up a list of files. You can bring up a new tab group and see two files side by side.

So, yes, one thing per file is actually a pretty good idea. Sometimes it's fine to put multiple things into a single file, if there's a lot of small implementations... but for anything even mediumly big, it's good to give it its own file. It helps a lot with navigation.

And yes, I know you can do "go to definition" etc, but if you want to go back and forth between code, separate files is a lot easier. It also makes source control a lot easier, because you can see a file changed and know immediately what it will and will not affect.

Which is not to say that I don't think java got it wrong, it did, it's just that the problem is not with one class per file, but rather that the file heirarchy matters.

Re:On F# code readability by MichaelGG on Monday March 04, 2013 @01:44PM (#5319787)
In C#, VS has a class view that lets you jump around by class name. You can split the window and compare within the same file just fine. And if anything, you're complaining about VS's lack of capabilities.

I'm not arguing that you never want a separate file, just that having a forced "one class per file" rule just sprays files all over and means you have to jump around more. Java's hierarchy+class=file is just silly; there's nothing stopping people from enforcing that themselves, if they so choose.

Re:On F# code readability by sitharus on Monday March 04, 2013 @01:43PM (#5319782)
That depends. I tend to leave small support classes in the same file, but anything public goes to file per type.

Why? Because I have to work with people who don't have resharper installed, and without resharper it's near impossible to find those types without doing a full project search.

Re:On F# code readability by MichaelGG on Monday March 04, 2013 @01:45PM (#5319796)
Is a search that hard? Go To Definition? Class View?
Re:On F# code readability by sitharus on Friday March 08, 2013 @09:46PM (#5347085)
If you're talking about a project with thousands of classes in a similar number of files, with auto-generated code from an ORM as part of it. Yes.

Search takes at least a minute. Class view is only useful if you know the namespace. Go To Definition doesn't help if you're looking a definition for an interface and you want the concrete implementation.