top | item 33799926

(no title)

Systemic33 | 3 years ago

Very cool idea and execution.

Slightly off-topic; if there ever was a excellent example of what it means when a C# program is being written by a java developer, this would certainly qualify.

Was this ported from a java project?

discuss

order

davbryn|3 years ago

When did we get C# devs flexing on Java devs? Isn't like that like a paint by numbers expert flexing on a paint by letters kinda person?

the_gipsy|3 years ago

Oh this is so mean ;)

n4r9|3 years ago

Could you give examples of what you mean? I've had a look through and there are certainly stylistic things I'd do differently, such as using "var" and LINQ more, and capitalising method names. But it's easy enough to understand despite that.

Systemic33|3 years ago

Don't get me wrong, it's not "bad" code (from a brief glance) but it's just clearly written as if it was Java code, and probably not in a usual IDE like Visual Studio, Rider or VSCode /w C# plugin (as that would typically scaffold a more C#-esque style).

Here's what I've noticed so far:

- Uses camelCase instead of PascalCase

- Uses setter and getter methods instead of C# properties.

- Uses reverse DNS namespace com.mc2k.SimCityReader instead of e.g. JGosar.MineCity2000.SimCityReader.

- Lack of LINQ (It is such a big part of C#, that not using it at all is strange).*

- Lac of using generics e.g. List<string> instead of string[].*

- Excessive use of arrays (you'd typically use a simple IEnumerable<T> or List<T>).

- Lack of `var`.*

- Casting integer literals to short, byte, etc -- these all have equivalent literal notation.*

- Lack of extension methods.*

- Lack of maps (pattern matching).*

There could be more, but those are what I noticed.

EDIT: * Given that the original code was done with VS 2010 and .NET Framework 4, its fair to say that a few of the points above do not apply, but the code is nevertheless very java-esque (just from the first two points).

jgosar|3 years ago

We were working on a mix of Java and C# projects at work at the time I started writing this, so that's probably why the code looks like a mix between the two.

Cthulhu_|3 years ago

It's typical how this particular project / codebase attracts so many armchair code reviewers (in multiple threads); I've not seen anything like that on HN for ages. Is C# / Java some kind of trigger for it?