What's the name for a mix of snake case and camel case?
Asked Answered
B

2

16

I'm maintaining some legacy Java code, and I keep coming across a weird mix of camel case and snake case in the same blocks of code. Some names are entirely camel case, others are entirely snake case, and others are a weird mix (e.g. displayText_label_maxDiff or hasProperty_). I realize that these names aren't an accepted Java coding style, nor should they be. I'm just looking for a meaningful term to use in conversation.

Is there already an accepted name? If not, what would you propose? I was thinking of "cobble case," "roadkill case," or "strange case".

Bernhard answered 25/7, 2017 at 21:30 Comment(4)
inconsistent naming styleNeuter
How about "basket case"?Nombles
It's probably just inconsistency but it might also be a philosophy of using the underscore as a stronger separator, while normally using camel case. It can increase readability in some cases, at least if the readers know what it means.Nanette
@Nanette I have actually seen one place where it makes sense. When naming unit tests, it can be handy to use underscores to separate the name of the method being tests from condition being tested. For example, if testing a method named registerNewWidget, you could have test methods named registerNewWidget_widgetIsDefective, registerNewWidget_widgetAlreadyRegistered, and registerNewWidget_happyPath.Bernhard
M
39

At first glance it would appear to be some custom hybrid of camelCase and snake_case called Upper_Snake_Case or Camel_Snake_Case[1].

Closer inspection (as pointed out in the comments below) shows it is an even worse hybrid than that, caused by the inconsistency of not using an underscore _ before each capitalized letter.

At this point, the term lowerCamel_snakeCase would describe it (although lower_camelCase_embeddedUnderscore would be more precise[2]) but... there is no such thing.

So, if we're making things up anyway, the suggestion of a Mythological Hybrid Animal of awesome ugliness that combines a camel and a snake (and boar and ox or goat) seems fitting.

As boarCamel_oxOrGoat_snake_case would be a bit too verbose, ypotryll_case might be a better match[3].

Especially as the ypotryll only appears in all of European Heraldry once [4], as the badge of a man dubbed the "Butcher of England" who was known for being ugly and cruel. As he left no heir, the badge was never used again.

This, I feel, makes it a perfect match for this coding standard, both in form (combining a camel and a snake) and function (only encountered once and never to be seen again).

I hope this answers your question, an image of a ypotryll has been added for your viewing pleasure:

image source: https://mistholme.com/dictionary/ypotryll/


Footnotes

[1] As Upper_Snake_Case is often confused with SCREAMING_SNAKE_CASE or MACRO_CASE, using Camel_Snake_Case is the safer of the two to use.

[2] see http://wiki.c2.com/?CapitalizationRules

[3] To place credit where credit is due: the term ypotryll_case was coined by the author of this question in the comments below.

[4] It appears in Fenn's Book of Badges of c.1470 as the badge of John Tiptoft, 1st Earl of Worcester.

Messapian answered 4/2, 2019 at 21:37 Comment(8)
If you get rid of some (not all) of the underscores from upper snake case, then it's not proper upper snake case anymore.Bernhard
Then maybe "Studly_sNake_CaPs" is more appropriate? 🤔Messapian
That would work if the upper case letters were in random positions, but I'm only seeing them at the beginnings of words.Bernhard
Then I think we'll have to settle for lowerCamel_snakeCase, although lower_camelCase_embeddedUnderscore might be more precise... (see wiki.c2.com/?CapitalizationRules).Messapian
Camel_snake_case isn't bad. We could shorten it to ypotryll_case. en.wikipedia.org/wiki/YpotryllBernhard
I've updated my answer to reflect the insights from these comments.Messapian
You say, "only encountered once and never to be seen again." I'll toast to that, even if my hope is in vain.Bernhard
What about "1337 Case"...Teasel
F
0

A mix of snake_case and camelCase can be confusing and easily misread in the languages that use PascalCase. For example my_varAdd() and my_var.Add() look too similar.

Fanestil answered 4/3, 2023 at 13:15 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.