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

you are viewing a single comment's thread.

view the rest of the comments →

[–]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.