Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
Search - "jquery"
I’m surrounded by idiots.
I’m continually reminded of that fact, but today I found something that really drives that point home.
Gather ‘round, everybody, it’s story time!
While working on a slow query ticket, I perused the code, finding several causes, and decided to run git blame on the files to see what dummy authored the mental diarrhea currently befouling my screen. As it turns out, the entire feature was written by mister legendary Apple golden boy “Finder’s Keeper” dev himself.
To give you the full scope of this mess, let me start at the frontend and work my way backward.
This function allows the user to better see the rows in the API Calls table, for which there is a also search feature — the very thing I’m tasked with fixing.
It’s worth noting that above the search feature are two inputs for a date range, with some helpful links like “last week” and “last month” … and “All”. It’s also worth noting that this table is for displaying search results of all the API requests and their responses for a given merchant… this table is enormous.
This search field for this table queries the backend on every character the user types. There’s no debouncing, no submit event, etc., so it triggers on every keystroke. The actual request runs through a layer of abstraction to parse out and log the user-entered date range, figure out where the request came from, and to map out some column names or add additional ones. It also does some hard to follow (and amazingly not injectable) orm condition building. It’s a mess of functional ugly.
The important columns in the table this query ultimately searches are not indexed, despite it only looking for “create_order” records — the largest of twenty-some types in the table. It also uses partial text matching (again: on. every. single. keystroke.) across two varchar(255)s that only ever hold <16 chars — and of which users only ever care about one at a time. After all of this, it filters the results based on some uncommented regexes, and worst of all: instead of fetching only one page’s worth of results like you’d expect, it fetches all of them at once and then discards what isn’t included by the paginator. So not only is this a guaranteed full table scan with partial text matching for every query (over millions to hundreds of millions of records), it’s that same full table scan for every single keystroke while the user types, and all but 25 records (user-selectable) get discarded — and then requeried when the user looks at the next page of results.
What the bloody fucking hell? I’d swear this idiot is an intern, but his code does (amazingly) actually work.
No wonder this search field nearly crashed one of the servers when someone actually tried using it.
"We use top of the art, endgame, final boss, super technology"
What they actually use: Java 1.8, jQuery, JSP and an old version of bootstrap
Why is this still a thing?2
Its most enjoyable when you are working on a codebase that was cleary planned and thought out beforehand. Bugs are easy to fix, features are easy to make because you already have a blueprint of how its supposed to look, modifying features is easy because you already know where to look to make the changes. You can work with plain jquery or fucking visual basic and youll still have a better time then with any modern framework if you have that.
Do you want to know why all the popular open source projects have less-than-optimal, sometimes really dirty code?
It's because their developers ditched all the unnecessary stuff to just get the damn thing done. When I choose an open source dependency, I don't need unfinished stuff. I need a stuff that works and has all the features I need from the very start. If it works, I don't care about code quality in my deps.
This is the reason why dirty, rushed stuff with a great idea behind it gains popularity. PHP, Git, jQuery, the list is quite large.
While you've been busy polishing your files hierarchy, these guys already shipped their product, gained adoption, and their userbase doesn't need your product anymore.
This is applicable only for true open source, not "it's developed by a full-time team of principal developers and the CTO is fucking Kent Beck, it costs $1m per month but yea we have it on github".3
It’s a huge nightmare to develop a React front-end when:
- you have to adapt Bootstrap 3/jQuery based components to React
- the “back-end” is a sparse collection of micro services with cryptic URLs and finding the correct name means searching on a laggy WSO2 API manager
- the documentation of said micro services can be outdated and that means wasting a lot of time trying requests on cURL rather than in doing actual development and continuously breaking your concentration
- sometimes the micro services just become unavailable altogether
- the back-end shuts down at
6PM everyday, usually when after I finally achieved a flow and I’m doing meaningful progress2