One fundamental attribute of good code is cohesiveness. A function with good cohesion does only one thing and does it well. There's plenty of material on this subject in books and on the web.
Sometimes, a good metaphor really brings it home. The current financial meltdown may illuminate the value of cohesion.
The problem with today's banks is that they were trying to do two things.
1. provide banking services to the public (individuals and companies): take deposits and make loans
2. trade and invest for profit
If a company loses money trading, no one really minds. If banks were only trading for profit (or a loss in today's market), we'd let them go under quietly, like the hedge funds.
Unfortunately, because they're also running banking services, people start worrying about access to their cash. The panic of a run on the banks would cause a global calamity. (We're talking large and institutional investors; deposits of small investors are generally guaranteed by the government.) In addition, because the banks need to manage their cash due to their trading and investment losses, they've stopped making loans. Solvent businessses who need a short term loan to expand or cover sudden cost spikes can't get funds.
As a result, we have to support the entire bank, even though we really want to only keep the banking services part. The cost of this lack of cohesion? $700 billion and counting. And that's just maintenance -- doesn't include refactoring.
Sadly, we once had a more cohesive system. It was called the Glass-Steagal Act, the expressed purpose of which was to "prohibit the large private banks whose chief business is investment business, from receiving deposits".
When was Glass-Steagall enacted? During the Great Depression, in order to prevent another global financial crisis.
What company was the the impetus for its repeal? Citicorp. They wanted to merge with Travelers insurance. Yes, the same bank that has received the most bailout funds and will be forced to break up. Here's a brief history.
Your code isn't going to cost $700 billion to maintain, no matter how badly written. But, as a percentage of your staff's time and budget, a systemic lack of cohesion makes a huge impact. Eventually, the changes required can overwhelm your ability to do anything without massive investment, e.g., throwing it away.
No comments:
Post a Comment