• My Name (unregistered)

    Wait... what is this doing in the CodeSOD series? This is definitely a Representative Line...

  • (nodebb)

    PostCommentForArticleTopicAndForGeneralSoftwareIndustryStateAndBasingOnMyMoodThisMorningWithoutThinkingForTooLong

  • TheCPUWizard (unregistered)

    2 letters and 3 digit number - the longest anyone needs for an identifier...

  • Naomi (unregistered)

    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).

  • Thiago (unregistered)

    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.

  • AP (unregistered)

    At least comments for this method are unnecessary.

  • (nodebb)

    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?

  • (nodebb) in reply to Naomi

    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.

  • KB (unregistered)

    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.

  • Sauron (unregistered)

    With a name like that, let's hope the function at least does what the name says it does.

  • Deeseearr (unregistered) in reply to AP

    At least comments for this method are unnecessary.

    Just wait until you see what the method actually does.

  • (nodebb) in reply to KB

    we couldn't move projects around as zip files because Windows wouldn't unzip due to a too long file path.

    You had names longer than 32768 characters???

  • Tim (unregistered)

    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

  • Tim (unregistered) in reply to Steve_The_Cynic

    Some parts of windows have a maximum path length of 255 characters beleive it or not.

  • Naomi (unregistered) in reply to DocMonster

    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; the Stream 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).

  • Duke of New York (unregistered) in reply to Tim

    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)

  • Steve (unregistered)

    There is something wrong with any name where, by the time I finish reading it, I can no longer remember the beginning...

  • Erwin (unregistered) in reply to Mr. TA

    Add an identifier named PostCommentForArticleTopicAndForGeneralSoftwareIndustryStateAndBasingOnMyMoodThisMorningWithoutThankingForTooLong and despair...

  • (nodebb)

    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...

  • (nodebb) in reply to Steve_The_Cynic

    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...

  • Fizzlecist (unregistered)

    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...

  • (nodebb) in reply to Naomi

    He refers to the IQueryable<T> interface and the ability to pass Expression<Func<T1, T2>> lambda expressions. Basically, the compiler generates an expression tree which the implementation behind IQueryable<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" is IEnumerable<T> in .NET, which is in-memory collection manipulations. Confusingly, in .NET, "streams" mean byte streams, like FileStream, SocketStream, etc.

  • (nodebb) in reply to Mr. TA

    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.

  • (nodebb) in reply to Tim

    Some parts of windows have a maximum path length of 255 characters beleive it or not.

    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.

  • (nodebb) in reply to Erik

    generic length char arrays in c apparently will likely allow that in the hands of most programmers...

    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.

  • (nodebb) in reply to Tim

    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

  • (nodebb) in reply to MaxiTB

    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.

  • (nodebb) in reply to Steve_The_Cynic

    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/

  • (nodebb) in reply to Steve_The_Cynic

    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/

  • (nodebb) in reply to TheCPUWizard

    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$.

  • Sou Eu (unregistered) in reply to Naomi

    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.

  • Bombe (unregistered) in reply to Balor64

    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.

Leave a comment on “Falsehoods Programmers Believe About Name Length”

Log In or post as a guest

Replying to comment #:

« Return to Article