When naming interfaces in Java

Asked 2 years ago, Updated 2 years ago, 86 views

In most object-oriented languages, when you name an interface, you put the capital i in front of it. But why not in Java? Why not?

I mean, when I implement User Interface and User, there are two ways.

But most languages use Class = User, Interface = IUser.

My question is, what is the value of naming an interface like that in Java's direction?

java interface naming-convention

2022-09-22 22:24

1 Answers

When defining an interface, do not prefix the name. The reason is that if you do so, you will be detrimental to readability. Also, using an interface is a good way to program it, but the name of the interface must be short to make it easier to write. Implementing a class can be ugly in order to suppress its use as much as possible. Because when you switch from an abstract class to an interface, you have to change the prefix I of all classes.


2022-09-22 22:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.