- 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
does not indentifiers differ only in frist 31 characters?
Admin
Beats the longest I have seen at 82 characters which was written by supposedly the companies best developer which was:
MedicationsWithZeroQuantityOnPrescriptionsNotOfRecordForNotesValidationRuleFactory
Admin
At least it was like that for an Pascal dialect for CP/M long time ago. Did debug this for a fellow programmer back in the 80th
Admin
C99 bumped to 63 letters. Not checked later standards.
Admin
My belief is that longer method names are fine when they increase clarity. This? This does not increase clarity.
Admin
Who says longer isn't better? Where I am we have functions that easily exceed 4000 lines (it's fun debugging :) )
Admin
So... I expect Spring to make functions like "And/Or (Not) TitleIgnoreCase", "Flags Null/NotNull" etc.. And that for multiple variables.
So that's a lot of redundant code. Still I'm wondering, how would this be easier then having one function (handwritten) with multiple input parameters?
But... as long as it works... right? :#
Admin
TRWTF is Spring and its method name to SQL conversion. Dear Java programmers, come to .net where LINQ solves this beautifully.
Admin
Is it just me or is everyone seeing the navbar overlapping the top half of the article title? I frist noticed this about a week ago.
Admin
What is a notorious? I think I might want one.
Admin
The more I think about it, the more horrible it seems to be. Who in their right mind decided to say, let's put a subset of a programming language inside a method name? Unbelievable. I don't think even PHP has this level of craziness.
Dear Java programmers, even if you don't run screaming into .NET after this, please please don't ever use this abomination. Not even once, not for any reason. Never.
Addendum 2018-10-22 14:51: *Abomination of an ORM feature.
Admin
THAT'S NOT HOW SELF-DOCUMENTING CODE WORKS!
There. Now that I've got that off my chest: what does that method name translate into SQL as? (Wow, even the question feels like a category error.)
Admin
You obviously have little idea about the usefulness of this library. As Remy wrote,
List<Whatever> findDistinctByTenantId(String tenantId);
is easy to read, easy to write and quite self-documenting.
I still wouldn't do it for any more than a single variable, though.
Admin
postFristPostUnlessFristAlreadyPostedThenPostBlakeyRant
Admin
Ah! This inspires a solution to the other "constants" problem! This can avoid those Constants classes containing --- well --- constants, thousands of them. Instead they could be auto-generated. So whenever you use
, the system will automatically convert it to !No more hard-coded constants!
No more tedious long files containing thousands of constants definitions!
Admin
This may not be the [stupidest] method name ever, but it’s certainly a strong contender.
Admin
Or just use annotations with SQL or any DSL for that matter
@Query("INSERT your_query CAST AS any(domain_specific_language) WHERE programming_language="Java"") Result<> function(DSL dsl) { [...]
Admin
344 characters long? STAHP!
Admin
This was my submission, and to my coworker's credit, he knew this was utterly crazy and only did it to see if it was possible. All of our other repository methods have much more sane names.
To Watson who asked what the generated SQL is: "select distinct ad0_.ad_id as ad_id1_1_, [...15 more fields...] from ad_t ad0_ left outer join flag_t flags1_ on ad0_.ad_id=flags1_.ad_id where ad0_.tenant_id=? and (upper(ad0_.title) like upper(?)) and (flags1_.flag_id is not null) and flags1_.resolution_type=? or ad0_.tenant_id=? and (upper(ad0_.description) like upper(?)) and (flags1_.flag_id is not null) and flags1_.resolution_type=? or ad0_.tenant_id=? and (upper(ad0_.email) like upper(?)) and (flags1_.flag_id is not null) and flags1_.resolution_type=? or ad0_.tenant_id=? and (upper(ad0_.contact_name) like upper(?)) and (flags1_.flag_id is not null) and flags1_.resolution_type=? order by ad0_.post_date desc, ad0_.title asc limit ?"
This is my first time inspecting that SQL. It appears to be a pretty literal translation of the method name, which generates SQL as inefficient as the length of the method name would imply. I might push a little harder for a refactor of this after checking out the SQL.
Admin
ORM in general are garbage. Some are a better abstraction, but at best its still a leaky abstraction. The queries may start out simple and lend itself well to these kinds of solutions, but inevitably they always get more complex. I find it just easier to write out the sql by hand rather than have to know the ORM works AND how sql queries work.
I was unaware Spring Data did this kind of thing. Grails with its GORM is another notorious offender of this "style".
Spring JDBC is a good middle ground above jdbc: it doesnt hide the fact that youre dealing with SQL, but reduces a lot of the boiler plate (not all of it) needed to ask the database a question. If your data is best modeled by objects, then why use relational data? You should consider using a NoSQL database. That would avoid the object relational mismatch problem altogether.
http://seldo.com/weblog/2011/08/11/orm_is_an_antipattern https://www.yegor256.com/2014/12/01/orm-offensive-anti-pattern.html