Employees may spend a fair amount of effort (especially in larger corporations where you find a concentration of regulatory specialists) mining the veins of gold sequestered away between the seams of operations and regulations. Sometimes this is explicitly an objective of management, at other times it is an implicit cultural undercurrent.
How you approach and handle this probably is more influenced by your ethos and personal beliefs than any of your other working relationships.
Society's regulations have both a written and an intentional form; the two are similar but not the same. To me, the intent of the law carries more weight than the letter of the law. You or your coworkers may disagree with the intent of the law, but unless you have a very clear and deep understanding of how the law came about you run a serious risk if violating its intent.
Resolving differences of opinion on this matter should be one of the first things you do before starting any large project that has a potential to move any boundary that affects this balance.
A full 65 to 75 percent of the politics of analysis happens on the boundary between employees and customers. Their interests are misaligned in any business because the distribution of profit margins either goes to one (in the form of wages) or to the other (in the form of competitive pricing). And you are developing a project that will impact sales or profit margin, because otherwise you wouldn't be working on it.
How this boundary moves however is none of your business, it is beyond your concern. Yet at the same time your analysis will sink into the mucky depths of oblivion unless you manage the politics of this boundary to appeal to both sides.
To the employees you must present an image that your creation will make their life easier without jeopardizing their jobs. To the customers (vis a vis the management) you need to present an end point that affords them greater efficiencies and value for their dollar. You may be unable to guarantee that you can sufficiently meet both targets, but it should be your objective nevertheless.
Wednesday, December 14, 2016
Artful Coworkers
Wednesday, November 16, 2016
Artful Query
Every so often I get called upon to troubleshoot the performance of some SQL queries (that I didn't design). Frankly I view this activity as both a waste of time and an indication of severe design failure. Yes it /is/ possible to optimize queries post hoc, and if you must work your way through this task I will give you some guidance shortly. It certainly isn't, however the optimal way to get work done.
First let me explain why this is a design failure. A critical task during development is building a test environment mocked up to full scale. If you fail to do this then you won't fully appreciate how to best design your queries to begin with.
Databases are all about reading data from disk. Yeah sure there is some writing too, but this is typically dwarfed a couple orders of magnitude by the task of reading the data. Databases are heavily IO bound.
Two things contribute to the time it takes to read table data or index pages: the "width" of each row and the quantity of rows. The width of a row is determined both by the number of columns as well as how much data each field contains.
Do you want fast reads? Use narrow tables and indexes (or use vertical partitioning). To limit the quantity of row reads, use horizontal partitioning or appropriate cluster indexing on tables with millions of rows. And guess what, you can't choose the best partitioning approach during development until you scale up.
Understand the above and you will have good baseline strategies for designing queries in the first place. Hence given the chance to "optimize" existing queries, a far better approach (if you have the time) is to refactor the application to take advantage of this knowledge.
Persist sub-queries to narrow temporary work tables. Target your query sequence to limit the selection criteria to the typically minimal rowset before finally joining in the "wide" information.
If you can't afford a full refactoring though, then you will have to resort to basic database query optimization techniques. Learn to understand the "explain plan" and to identify the time resource hogs. Use nolock hints where possible. Experiment with other hints to modify join order. Direct reads by a key are fast, full scans are slow, so build indices on columns used in joins.
Yeah you can soup up your Toyota Corolla queries to run at 160 miles per hour, but it would have been far better to design your queries like a Ferrari from the start.
Monday, October 17, 2016
Artful Bug Squashing
Bugs are just a fact of life in software development: nobody likes to see them, but so many demands confound a programmer’s time that it becomes impossible to design down to every last exception. Sometimes the bugs even pre-exist in the tools that we use, the development environments, or the compilers.
However much I’m reluctant to admit it, all the same we’ve got a vested interest in keeping a fair share of bugs in the works; if our offerings are perfect then we essentially program ourselves out of our jobs. Imagine if all the schoolkids picked up every last piece of trash and wiped down all the tables when they finished lunch. What would all the janitors do?
You can prevent some bugs by utilizing certain development techniques. One of my favorites is to rename all of your variables and functions to make them distinctively descriptive and non-overlapping. This adds another couple of days to the project, but in the long run it pays off twice: first in easier maintenance with standard names. Second the process of editing and replacing catches many bugs by itself.
As I mentioned in an earlier post, another useful trick during development is to make specific plans to keep audit trails (or trace logs). I usually ask the staff to define a global Boolean called Testing that when true should cause nearly all activity to log to external files.
When persisting to a database I prefer to avoid deleting records: instead I include an “obsolete” flag and set it True when the record should be ignored. Depending on the audit requirements of your system you may even prefer to append a copy of a record for modification, so that if necessary you can always go back to prior versions of a row (note however that this strategy is quite costly from a storage perspective).
Legally many systems also need to track the identity of the user and a timestamp when any rows or fields were modified. If you also include a field to identify the module name and version of the modifying process you can greatly aid version-debugging and historical corrections.
Tracking and fixing bugs is an art of its own. Under pressure rank a bug’s squash-priority by the nature of its criticality. Certainly items that involve the health and safety of your clients, your staff, and yourself come first. Items that adversely impact production cycles are the next highest importance. Bugs that interfere with someone accomplishing their work come in third (especially if you lack an immediate workaround).
Next you will have a large hodgepodge grouping of nuisance bugs, resource bottlenecks, and business-critical enhancements. Everything else will likely go into the bottom of your priority list for “when you have the time”. A useful trick-of-the-trade is to dedicate one-half to one day each week for the lowest priority items; that way you can at least address some of them. Keep the list of unfinished items however… at some point several months to a couple years down the road you will want to revisit many of them to see if they still have merit.