Finding the Lowest Value |
Maxs team moved into a new office, which brought with it the low-walled, bee-hive style cubicle partitions. Their project manager cheerfully explained that the new space would optimize collaboration, which in practice meant that every random conversation between any two developers turned into a work-stopping distraction for everyone else.
That, of course, wasnt the only change their project manager instituted. The company had been around for a bit, and their original application architecture was a Java-based web application. At some point, someone added a little JavaScript to the front end. Then a bit more. This eventually segregated the team into two clear roles: back-end Java developers, and front-end JavaScript developers.
Silos, the project manager explained, are against the ethos of collaboration. Were all going to be full stack developers now. Thus everyones job description and responsibilities changed overnight.
Add an overly ambitious release schedule and some unclear requirements, and the end result is a lot of underqualified developers rushing to hit targets with tools that they dont fully understand, in an environment that isnt conducive to concentration in the first place.
Max was doing his best to tune out the background noise, when Mariella stopped into Daltons cube. Dalton, sitting straight across from Max, was the resident front-end expert, or at least, he had been before everyone was now a full-stack developer. Mariella was a long-time backend JEE developer who hadnt done much of the web portion of their application at all, and was doing her best to adapt to the new world.
Dalton, whats the easiest way to get the minimum value of an array of numbers in JavaScript? Mariella asked.
Max did his best to ignore the conversation. He was right in the middle of a particularly tricky ORM-related bug, and was trying to figure out why one fetch operation was generating just awful SQL.
Hrmmmm… Dalton said, tapping at his desk and adding to the distraction while he thought. Thats a tough one. Oh! You should use a filter!
A filter, what would I filter on?
Max combed through the JPA annotations that controlled their data access, cursing the magic that generated SQL queries, but as he started to piece it together, Dalton and Mariella continued their instructional session.
In the filter callback, youd just check to see if each value is the lowest one, and if it is, return true, otherwise return false. Dalton knocked out a little drum solo on his desk, to celebrate his cleverness.
But… I wouldnt know which value is the lowest one, yet, Mariella said.
Oh, yeah… I see what you mean. Yeah, this is a tricky one.
Max traced through the code. Okay, so the @JoinColumn is CUST_ID, so why is it generating a LIKE comparison instead of an equals? Wait, I think Ive-
Ah ha! Dalton said, chucking Maxs train of thought off the rails and through an HO-scale village. You just sort the array and take the first value! *Thumpa thumpa tadatada* went Daltons little desk drum solo.
I guess that makes sense, Mariella said.
At this point, Max couldnt stay out of the conversation. No! Dont do that. Use reduce. Sortings an n(lg n) operation.
Hunh? Dalton said. His fingers nervously hovered over his desk, ready to play his next drum solo once he had a vague clue what Max was talking about. In logs in? Were not doing logging…
Max tried again, in simple English. Sorting is slow. The computer does a lot of extra work to sort all the elements.
No it wont, Dalton said. Itll just take the first element.
Ahem. Max turned to discover the project manager looming over his cube. We want to encourage collaboration, the PM said, sternly, but right now, Max, youre being disruptive. Please be quiet and let the people around you work.
And that was how Daltons Minimum Finding Algorithm got implemented, and released as part of their production code base.
[Advertisement] Manage IT infrastructure as code across all environments with Puppet. Puppet Enterprise now offers more control and insight, with role-based access control, activity logging and all-new Puppet Apps. Start your free trial today!
| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |