| « Sponsor Appreciation, The Server Room Switch, Woody, and More | Gaming the System » |
When Eli accepted a position nicknamed The Marshal, he knew he’d be in for a challenge. For many years, the company’s culture was dominated by cowboy coders and a frontiersmen attitude of just get’er done. Though many of the code-slingers had long since retired, the spirit of the Wild West still remained.
Strewn across the vast corporate expanse were dozens and dozens of ghost applications that weren’t on any IT Systems map, yet were still used by various business units. Some were small, living on an old workstation under a desk, while others were large, forgotten systems that once were fertile pastures of development.
Bringing law and order wasn’t something that could happen overnight, but Eli knew exactly where to start: the database. If he could simply choke the supply of queries to and from Oracle, scofflaw applications would have no choice but to turn themselves in with “access denied” error messages. Sure, the handful of applications that used illicit database engines would continue to elude justice, but those could always be caught another day.
After turning off free-for-all database access, it didn’t take long for the “access denied” messages to come up. In fact, one of the first offenders was an application that seemingly didn’t even need database access: a simple budget estimator. Since no development team took responsibility for the years-old app, Eli rolled up his sleeves and got his hands dirty wrangling with code.
public double calculateCostSQL(double cost,double discount){
ResultSet rs = null;
double resp = 0;
try{
String quer = null;
quer = "SELECT "+cost+" - "+discount+" result FROM DUAL";
rs = dbm.query(quer);
if(rs.first())
resp = rs.getDouble("result");
}
catch(Exception e){
e.printStackTrace();
}
finally{
try{
if(rs != null){
rs.close();
rs = null;
}
}
catch(Exception e){
e.printStackTrace();
}
}
return resp;
}
There was no fathomable reason why anyone would need to bring in Oracle for a simple subtraction, and Eli didn’t give it a second though. He simply strung up the code and put it out of its misery, replacing the entire body with a simple return cost-discount;.
|
Oracle is great for all things enterprise. Enterprise data storage, enterprise basic mathematics, it has it all!
|
|
(evil laugh) Layers!!!! (even more evil laugh) We MUST have MORE layers!!!!
|
|
I would replace this with a call to a local instance of Excel. Perhaps I'd be even more creative and use a JavaScript ScriptEngine to evaluate the string.
|
Why not integrate it into the workflow? Make calculateCostSQL a "Human Task", so whenever invoked an automated email containing the parameters is sent to a Senior Arithmetic Analyst, who performs the subtraction (using a database), pulls up the Subtraction Response form, and submits the difference, which is then placed in the Cost Calculation queue for the application to receive. Sure, it needlessly slows processing time, but it evenly distributes the work over more company resources. |
|
Actually, there is a valid reason for performing it in this manor. As is a somewhat common occurrence on high performance, virtualized environments like the one this enterprise application was running on, mathematics chips fail on local machines.
By utilizing the mathematics processing system (MPS) functionality on the Enterprise edition of Oracle 9g+, you can be assured that whilst a numerical operation may fail due to a similar mathematics chip failure, it will fail consistently throughout the entire organisation, meaning that it only needs to be repaired and adjusted in one place to fix it company wide. This simply makes sense, from a time saving and code quality point of view. This is why I always code a fresh operating system for every application I release. |
| « Sponsor Appreciation, The Server Room Switch, Woody, and More | Gaming the System » |