- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Wait... what is this doing in the CodeSOD series? This is definitely a Representative Line...
Admin
PostCommentForArticleTopicAndForGeneralSoftwareIndustryStateAndBasingOnMyMoodThisMorningWithoutThinkingForTooLong
Admin
2 letters and 3 digit number - the longest anyone needs for an identifier...
Admin
This looks like a Spring Repository method. If you follow the naming convention, Spring can generate an implementation; e.g. the built-in
findById
method does a primary key lookup. For cases like this, when following that convention produces an awkward name, you can use an annotation ("attribute" for the .Net folks) instead, which lets you name the method whatever you want.Also, the most commonly cited examples of the stereotype that Java has ridiculously long class names are internal to various frameworks, or are taken from huge enterprise projects, both of which have needs that regular projects don't. The only time I've actually seen a class name I'd consider "unreasonably long" was, ironically, during my brief stint at a C# shop (I attribute it to my boss, who wrote it, being a pretentious asshole).
Admin
That is standard Spring Data JPA query method. This kind of method has no implementation, just the name. The Spring framework automatically generates the implementation based solely on the name. They usually are relatively short, like findById or findAllByNameAndAddress, but since you can navigate the object graph, it is possible to be monstrous.
Admin
At least comments for this method are unnecessary.
Admin
This is ugly, but I get it. Probably a holdover "repository" method where you would build out every permutation of how you'd query. Does Java even have the Func<> stuff like C# has where you could build a query object or something to take predicates saying what you want to find by?
Admin
Quite definitely a Java Spring Hibernate repository name. Spring generates the SQL code entirely from the name. I don't think its a WTF. There are rare cases where this would be the correct way to code the method name. i would add a 'synonym' method to the repository class so my application code was more readable, but this method would still be in the codebase.
Admin
My old boss started doing the way too long name thing for classes, methods and folders because "we have Intellisense" (C#). Eventually names would get so long that we couldn't move projects around as zip files because Windows wouldn't unzip due to a too long file path.
Admin
With a name like that, let's hope the function at least does what the name says it does.
Admin
Just wait until you see what the method actually does.
Admin
You had names longer than 32768 characters???
Admin
I don't know spring but if this is a variation on "findById", it looks like the database designers have prepended the table name "CampaignStat" to every colum name, which woud definitely be a WTF
Admin
Some parts of windows have a maximum path length of 255 characters beleive it or not.
Admin
I'm not sure what you mean by "the
Func<>
stuff". If you're talking about lambdas, Java's supported them for a long time; theStream
API uses them extensively to build up functional pipelines. If you're talking about building up database queries, there's a library for that, although people more often use Spring repository methods (they can do a ton of things with fairly minor configuration).Admin
Limiting that to path lengths is optimistic.
And the “Func stuff” in C# is clearly labeled as LINQ (ntbcw Funky Stuff,, which is labeled as a song by Kool & the Gang)
Admin
There is something wrong with any name where, by the time I finish reading it, I can no longer remember the beginning...
Admin
Add an identifier named PostCommentForArticleTopicAndForGeneralSoftwareIndustryStateAndBasingOnMyMoodThisMorningWithoutThankingForTooLong and despair...
Admin
Just left a discussion on FB on first sentences in novels. It is as if nothing has happened at all but yeah... brevity is the soul of wit in creative writing as well as in programming...
Admin
That would be the 260 chars max length of paths in file explorer and other libs in XBox OS ... sorry Windows... I bet it's to prevent overflow hacks since generic length char arrays in c apparently will likely allow that in the hands of most programmers...
Admin
I worked in a few languages back in to 90's that would allow variable, procedure & function names to be as long as you wanted, but only the first x characters would be significant, meaning that AReallyLongVariableName and AReallyLongVariableNameToo would actually refer to the same variable. Made for some interesting bugs...
Admin
He refers to the
IQueryable<T>
interface and the ability to passExpression<Func<T1, T2>>
lambda expressions. Basically, the compiler generates an expression tree which the implementation behindIQueryable<T>
can use to dynamically emit a SQL (or any other type of) query. If I'm not mistaken, what Java refers to as "streams" isIEnumerable<T>
in .NET, which is in-memory collection manipulations. Confusingly, in .NET, "streams" mean byte streams, likeFileStream
,SocketStream
, etc.Admin
Java does have Stream for in-memory collection manipulations, but it also has InputStream/OutputStream for byte streams. Yes, they're really both called streams, despite doing very different things and having very different APIs.
Admin
Yes and no, but mostly no. The core of Windows has a much larger limit (32767 UCS-2 characters plus a UCS-2 NUL), while the 255 (260 including drive letters and trailing NUL, in fact) is a limitation of the surface API. It's now overridable even without the funky notation that enabled the override before. That applications (e.g. Explorer) don't do it is their fault, not the fault of the Windows core.
Admin
That's news to me. C strings (er, character arrays, as you put it) are NUL-terminated, not length-prefixed. And the overall "default" limit exceeds 255, which is the logical boundary case for byte-sized lengths.
Admin
MAX_PATH is actually 260 characters, not 255 characters. You are mixing that up with PASCAL string length. And honestly, this limit only applies to old Win32 APIs which are obsolete for a decade now - if you still using one of those, it's time to migrate to 64-bit like everyone else in the world ;-)
Addendum 2024-05-23 03:21: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
Admin
Given the number of things (mainly, but not limited to, third-party software) that are liable to break if they encounter a path longer than 260 characters, I'd be wary of anyone who disables the limitation.
Admin
I guess congratulations on not having bumped into this one are in order, but yeah, it's a thing: https://stackoverflow.com/questions/1880321/why-does-the-260-character-path-length-limit-exist-in-windows/
Admin
I guess congratulations on not having bumped into this one are in order, but yeah, it's a thing: https://stackoverflow.com/questions/1880321/why-does-the-260-character-path-length-limit-exist-in-windows/
Admin
A friend of my parents at a programming class in the mid 1980s when discussing variable naming:
"John [my Dad and amateur BASIC programmer] only uses one variable and it's called
Q$
.Admin
THIS! A thousand times THIS! By using this (extremely verbose) pattern, Spring will autogenerate the implementation. The alternative is to give a shorter name and provide your own implementation.
Admin
You know, maybe it’s because I’m not a native English speaker, but it never even once occured to me to consider the InputStream/OutputStream API and the new Streams API as any kind of related. For me, they were always two completely separate things and as thus never needed to have any commonalities.