DEV Community

Alexey Voinov
Alexey Voinov

Posted on

1

On typical naming anti-pattern in Java

I think one word summarises it all: OneEyedOneHornedFlyinPurplePeopleEater. Every time I see a typical javish 40+ character class name often composed of several short sentences, I remember this song and silently sing it a little bit. I think I'll give it a try to sing it aloud for a change. :)

Anyway, I believe it is a great name for this anti-pattern. Opinions?

Top comments (2)

Collapse
 
simonhaisz profile image
simonhaisz

class PeopleEater implements HasEyes, HasHorns, CanFly, HasColor {
...
}

Interfaces: not just for polymorphism.

A related beast is the method name that references it's parameters and/or class.

class Foo
// Why do this...
public void addBarToFoo(Bar bar);
// ...Instead of this?
public void add(Bar bar);
}

Collapse
 
voins profile image
Alexey Voinov

Exactly! :)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay