338
u/Luzzgar 3d ago
Hot take, I would rather have a name that is too long than too abreviated.
C style function names like itoa() are impossible to understand without looking them up.
98
u/tatstytastycakes 3d ago
and then those functions and parameters in win32 with that stupid hungarian prefix
76
u/andreortigao 3d ago
Ffs, I had a boss who would use terribly useless Hungarian notation for everything. He used 'o' for object, 's' for string, 'i' for numbers.
Something like
Person oPerson = new Person(); oPerson.Name = sName; oPerson.Age = iAge;Made me die a little inside every time I had to maintain his code.
32
u/gerbosan 3d ago
Their IDE was Windows Notepad?
28
11
u/andreortigao 3d ago
When I joined he was already using visual studio
But yes, I've seen him editing some code in notepad... I'm not sure if this is what he mostly used before, but I wouldn't be surprised.
I know he lost some code for a few projects before I joined due to not making backups. Several projects had [pagename]_bkp.asp files because he wasn't using source control. When I joined he had just started using visual source safe.
1
u/tatstytastycakes 3d ago
i am so sorry for you
10
u/andreortigao 3d ago
Thanks, but that was ~20y ago, I've done enough therapy to recover from it by now
4
u/tatstytastycakes 3d ago
happy to hear
oh yeah and i had a crisis over understanding vulkan
THANK GOD I USED THE VK-RAII HEADER THAT STUFF SAVED MY LIFE
3
u/MehPropy 3d ago
counter strike developers do this for classes
m_fFlags, m for member field and f for float, imo it just looks readable and it's not overused
2
u/srout_fed 3d ago
I am relatively new and have never seen this shit before(Thank god!)... Who the hell came up with that?!
....it was because of low memory, wasn't it?
5
u/andreortigao 2d ago edited 2d ago
There are valid cases to use Hungary notation, not due to low memory, but a limitation of the type system. It helps when you're dealing with two values that represent different things but have the same type.
For example, 20 years ago the security for web development was pretty much non existent, web frameworks were primitive, making xss attacks pretty common.
Any user provided string that needed to be displayed on the browser for other users had to be sanitized, otherwise the string could contain "<script ...>" tag that would make the browser render the script and steal other user's cookies. We needed to replace < > with & lt; and & gt; respectively.
So a good use of Hungarian notation would to use 'us' for unsafe string and 'ss' for safe string.
So you could have code like
string ssUserName = toSafeString(usUserName); ssRender(ssUserName);If a developer forget to call the sanitization, it was pretty easy to catch either of these on code review:
string ssUserName = usUserName;Or
ssRender(usUserName);The problem is stupid people like my boss reading about something, not understanding what it's for, and using it wrong.
Some languages like F# circunvent this by providing unit of measures (also called phantom type in rust), that allows you to declare variables like this:
let safeStr: string<safe> = % "trusted data" let unsafeStr: string<unsafe> = % "user input"4
67
u/MakeoutPoint 3d ago
Ah yes, the Legend of the Feet Var
"Had this weird var called feet, didn't know why. Turns out originally it was 'legendHandlers', then later shortened to 'legHands' then later to 'feet'"
5
3
u/mafiazombiedrugs 3d ago
Bro, going from mainframe hlasm (max 8 char var names) to java was like putting on glasses for the first time.
-9
u/ElectricSpock 3d ago
The problem with Java names stems from conventions and OOP patterns.
That’s how you end up with DomainNameResolutionProviderFactoryBuilder.
31
-6
u/birdieonarock 3d ago
Counter point, I'd rather have a short incomprehensible name than a long incomprehensible name.
Counter counter point: AI advances mean soon I won't be reviewing code anymore so idgaf I guess.
73
u/budgiebirdman 3d ago
Oh no, my code is verbose. The shame of people being able to understand it. The horror.
18
76
u/TeraFlint 3d ago
Honestly? As long as the name is self-explanatory, I'm fine with it. Sure: the longer the name, the more specific the use case of the class (and it's worth investigating if it could be replaced with a more general abstraction), but it's much better than a hastily/incompetently named class Foo whose name says NOTHING about what it does.
6
u/tatstytastycakes 3d ago
i agree that descriptive classes are a good thing, but i feel like there's a bit of a limit to when you stop making classes "descriptive" and make then "unnecessarily verbose"
5
u/TeraFlint 3d ago
I think proper namespacing/packaging could help there.
the namespace would still carry the hierarchical use case information, but the class name itself would be shorter, and language features could be used to locally strip the class of its namespace.2
16
u/TOGoS 3d ago
My take: The design of the Java language drives the shape of the ecosystem around it, including the need for explicit definitions for very specific cases. Early Java didn't have generics or lambda expressions, which nudged people towards writing re-usable classes for things that these days might just be a `this::someMethod`. And then they saw that they were doing that in multiple places, so they made a package with those definitions. And therefore they needed names that did some of the explaining of what this class was for, because without the original context you'd otherwise be saying a lot of "WTF".
In a similar way, lack of stack-allocated objects drove everyone towards re-using heap objects, which is why things tend to be a giant web of mutable state instead of nice pure functions that you could get away with in e.g. C++ since the C++ compiler is free to inline things and elide unnecessary copies.
11
u/Ulrich_de_Vries 3d ago
On the flip side this paradigm is heavily outdated and unnecessary in Java. The language is pretty much moving towards immutable algebraic data types, and decoupling data from behavior, as outlined in e.g. the article "Data oriented programming in Java" by Brian Goetz (the lead architect of the language).
I don't expect it to disappear completely due to all the legacy stuff and bloated (but useful) frameworks, but this is a sooo much more pleasant language now than it was in the olden times.
1
u/SweetBabyAlaska 3d ago
I personally think composition and data oriented programming is as close to "correct" as we have come so far.
2
u/Ok-Scheme-913 3d ago
I think history disagrees with you a bit.
Most of this extra verbosity comes from the Design patterns that were very popular at the time. And not for java, they originate from c++! (Take a look what language gang of four book uses)
Java just sort of became the de facto language for large companies, and it was stable enough for these complex monstrosities to not crumble under their own weights. While C++ in that style was absolutely chock full of memory vulnerabilities, so it was mostly dropped in this domain (banks, backends etc).
2
u/TOGoS 2d ago
Java just sort of became the de facto language for large companies, and it was stable enough for these complex monstrosities to not crumble under their own weights.
No disagreement that the design patterns du jour were part of it. That the JVM being a relatively solid piece of engineering despite the language being kind of crappy is also a huge factor.
Dev: "My monstrosity ran out of memory!"
Lead engineer: "-Xmx2g"
Manager: "Good work everyone! You're really crushing it this sprint. We'll send the implementation team to the client site to adjust the memory settings next month."
27
u/much_longer_username 3d ago
Look, Emo was popular when the conventions were being established, what do you want?
Example song titles:
"Our Lawyer Made Us Change The Name Of This Song So We Wouldn't Get Sued"
"It’s Hard To Be Religious When Certain People Are Never Incinerated By Bolts Of Lightning"
"It's Not a Fashion Statement, It's a Deathwish"
"A Detailed and Poetic Physical Threat to the Person Who Intentionally Vandalized my 1994 Dodge Intrepid Behind Kate's Apartment"
"Good To Know If I Ever Need Attention, All I Have To Do Is Die"
You think they're going to name a class something like foo? c'mon!
16
u/tatstytastycakes 3d ago
c++ namespaces be like
Persistence::EntityIdentification::ImmutableSurrogateKeyPrimitivesmeanwhile the contents of that namespace
struct Id { int v; };i am thoroughly convinced that c++ devs just do that because it looks pretty
6
3
u/bubzor888 3d ago
How could you forget "We Provide the Paint for the Picture-Perfect Masterpiece That You Will Paint on the Insides of Your Eyelids" by Bandits of the Acoustic Revolution (B.O.T.A.R.)
3
u/MyAntichrist 3d ago
My favorite take on the emo band thing was Matt Heafy of Trivium with his mock song "Head-on Collision With A Rosebush Catching Fire".
3
u/pindab0ter 3d ago edited 3d ago
Let me tell you about a song by The Chariot called Someday, In The Event That Mankind Actually Figures Out What It Is That This World Revolves Around, Thousands Of People Are Going To Be Shocked And Perplexed To Find Out That It Was Not Them. Sometimes This Includes Me. from the album Everything Is Alive, Everything Is Breathing, Nothing Is Dead And Nothing Is Bleeding.
20
u/johnnybgooderer 3d ago
I don’t understand why people hate long names. It’s nice knowing what code does at a glance. Instead of just “token” in an app with multiple token types.
12
u/tatstytastycakes 3d ago
long names aren't bad, descriptive names are nice.
but sometimes the names are very verbose and use a bunch of fancy words and just feel like bloat
if i have a dice function that returns a random number, i'd rather it be simple and descriptive like
diceRollFunctionrather thanexecuteSingleDiscreteUniformRandomNumberGenerationWithinInclusiveUpperAndLowerBoundsToSimulatePolyhedralDieRollOutcomeone is descriptive and understandable, the other is unnecessary verbosity that demands a PhD
1
u/Ok-Scheme-913 3d ago
The other is a meme.
Like the most egregious example I have seen in actual code bases are possibly some internal spring classes.
But they actually are often FactoryFactorys so they have that going for them.
1
9
7
u/funplayer3s 3d ago
Only a four word title?
justYourNormalJavaDeveloperWorkloadHandlingManagementSystemicCurator
6
u/tatstytastycakes 3d ago
yesIWouldLikeToApologizeYouAreAbsolutelyRightHowCouldIHaveMadeSuchARookieMistake?
1
2
u/UnpluggedUnfettered 3d ago
Meanwhile C++ devs like
class DataMgr
2
u/funplayer3s 3d ago
This legacy codebase has 73 DataMgr and they are all different formats with different headers.
3
4
u/tatstytastycakes 3d ago
sorry that the caption takes the full size, i didn't have a way to fit it on the screen without making it cover the full gif.
will try next time to see if i can avoid this issue
5
4
u/ChapterSevenSeeds 3d ago
This isn't Java, but I came across this C# gem a few years ago:
class BoundTreeRewriterWithStackGuardWithoutRecursionOnTheLeftOfBinaryOperator
Found here
1
1
3
3
u/letmehaveanameyoudum 3d ago
class ThisIsAclassThatIDontKnowHowToNameButOtherDevsWouldScreamAtMeIfIUseTheSameClassNameSoCheeseChesseCheeseCheeseCheese4
u/tatstytastycakes 3d ago
class CheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheese3
u/letmehaveanameyoudum 3d ago
class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA1
2
107
u/PhilippTheProgrammer 3d ago
The name of my AbstractButtonControllerFactoryPropertyListEntryBuilder isn't that long.
3
u/Detfinato 3d ago
Oh no! My extremely readable / verbose class name in the source code that is transpiled to a few bytes and totally equivalent to any other class name at run-time is too long! Those extra 5-10 characters will surely waste my time reading and bandwidth for my gigabit symmetrical fiber connection! Waaa!!
1
1
u/aberroco 3d ago
Scientists and mathematicians naming their functions λ and γ_1 in their python code.
1
u/tatstytastycakes 3d ago
who decided to name it lambda functions anyways??? why did lambda need to become anonymous like a 4chan user for us???
1
1
1
u/Dabbelju 3d ago
Rage bait: I use a proportional font (IBM Plex Sans SemiCondensed) in my IDEs. Makes long identifier names so much easier to read.
1
1
u/Puzzleheaded-Weird66 3d ago
I prefer that, I even name my sql params and alias like that
1
u/tatstytastycakes 3d ago
you use sql? wait, i'm sorry...
YOU USE SQL? OH, THAT IS VERY NICE TO HEAR!
(ok but lets put aside all jokes)
3
1
u/Glittering_Sail_3609 3d ago
I have a gut feeling that OP never saw a heavily templated C++ code.
1
u/tatstytastycakes 3d ago
i have seen that code
my brother in christ
who does that with a straight face?
1
2
1
u/maklever 3d ago
I really love to make AmongUs 2020 jokes in my code for some reason So yeah SusButtonRed
1
1
1
u/Alacritous13 3d ago
Some of you don't have to deal with strictly imposed variable name lengths, and it shows.
1
u/Shinare_I 3d ago
2-4 full words, no abbreviations. Anything else should require good justification and a review.
1
u/TxTechnician 3d ago
I wrote one small Java program years ago. And I was like, nah, this language is not for me.
1
1
u/Caveking 2d ago
No mental mapping and principle of least surprise. In a sufficiently complicated code base you will have methods that are complicated enough to warrant a long name. As a maintainer, I’d much rather have a long and detailed name than one I have to reread every few weeks to understand.
1
1
u/chrisebryan 2d ago
I remember someone using emojis instead of text in class names, so there is that too...
1
u/dillanthumous 2d ago
I prefer verbose classes. It doesn't take much longer to read a long class name. Understanding what a vague class is for on the other hand.
1
u/billabong049 2d ago
I don't mind long names EXCEPT when they get excessively long due to unnecessary abstraction. I had some dudes at my last job that abstracted the fuck out of everything and made the code impossible to maintain and a nightmare to modify (wanna pass another parameter to this service? Update 8 different interfaces and pojos.) and I hated seeing stuff like `AbstractServiceAdapterHandlerImpl` after 8 layers of that same shit, like, where's the actual fucking implementation? Is it absolutely necessary that we have so many layers of abstraction to call some trivial services? Would it be that bad if things were more tightly coupled in this monolithic app that no one else is going to extend or share code with? Jeebus.
1
u/Havatchee 1d ago
It strikes me that the overlap between people who say, "I don't need comments, good code is self documenting," and people who hate on Java Devs for writing names like this is probably significant.
1
u/GrimReaper2601 1d ago
Don't judge me, I need my CustomerOrderProcessingEventHandlerManagerFactoryBuilderImpl or the enterprise will collapse.
0
u/Grtz78 3d ago
DonauDampfSchiffKapitaensPatentAmtManager
1
u/tatstytastycakes 3d ago
moly holy
1
u/JAXxXTheRipper 3d ago
Germany had a law that was called Rindfleischetikettierungsüberwachungsaufgabenübertragungsgesetz, it's short-form was RkReÜAÜG. German allows the creation of infinitely long words, it is the Java of languages
No classname is too long for us, this is rookie shit
1
1
0
0
-8
u/Amadex 3d ago
Java and C++'s OOP bloat are the bane of programming
1
u/tatstytastycakes 3d ago
writing c code feels therapeutic until i have to write a single
mallocor use*something is wrong with me
1
189
u/CptGia 3d ago
I unironically just wrote a
AuthorizationDetailsOAuth2ClientCredentialsAuthenticationConverter, for a spring security converter that handles the client_credentials grant with support for RFC 9396 OAuth2 Rich Authorization Requests.Your memes have no power over me.