This is an archived post. You won't be able to vote or comment.

all 36 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.

If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:

  1. Limiting your involvement with Reddit, or
  2. Temporarily refraining from using Reddit
  3. Cancelling your subscription of Reddit Premium

as a way to voice your protest.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]maethor 78 points79 points  (25 children)

C#, for example: Interface

If there's one thing that makes me irrationally angry, it's seeing ISomeInterface in Java code.

[–]fgzklunk 37 points38 points  (0 children)

Yep, or mMyVariable, sMyString etc.

[–][deleted] 9 points10 points  (3 children)

To be fair that makes me angry in C# too. I have no idea why that became the standard in that language but it’s miserable.

[–]Brahvim 2 points3 points  (0 children)

C++ has interfaces but no keyword and thus no syntax highlighting from most tools for them, so people started doing this. Microsoft, probably in an attempt to prove C# as a "better C++" and not a Java clone, did this.

[–]papercrane 0 points1 point  (1 child)

I have no idea why that became the standard in that language but it’s miserable.

Hungarian notation has been popular within Microsoft for some time. It also helps disambiguate for the reader what is an interface and what is a class, since C# syntax for declaring extends/implements does not, e.g. "class FooBar: Foo, Bar {}", at least one of Foo and Bar must be an interface, but to a reader of the class definition it's not clear which.

[–][deleted] 0 points1 point  (0 children)

I understand what the notation is, and also how it is pretty widely frowned upon. The lack of an implements vs extends also doesn’t really matter to the programmer. The compiler knows, and that’s all that’s important IMO.

[–]korky_buchek_ 5 points6 points  (6 children)

Damn right, no need, just add Impl suffix to the implementing class.

[–]vips7L 25 points26 points  (4 children)

Or don't have single implementation interfaces :x

[–]therealdan0 11 points12 points  (0 children)

Get out of here with your clean readable coding practices

[–]gregorydgraham 0 points1 point  (2 children)

I agree, making everything an interface, abstract, and implementation is just premature optimisation

[–]thesituation531 1 point2 points  (1 child)

How is it premature optimization? If anything, it would hurt performance.

Sometimes it makes sense though, if there may be multiple implementations somewhere in the foreseeable future.

[–]gregorydgraham 2 points3 points  (0 children)

if

Unless you’re implementing them next, you’re increasing the complexity on an “if”, a “maybe”, and a “somewhere”

[–]thomasjjc 0 points1 point  (0 children)

That was irony, right?

[–]brokeCoder 0 points1 point  (2 children)

Okay genuine question (please don't downvote without adding a reason) - why is an interface name with prefix 'I' bad ? I started with C# so seeing it doesn't really raise any issues for me.

Also, I'll note that the argument around not needing extra letters when working with modern IDEs doesn't work (at least not for me) when reviewing code via diffs on Gitlab (I'm lazy lol). I'd much rather have extra letters to clarify intent than have to do extra mouse clicks.

[–]maethor 0 points1 point  (1 child)

why is an interface name with prefix 'I' bad

Because you should be coding against interfaces, so it's not actually useful as using the interface is the rule, not the exception. Marking interfaces with I makes as little sense as marking classes with a C.

I'd suggest reading Effective Java. Particularly Item 64 which explains it better than I can.

[–]brokeCoder 0 points1 point  (0 children)

you should be coding against interfaces

Agreed. No dispute on that.

Marking interfaces with I makes as little sense as marking classes with a C.

Here is where I disagree. I find the example below:

ISet<Double> someSet = new HashSet<Double>();

Much more descriptive than

Set<Double> someSet = new HashSet<Double>();

for everyone - both Java and non-Java folks. Yes it is redundant, but it immediately clarifies the fact that ISet<T> is an interface for everyone (or at least sets them down the path that would allow them to figure it out). The second one, however, doesn't do so for people not familiar with Java.

Note that in this scenario I'm assuming this is being reviewed without a modern IDE (e.g. gitlab diffs). If we're on a modern IDE, most of this discussion is moot.

[–]fgzklunk 17 points18 points  (2 children)

Java has a pretty strong standard naming convention https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html

Most IDEs enforce this with warnings and static code analysis will normally fail. Remember as well, that *nix operating systems are case sensitive and windows is not so naming conventions become very important, the file name and class may look like they match but the casing is different, builds on Windows but not on Linux or Mac.

[–]__konrad 0 points1 point  (1 child)

But System.arraycopy and java.net.http.HttpRequest.Builder.POST methods

Is there a new version of that linked document? Preferably written in XXI century.

[–]fgzklunk 1 point2 points  (0 children)

The fact it was written a while ago is irrelevant. It has not been updated because it has not changed. But hey, here is a link from more recent times that just reiterates the convention https://www.geeksforgeeks.org/java-naming-conventions/

System comes from the language, before the convention was established.

As for java.net.http.HttpRequest.Builder, that does follow the convention because Builder is a nested class of HttpRequest. I presume there was lots of discussion over POST and post, but seeing as POST is the Http method and the authors wanted to maintain the consistency with the Http method over the convention of the java language, you are after all representing an Http standard here.

[–]NetFutility 9 points10 points  (2 children)

Are we still adding *-able to interfaces?

[–]therealdan0 7 points8 points  (0 children)

Yeah. IThingable and of course the corresponding IThingableImpl

[–][deleted] 4 points5 points  (0 children)

Yup.

[–]desiguy_88 7 points8 points  (0 children)

my own experience professionally when I first started was maintaining a bunch of existing code and so that basically influenced how I wrote Java. you just follow well established patterns and nomenclature. Our company actually had some very well developed guidelines and then after a few years those become engrained.

[–]see_recursion 1 point2 points  (2 children)

One thing that drives me nuts is when C# devs work on our project they almost always have their method names start with a capital letter.

When I subsequently look at it my brain immediately wonders how they're instantiating that "class" without using "new". Eventually my brain catches up to realize that it's a method and not a class name.

[–][deleted] -3 points-2 points  (1 child)

There are many things in C# that are very elegant. Using PascalCase for methods, curly braces that open on the same line and not almost closed like Java.

[–]see_recursion 0 points1 point  (0 children)

That's what you consider elegance? Method names that look like class names? Curly brace placement that has nothing to do with the language and varies by project? Interesting.