Tuesday, December 27, 2011

So I spent a couple of hours digging around in Visual BASIC code today. We're moving this code from one server to another. The .NET version changed. And the database delete functionality stopped working. Insert and update work fine. Only the delete part broke. It's frustrating.

The code uses something called a Business Facade with LINQ for database access. I personally find it very confusing. LINQ abstracts away the database access. In my mind, LINQ just adds another translation layer between me and the goal. My coworker probably feels the same way about Catalyst with DBIC. So honestly, what's the difference?

Abstraction vs. Simplicity

We use abstractions all of the time in real life. Calendars abstract the march of time so that we can see the interactions. We write checks instead of mailing cash. You look at a gas gauge instead of the fluid level right in the tank. Abstractions make our lives simpler. They stand in for messy details.

Catalyst does that. It hides the mundane intricacies of web connections. No matter how many web applications you write, parsing the URL happens the same way every time. There is only one right way of parsing CGI. And every application does it the same way. Why rewrite that code over and over and over? Catalyst does it once.

DBIC works in similar fashion for database queries...
  • Make the connection
  • Generate the SQL
  • Join related tables
  • And convert it all into Perl data structures
Abstractions help you write working code faster. My Catalyst applications are more documentation than code. And that's a good thing. So what happens when the abstraction breaks? This is the situation we find at work - the abstraction broke. My co-worker finally figured out that the web class calls into Business Facade which calls down into another class that executes a stored procedure that runs a DELETE statement. Yeah - all of that work for something as simple as deleting a record.

An abstraction should simplify details, not hide them. When the abstraction breaks, you can figure out what's happening.

Good Managers Delegate

Delegation happens every day. Your boss's boss asks your boss for something. Your boss then gives you responsibility for getting it done. You do a spectacular job, hand the result to your boss, who then gives it their boss. This occurs across your entire team. So when the manager delegates work to 8 people, that means he received the work for 8 people. What would you do if someone dropped the work of 8 people in your lap? One person doesn't accomplish the same as 8.

Delegation lies at the heart of automation. We delegate work to machines. Machines handle repetitive tasks with aplomb. Humans find them boring. Seriously, I would go bonkers typing in all of our data by hand. The computer doesn't blink an eye when it loads that same data. I delegated my work to the computer and accomplished more by doing so.

Web frameworks are about delegation - not abstraction. A good framework delegates the mundane, repetitive details using a library of proven code. Catalyst delegates the URL parsing to some block of code I have never seen - and don't need to. DBIC delegates table joins to some block of code I have never seen - and don't need to.

Catalyst and DBIC don't hide the details. They tie directly with the lower level details, if you need those capabilities. Both frameworks handle the details by default - helping you the programmer - like a good assistant. Does your framework help?

Thursday, December 22, 2011

Getting the Message Across

What Happened?

So our co-director is estimating the cost of bringing on a new client. Their data is a little different than our normal fare - especially the volume. We don't want to bite off more than we can chew.

The prospective client sent one month's worth of information. A quick look revealed records with no useful text. Then we identified a slew that do not fit our profile. Expert data analysts combed the remaining records flagging them as they went.

In our meeting today, the good doctor and I went over the results. We began by recalculating all of the numbers before. Then we adjusted our estimates based on the actual results. Of course, some numbers did not add up. From that, we remembered changes in the filtering. Change the SQL and boom - everything reconciles again.

All through the process, my co-director made notations on the white board. He started at the top and moved down with each calculation. The progression over time provided as much information as the data. We ended with a range of possible outcomes. And somewhere in that range falls our actual experience.

The folks in this department are professional researchers. I worked for a company that said they made decisions with data. These people live, breathe, and sleep data. It's second nature.

What Did I Learn?

First - always build a prototype. Secondly, the prototype doesn't look like the final product.

In software development, you never do the same thing twice. Every job has some unique twist. After all, if if the job was the same then I could use the same code. The customer wouldn't need me to develop new code. Prototypes help me provide a more meaningful estimate.

In our meeting today, my co-director and I created a prototype presentation. We put together enough to see if the message comes through. I lose sight of that when developing software, The prototype has a purpose - try some new technology, experiment with a new algorithm, or even just identify nasty, hairy edge cases. I lose sight of the message, and start writing the final product. It's no wonder that the customer's think they see a finished product!

Like a good estimate, a prototype needs rough edges. It should crash. The prototype should say things like Menu goes here. This isn't unprofessional. It's honest. Those blemishes provide visual cues that the product isn't finished. And when the software looks better every time, your customer sees real, definable progress.

This just grates on the perfectionist inside of me. Another character flaw to overcome...

Wednesday, December 7, 2011

It's the Economy

Occupy Wall Street, unemployment, federal deficits, tax the rich, Obamacare, conservatives, liberals, Republican, Democrat, spending cuts, tax cuts, capitalism, socialism, big bad banks, golden parachutes, entitlements...

Socialists want to take money away from an executive making obscene amounts. Conservatives defend that income because, well, the executive earned it. Of course he earned it by making bad loans then selling them to other people who lost their money when the market crashed. Now we're back to punishing this fictional executive. Yet we know that socialism is wrong. But the free market failed. Around and around our argument goes - one big, giant circle.

Sadly, I find myself arguing in circles a lot at work. It's a sure sign that I'm solving the wrong problem. Could that be happening here too?

Socialism is wrong. Theft by the government is still theft. Socialism takes by force money or labor that does not belong to the taker. In theory, the taker gives the spoils to someone less fortunate. Look at socialist countries in the real world. You see that the spoils stay with the taker. I consider that pure and simple theft.

On the other hand, the book of Acts describes the early church practicing socialist policies. There must be something good about sharing wealth.

Capitalism too is wrong. It encourages greed and rewards the dishonest. Absolutely free markets collapse on themselves. Then again, capitalism built airplanes and skyscrapers. There must be something good about rewarding success.

The same dichotomy holds true if you compare democracy and feudalism. Each has shining examples of success. Each also has glaring examples of utter failure. Economic structure does not guarantee success or failure. Political structure does not guarantee success or failure. There must be some underlying factor that brought about the successes.

Root Causes

Proverbs sheds light on the subject...

No one can be established through wickedness, but the righteous cannot be uprooted. -- Proverbs 12:3
The wicked are overthrown and are no more, but the house of the righteous stands firm. -- Proverbs 12:7

Corporations are not the problem. The economic system is not the problem. The political climate is not the problem. Our problem comes from wicked people doing wicked things. People possess a will. We impose that will on the world around us - molding the world in our image. Now imagine that image is distorted, bent. What happens to the world?

The righteous care for the needs of their animals, but the kindest acts of the wicked are cruel. -- Proverbs 12:10
When the wicked rise to power, people go into hiding; but when the wicked perish, the righteous thrive. -- Proverbs 28:28
Her house is a highway to the grave, leading down to the chambers of death. -- Proverbs 7:27

Well, it destroys the world around the wicked. Everything a wicked person does destroys those around them. Even when trying to help, a wicked person only hurts. Microsoft brought personal computers into millions of homes. They also put thousands of people out of work with illegal business practices. They set back the state of the art by decades. They hurt the very people they were helping.

Is it wrong to extend unemployment benefits? It doesn't matter. When wicked people enact policy, they hurt the recipients. Extending those benefits will end badly.

Solutions

The opposite also holds true. Put enough righteous people in power and the world takes a different shape. Righteous leaders surround themselves with wise counselors. They create an environment where righteousness thrives. And it too spreads outward.

In First Break All the Rules, Marcus Buckingham and Curt Coffman discuss the role of talent in our work. Talents represent who we are. As we grow, we learn skills that complement our talents. Righteousness is like talent - it describes who we are, not what we do.

What happened to the discussion of character in political campaigns? I don't mean mud slinging throw around insults and lies. I mean real debate about character. Is a candidate honest? Are they self serving? Who's looking at their record, their actions, their speeches for integrity?

Wait, don't issues matter? Well, no. Remember Proverbs 12:10 - but the kindest acts of the wicked are cruel. So even if a candidate does everything you want, enacts every policy you want, in some way it destroys the world around them.

Consider that next November - how will your vote change the world?