Thursday, January 16, 2014

Capitalism - Still A Better Love Story Than Twilight

We live in a capitalist society. And I think that word has become socially distasteful over the years. (To be fair, living any any *-ist society sounds kind of distasteful. Perhaps it's the act of classifying and not the classification itself that's really at the heart of the perception?) We can debate at length as to how and why, or whether or not such perceptions are justified, but that's not what this is about.

I am a capitalist. There's that distaste again. Can you feel it? Just by hearing me say that, can you feel an almost foaming-at-the-mouth either in yourself or in others? After all, this means I'm greedy, doesn't it? It means I worship money, right? That I want to enslave the downtrodden so I can stand on their backs and smoke an expensive cigar?

I really don't think that's what it means. I honestly don't draw such a connection between being an active part of the society in which I live and being Kingpin. Though I've certainly met (or in some way interacted with) a fair number of people who, for whatever reason or set of reasons, don't separate the two concepts. And that's too bad for them, really.

Capitalism is not inherently evil. Are there evil people within capitalist societies? People who lie, bully, extort, and generally do terrible things for personal gain? Absolutely. If you can find me any society in the entirety of human history, capitalist or otherwise, which didn't suffer from that plague then I'm certainly interested to hear about it.

So no, I don't sit around reading Ayn Rand and thinking of ways I can abuse people and take their money. To be honest, I barely only tangentially knew who Ayn Rand was until the accusations of this behavior started to become more frequent. Cursory research on the subject led me to three conclusions about her work:
  1. Her fiction work was awful. I mean really just abysmal. This isn't to say that mine is any better (or even, you know, extant), but that's neither here nor there. If you're curious to learn just how bad it is but don't want to invest the time in reading one of her novels (who could blame you?), know that at the time of this writing parts 1 and 2 of the Atlas Shrugged movies are available for your viewing, um, pleasure. Pay close attention to the forced narrative, un-relatable characters, and absurd storyline.
  2. People who claim to hate her are obsessed with her. Again, the name was barely a footnote in my knowledge prior to encountering such people. Prior to this writing, I don't recall ever once injecting the subject into any conversation. But she sure has come up a lot from other people. I guess I don't see the attraction.
  3. To disagree with her philosophies is a human right. To deny her impact on modern business practices is, at best, naive.
But I digress. A lot. This isn't about the notion that people fervently accuse me of evil deeds simply because I have a fairly successful career. No, this is about a little corner of capitalism that is often forgotten. This is about the idea that just because we're looking at a spreadsheet of numbers doesn't necessarily conclude that we're not doing something good for the world.

That's all it really comes down to, isn't it? A spreadsheet of numbers? Capitalism isn't about being evil. There are no Captain Planet villains who spend billions on a business model that has no customers, only destructive deeds. It's about money. You know, capital. The rules are simple. If the gain outweighs the cost, it's a go. (Of course, there is much disagreement about the "cost" of non-tangibles, such as employee work/life balances or environmental damage. There is much disagreement about a lot of things. Welcome to life.)

At its simplest, if the numbers in Column A add up to more than the numbers in Column B then clearly Column A is the sound choice. All the complaining and arguing in the world isn't going to change the clarity of numbers. However, with a little reason and pragmatism, you can change the numbers themselves.

They're just variables. Values with weights assigned to them. If you desperately want Column B to be the outcome of the decision then your goal is pretty clear. Is your goal to argue? No. Is your goal to accuse the supporters of Column A of malfeasance? That doesn't seem productive either. Indeed, your goal is to get more numbers. What other factors haven't been considered? What other variables can be weighed and accounted? Outside of what other boxes can you think?

Because guess what? That works. I doubt any business leader or board member or what-have-you has ever been under the delusion of knowing everything. Sure, they may put up a front of sorts, because that's part of their job. But business decisions are based on information. And with a goal as clear as one number being greater than another number acting upon information seems like a pretty straightforward activity.

So... What information can you add to the discussion? Keep in mind that your personal opinions, regardless of how much passion you have for those opinions, are not information. Sorry to break it to you, but strongly-held opinions are not facts.

But that's not necessarily evil. No more than the application of the scientific method in research is evil. I dare say that a separation of opinion from fact is a cornerstone of enlightened society. (Though that's just my opinion.)

Now before the accusations fly again, let me assure you that I still realize that there are bad people who do bad things in the world. I toil under no delusion that capitalism by design is "good" (whatever that word means) or benevolent. (There is, after all, a lot of money to be made in standing on the backs of others. I don't personally do that, but it's hard to deny the motivations of those who do.) But just as it's not one extreme of that particular spectrum, it's also not the other.

Somewhere in the middle, in an oft forgotten corner of society, there exist numbers which add up to really, really good things. And when they do, it is indeed the function of capitalism which turns those good numbers into those good things. After all, if Column A is a greater sum than Column B then there's profit to be made. And if Column A also happens to be really good for the world, so much the better, right?

I sometimes refer to this phenomenon as The Lost Dream Of Capitalism. And, yes, I have examples.

Have you seen how Utah is planning to end homelessness? The statement alone sounds pretty good, doesn't it? But surely, surely such an endeavor would be expensive and nobody would want to pay for it, right? Nope. It's actually going to be cheaper. How did they come up with this? Simple. The numbers in Column A added up to more than the numbers in Column B.

The premise is financially sound. A bit of research into some data, pivoted and examined in the right light, led to a fascinating conclusion. The state basically figured out how much money they pay to subsidize emergency room services for care directly resulting from the poor living conditions of the homeless. (This is Column B.) Then they figured out how much it would cost to give apartments to their homeless population and assign them case-workers to help them become self-sustaining. (This is Column A.)

Both columns are a deficit, clearly. Both involve spending tax money. But the two numbers are not equal. While still in the negative, Column A was a greater value than Column B. It was a net gain for the budget. Helping people was deemed profitable. So, in traditional capitalist style, the more fiscally-sound choice was made. And, lo and behold, it wasn't inherently evil.

There are, indeed, a lot of businesses who are actively working toward this same fiscal model. A little closer to home for me is the company Dovetail Health. This is a company which reduces healthcare costs, increases patient care quality, and makes money doing it. (And they're not alone, they're just the only one I know off-hand.)

The business model is simple... Intervene in patient care conditions outside of a hospital setting at periodic intervals for the purpose of preventing further hospital visits. After all, hospital visits are expensive. Really expensive. But with a little bit of in-home intervention and comparatively simple patient care, hospital visits can be avoided. Insurance companies pay less for care (win), benefits-holders pay less for insurance (win), hospitals pay less in overhead (win), patients are healthier and more effectively avoid injuries (win), and finally... the company doing this makes money (win). Where's the evil in that last one again? Cause I'm not seeing it.

By thinking outside of a box or two, shifting the occasional paradigm, or whatever cliche business gobbledygook you want to use, the idea of making money can actually conform with the idea of improving the world in which we live.

It's something people don't often see when they look at the (evil) capitalist society around us. But for those who find it, for those who participate in it, the monetary rewards alone pale in comparison to the profound sense of community and fraternity to be found in not just doing something well, but doing something... good. Therein lies that lost dream of capitalism. Stepping outside the stereotype of nickeling-and-diming everybody into oblivion to squeeze more profit from society, and stepping into the simple notion of putting the right numbers into Column A to actually make the world a slightly better place to live.

It's all too rare, hence the "lost dream." But it's real. It exists. And if I can wish for anything on the subject it would be that the rabid opponents to the very word "capitalism" could step away from their Facebook rants for a moment and actually help with efforts like this. Actually use their intelligence for the better. The world could use better numbers in Column A, it can't use angry Facebook posts.

Tuesday, October 29, 2013

Refactoring Screencasts V

There exist a host of excuses for why it took so long to get these finished. But they boil down to two:
  1. There is no quiet place to record at home.
  2. There is no quiet place to record at work.
The first one is being remedied as we speak, for I'm in the process of moving to a new house and there will be space to set aside for a make-shift "recording studio" in said house. (Which will basically be a table and chair in the basement with some heavy blankets draped around it for sound dampening. But it's something at least. Note, however, that this "being remedied" is a long and drawn-out process, to be followed by the holidays, so I may be quiet for a while. But I digress...)

The second one hadn't been a problem during the summer, when my work mainly involved travel and hotel rooms are notoriously quiet when one is alone. However, for some time now I've been "between projects" and mainly sitting around in the company's office. (Which is not normally where a consultant spends his time.) Again, normally this isn't a problem. We have a conference room for this sort of thing. But another large project has been much taken over our office's conference room, for reasons I'm not aware of but aren't so uncommon to bear going into.

Yesterday, however, the conference room was inexplicably empty. So I was able to knock out the remaining recordings for the Making Method Calls Simpler series in an afternoon. Hopefully they don't appear hurried as a result. In any event, here they are. Enjoy!

Rename Method

Add Parameter

Remove Parameter

Separate Query From Modifier

Parameterize Method

Replace Parameter With Explicit Methods

Preserve Whole Object

Replace Parameter With Method

Introduce Parameter Object

Remove Setting Method

Hide Method

Replace Constructor With Factory Method

Encapsulate Downcast

Replace Error Code With Exception

Replace Exception With Test

Next I'll move on to the Dealing With Generalization series of patterns.

Friday, October 25, 2013

The Left Turn At Albuquerque

Bugs Bunny is lost. Really lost. And looking at a map of his current location doesn't seem to be helping him.
You see, he should have taken that left turn back at Albuquerque. Unfortunately, he missed that turn and just kept going in the wrong direction. And kept going, and kept going. Where is he now? Is this place even on his map? One thing's for certain... Getting from where he is now to where he wants to be isn't going to be easy. His original intent assumed a left turn at Albuquerque, so by definition everything he's done since then has been wrong.

This happens to programmers a lot. Invariably they find their way to Stack Overflow to ask a question about where they should go next. And very often they get a series of comments similar to this:
"Why are you doing it that way? There's no need for that. You're doing something else wrong."
It seems unhelpful on its face, but it's exactly the problem the programmer is facing. He's trying to solve a problem that he shouldn't have in the first place. And he's getting frustrated by the fact that there isn't a readily available solution to the problem that he just invented.

How should Bugs Bunny get to where he's going? Well, we don't know. We'll never know, because he didn't tell us where he's going. Nor did he tell us where he came from. We don't know the problem domain that he's trying to solve.

The programmer needs to step back for a moment and examine the bigger picture. It's not that we don't want to help him solve his problem, it's that we don't know what the actual problem is. And we need to know that to be of any use. Sure, maybe we can help him with his current roadblock. Then he'll just come back in an hour trying to solve his next roadblock.

If Bugs Bunny's tunnel encounters a massive outcropping of rock, he's going to ask someone how to get around that rock. And maybe they'll show him. Great, now he's on the other side of the rock. But is he any closer to his destination? We don't know, because that's not what he asked us. He only asked us how to get around the rock.

The programmer took a wrong turn somewhere. Perhaps a very wrong turn. Perhaps somewhere a long time ago. We don't know. All we know is that the sequence of steps, with no weights assigned to them to provide any perspective, went something like this:
  1. Programmer performed Step 1.
  2. Programmer performed Step 2.
  3. Programmer messed up on Step 3.
  4. Programmer figured out how to perform Step A.
  5. Programmer figured out how to perform Step รพ.
  6. Programmer got stuck on Step ± and asked for help.
  7. Programmer became frustrated that the help didn't get him any closer to Step 10.
  8. Rinse, repeat.
We want to help this programmer. We really do. But we can't unless we know the actual problem he's trying to solve. Not the immediate roadblock he's facing right now, but the actual problem being solved.

I guess if there's any piece of advice I can give from this little rant, it's this...
  • Never assume that everything you've done until now has been correct.
  • Never assume that just because you got something to work it means you're any closer to your goal.

Saturday, September 21, 2013

Refactoring Screencasts IV

Continuing the series, here are the screencasts for Simplifying Conditional Expressions.  Enjoy!

Decompose Conditional

Consolidate Conditional Expression

Consolidate Duplicate Conditional Fragments

Remove Control Flag

Replace Nested Conditional With Guard Clauses

Replace Conditional With Polymorphism

Introduce Null Object

Introduce Assertion

Tuesday, September 3, 2013

Refactoring Screencasts III

I know, this took a lot longer than expected. But it's been an interesting summer employment-wise. Lots of travel, lots of experiences, etc. I finally finished this series though, and have continued well into the next one.

It's worth noting that I skipped three of the patterns in this series.
  • I skipped Self-Encapsulate Field because the differences in how inheritance work in C# vs. Java were getting in the way, and ultimately the C# version was essentially identical to Encapsulate Field.
  • I also skipped Duplicate Observed Data because a lot has changed over the years in terms of data binding and the tooling that's available.
  • And I skipped Replace Record With Data Class because in modern tooling it seemed really similar to Replace Array With Data Class. (Though it's likely that I missed a key point/difference.)

Without further ado, here are the videos for the Organizing Data patterns:

Replace Data Value With Object

Change Value To Reference

Change Reference To Value

Replace Array With Object

Change Unidirectional Association To Bidirectional

Change Bidirectional Association To Unidirectional

Replace Magic Number With Symbolic Constant

Encapsulate Field

Encapsulate Collection

Replace Type Code With Class

Replace Type Code With Subclasses

Replace Type Code With State/Strategy

Replace Subclass With Fields