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.
Honestly, this swings towards the better use cases for elaborate class names. Everyone looking into the project tree will be able to figure out what that class does, and that's a good thing.
Primarily they exist to prevent naming conflicts. Any improvements to readability are strictly coincidental (And probably a smell with the original name).
Just to make sure we're on the same page, do you mean for example wrapping classes like java.util.Date and java.sql.Date in something named UtilData and SqlDate?
I suppose I can see your point but I think it's a matter of opinion if it results in reduced legibility or not. I personally would rather not directly reference the FQN if I can avoid it.
But I'll accept it's often nicer to just use a more simple name when it's clearly referring to some colocated impl. In that way I'll admit using a package/namespace is fundamentally being used to make things more easy to read (But only within the package it is defined), even if it is using a mechanism to avoid conflicts.
I'm literally just copying the Java name and what it implies, take it up with them. My point is that encapsulating these things properly, you get something that is terse and adequately describes what it is doing.
Now here, it feels like you are comparing apples and oranges here. You can't just dismiss the lost information in the name and call it equivalent. If that name was adequate they could have simply called their class i.e.
AuthCredentialsConverter. Which is more terse than the suggested Auth.Credentials.Converter if terseness should be a concern at all (Usually not since they are hiding behind a sensibly named interface)
you don't need the name to express every component and action that could possibly be taken and their name, despite being longer than any word in the english dictionary, doesn't actually express that much meaningful info in the first place.
You don't need all that fluff to convert a form of credentials in another, and the client or the auth implementation can carry the details for the most part. Sure, my example is not the greatest, but what is there even to go off of.
and in no world is `AuthorizationDetailsOAuth2ClientCredentialsAuthenticationConverter` sane.
like the following barely even means much more than what I wrote when you break it down
AuthorizationDetails
OAuth2
Client
Credentials
Authentication
Converter
but I can guarantee that there is a terse and logical grouping for these things based on what I said.
Well... I wasn't really arguing if it's a good name or not. Once a name gets that long it's due time to break it down and pass in the specifics of the behavior as dependencies. But luckily such a specific name tells me that immediately. As for if it makes sense or not, it's impossible to tell unless we know what was there before that implementation. It could be running in parallel with some nasty legacy ldap auth system or something that it needs to share an interface with. Personally I disagree with the assertion that the name of concretions shouldn't express the actions and methods (*As in how it accomplishes it's action/side-effect, not the actual abstract methods of the interface) used by an implementation. In fact it's pretty much everything I want a type name to express. Leave the abstract high-level nomenclature to the interfaces which consumers will interact with.
If you intend to put it in a package like, idk, org.sweetbabyalaska.app.permissions.converter.oauth2.Auth, I suppose it's alright until you need to start referencing other classes with the name Auth. Because then you're back to using the FQN which isn't any better than the existing name.
But back on track - What I am saying is 1) information is lost when you change the name from what it was to what you suggested, regardless if they are important details or not (Impossible for any of us to tell without seeing the code), and 2) using a namespace (package) doesn't automatically make the name any more or less readable or terse.
Sometimes you really need package protected access. I wish that java had a way to grant package access to a specific class in another package. Alas, it does not without some really weird inheritance shenanigans.
So, this class lives in an app that implements an OAuth2 Authorization Server. It's part of the token endpoint that creates access token JWTs.
First, it delegates to the standard spring converter to extract the client_credentials parameters from the request into an authorization object. Then, it extracts and validates authorization_details from the request's additional parameters, and adds it to the authorization object. This object is eventually authenticated and turned into an authentication principal.
Basically I'm augmenting the JWT that my authorization server is creating with an additional claim that add details to the authorization scopes, turning "can send an email" to "can send an email but only to the domain xyz.example.com"
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.
i think it was to act as shorthands for devs to get quick recollection of the purpose/return types since this was before ide tooltips and whatnot allowed for people to just know automatically what the function's purpose/return types were so they implemented these so that they could recollect easily
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.
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"
"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'"
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.
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"
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.
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.
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.
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).
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."
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!
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.)
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.
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.
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 diceRollFunction rather than executeSingleDiscreteUniformRandomNumberGenerationWithinInclusiveUpperAndLowerBoundsToSimulatePolyhedralDieRollOutcome
one is descriptive and understandable, the other is unnecessary verbosity that demands a PhD
class CheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheeseCheese
class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
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!!
The association of variable-capturing functions with the letter lambda comes from Alonzo Church's lambda calculus. He's one of the original GOATs of computer science
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.
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.
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.
Is a super verbose way to do what python would do in a single line, but you also know 10 years from now, when someone will need to modify that code with new business logic, the full app won't break because you're not here to babyseat things like regex.split()[::-1].replaceAll("X", "") shenanigans
You already know that when PO will ask if we can integrate Json format, add a new allowed bic, change validation rules,... The implem will be cleaned, business and technical issues are already split, ...
Basically: why I got to love Java is because, by design, you can force your legacy code to be easy to maintain. That's not the case if you're not forcing yourself to writr meaningful variable names in python.
don't talk to me or my InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState or my HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor ever again
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
218
u/CptGia 6d 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.
368
u/Luzzgar 6d 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.
82
u/budgiebirdman 6d ago
Oh no, my code is verbose. The shame of people being able to understand it. The horror.
79
u/TeraFlint 6d 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 Foowhose name says NOTHING about what it does.28
u/much_longer_username 6d 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!
21
u/johnnybgooderer 6d 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.
10
u/itsTyrion 6d ago
meanwhile C and Go devs: 1 LETTER, 2 ON A GOOD DAY, TAKE IT OR LEAVE IT
7
u/funplayer3s 6d ago
Only a four word title?
justYourNormalJavaDeveloperWorkloadHandlingManagementSystemicCurator
4
u/tatstytastycakes 6d 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
4
u/ChapterSevenSeeds 6d ago
This isn't Java, but I came across this C# gem a few years ago:
class BoundTreeRewriterWithStackGuardWithoutRecursionOnTheLeftOfBinaryOperatorFound here
3
u/MasterGeekMX 6d ago
For a moment I thought I was on r/MinecraftMemes.
3
u/letmehaveanameyoudum 6d ago
2
u/gain91 6d ago
So like those Isekai novel titles
109
u/PhilippTheProgrammer 6d ago
The name of my
AbstractButtonControllerFactoryPropertyListEntryBuilderisn't that long.3
u/Detfinato 6d 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
u/aberroco 6d ago
Scientists and mathematicians naming their functions
λandγ_1in their python code.1
u/stjeana 6d ago
better than cookie and cake
1
u/donszefo 6d ago
Ekhem https://projects.haykranen.nl/java/
1
u/Dabbelju 6d 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
u/Puzzleheaded-Weird66 6d ago
I prefer that, I even name my sql params and alias like that
3
u/iStumblerLabs 6d ago
Laughs in Objective-C
1
u/Glittering_Sail_3609 6d ago
I have a gut feeling that OP never saw a heavily templated C++ code.
1
u/Rojeitor 6d ago
strategyComandBuilderFactory
2
u/Jediweirdo 6d ago
We live in the age of autocomplete, so such squabble means nothing to me
1
u/maklever 6d ago
I really love to make AmongUs 2020 jokes in my code for some reason So yeah SusButtonRed
1
u/zirky 6d ago
do people not use code complete? like, every ide has code complete. you don’t have to type all that
1
u/Acclynn 6d ago
My first thought to this is that I'm wondering if LLMs might be more token-expensive when working on Java just because of this
1
u/CrimsonPiranha 6d ago
CS first semester joke
1
u/Alacritous13 6d ago
Some of you don't have to deal with strictly imposed variable name lengths, and it shows.
1
u/Shinare_I 6d ago
2-4 full words, no abbreviations. Anything else should require good justification and a review.
1
u/TxTechnician 6d ago
I wrote one small Java program years ago. And I was like, nah, this language is not for me.
1
u/InStars 6d ago
But it's great, just hit Ctrl+N in IntelliJ and type some words you know and BAM - the right class opens!
1
u/NightIgnite 5d ago
My monitor is 1920 pixels wide, Im going to use all 1920 pixels
1
u/Caveking 5d 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
u/Sad_Shop4 5d ago
just imagine writing comments also
1
u/chrisebryan 5d ago
I remember someone using emojis instead of text in class names, so there is that too...
1
u/dillanthumous 5d 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 5d 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 4d 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 4d ago
Don't judge me, I need my
CustomerOrderProcessingEventHandlerManagerFactoryBuilderImplor the enterprise will collapse.1
u/Matwyen 2d ago
If you ever worked on a project spanning multiple years and people, you know
Is a super verbose way to do what python would do in a single line, but you also know 10 years from now, when someone will need to modify that code with new business logic, the full app won't break because you're not here to babyseat things like regex.split()[::-1].replaceAll("X", "") shenanigans
You already know that when PO will ask if we can integrate Json format, add a new allowed bic, change validation rules,... The implem will be cleaned, business and technical issues are already split, ...
Basically: why I got to love Java is because, by design, you can force your legacy code to be easy to maintain. That's not the case if you're not forcing yourself to writr meaningful variable names in python.
1
u/El-yeetra 12h ago
don't talk to me or my
InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedStateor myHasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitorever again0
u/Grtz78 6d ago
DonauDampfSchiffKapitaensPatentAmtManager
0
u/frozen-dessert 6d ago
How to tell you are still in school, without saying you are still in school
0
u/XxasimxX 6d ago
This joke wasn’t even valid 10 yrs ago, how are ppl still making this joke?
-8
u/Amadex 6d ago
Java and C++'s OOP bloat are the bane of programming
1
u/Z3t4 6d ago
I paid handsomely for my UltraWide, and I'm gonna use every damn inch!