Wednesday, February 8, 2012

Why a Career Can Suck if You Make it Suck

A colleague came across this old blog post yesterday, in which some random blowhard rants about how computer programming is a terrible career.  It's a long and somewhat painful read, but I still read it.

As another colleague put it, this person proves the adage: "Blogging is not writing. Blogging is graffiti with punctuation."  (Or so I wrote on my blog.)  And, despite the irony of following in kind, this is very much true.  The author is simply ranting to anybody who cares to listen, offering no real substance.  (Again, the irony of me saying this is not lost.)

Now, to be fair, there did exist the occasional nugget of insightful commentary in that rant.  But the noise to signal ratio was a bit high to really glean much from it.  I'll see what I can do, though...

Temporary Nature of Knowledge Capital

In this section the author describes the plight of the computer programmer in an ever-changing world of skill sets.  It's a challenge we face as an industry, that much is true.  But statements like this give me pause:
"I’d make the case that it’s better to hire the 27-year-old because he is still at the stage of his career where he enjoys the stuff and is therefore more motivated to learn and work harder, while the 60-year-old is surely bitter about the fact that he’s getting paid less than the younger programmers."
What the author basically just said was that old people are stupid and angry and shouldn't be hired.  No wonder he sees the career as a dead end.  He assumes that, as he gets older, he's not going to want to learn or do anything anymore.  Hopefully nobody makes the mistake of hiring this guy, because apparently his plan is to stop developing his career.  And here's a clue as to why this is his plan:
"Because of the temporary nature of the knowledge capital, computer programmers quickly reach a stage in their career when their old knowledge capital becomes worthless at the same rate as they acquire knew knowledge capital. Their total knowledge capital is no longer increasing, so neither does their salary increase. They have reached the dead end plateau of their career, and it happens after less than ten years in the field."
Apparently he thinks that, after being in the field for ten years, he's learned everything he'll ever need to know.  And apparently he thinks that the tools he uses are the only things he can learn.  Forget things like design patterns or language constructs in general, he seems to only know or care about a tool.  And he plans to forget how to effectively use his tools as he learns new ones.

I think I have an idea as to why his salary is no longer increasing.  It would appear that he's getting old and has decided that he can't improve anymore.  Well, that's why other programmers get paid higher salaries.  They continue to improve.  It's called competition.  Get used to it.

Low Prestige

He opens this section with this:
"Computer programming is a low prestige profession. This is evidenced by the fact that people from affluent families rarely go into computer programming but instead will seek out the more prestigious professions such as law, finance, and medicine. Of course there are some exceptions. There was a programmer who worked for me whose father was a doctor. But more typical was another programmer who never finished college and whose favorite hobby was hunting."
This isn't low prestige.  This is low self-esteem.  So... the guy whose father was a doctor has some kind of different educational and/or social status than the guy who liked to hunt?  I'm sorry, I don't see it.  Maybe by coincidence these two people did come from very different rungs on the social ladder, but the author seems to think it has something to do with doctors and hunting.  Sounds to me like he came from a less affluent family and he's just mad about it.  You're an adult now, buddy.  Get over it and move on.

Then there's this gem:
"There is a prestigious school, the Massachusetts Institute of Technology, devoted to science and engineering, and while I’m sure that there are some students there who are majoring in 'computer science,' the science that’s taught isn’t related to the dirty low-prestige job of creating e-commerce websites using ASP.NET. On the other hand, practical computer programming is a popular major at bogus for-profit schools like Devry 'University' and the 'University' of Phoenix."
Wow.  Just... Wow.  He's right about one thing... Universities often don't teach courses in grunt work application development.  This seems to go back to his earlier implication that there's nothing else to learn in software development other than how to use a tool.  (Or, to put it more bluntly, how to drag a little picture onto a design surface, set some properties, and pretend you just did something difficult or interesting.)  No, I'd much rather see universities spend time on something a little more... academic.  Theory, design, software life cycle, core concepts, all those lovely things.

Again, it sounds to me like this guy is just self-loathing here.  He didn't come from money, and he's mad about that.  He didn't go to a big name university, and he's mad about that.  Etc.  Throwing in that jab at schools like DeVry and UoP isn't really constructive either.  So, to add to his earlier point about how there exists only ten years worth of knowledge to be learned, he's now saying that it all depends on where one went to school.  Horse shit.

Again, the author needs to grow up and be a professional.  Within a couple years of leaving school, the school no longer matters.  At all.  Does his education still take up a third of a page on his CV like it does with junior developers?  People who have been in the industry for ten years or more barely even mention it.  The degree received along with where and when it was received is nothing more than a footnote on a professional CV.  But then, he apparently doesn't learn anything new to advance his career, so what else would he add?

To further support his argument, he quotes a student:
"As a Chinese immigrant at the University of Virginia wrote, 'whatever your position is, as a CS person, you are socially classified as a geek. At my school, University of Virginia, being a rich frat boy and having a future in investment banking or law gets you a lot further status-wise even though you may not necessarily be paid more.'"
Allow me to translate... "I'm a college student who studies some kind of science.  People call me a geek.  Jocks are more popular.  That's not fair."  Note that, in his argument about how a career in computer programming sucks, he is supporting his views by quoting a student, someone who hasn't had a career in computer programming.

The Foreignization of Computer Programming

This entire section basically boils down to... "There are too many damn Indians in programming.  I hate that."  At one point he steps aside for a moment to explicitly state that he's not trying to sound racist and that the "foreigners" with whom he's worked are nice people.  Now, see, he wouldn't have to explicitly try to defend himself as not sounding racist if he didn't sound so damn racist.

But let's not play the race card.  Let's take a look at things he actually says:
"Computer programming (along with nursing) has been specially targeted by our government for foreignization."
Citation, please?  I didn't think so.  Granted, this was written a few years ago and off-shoring was big at the time.  My observations in recent years tell me that it's been dying down a bit because the total cost of ownership from always going with the lowest bidder is starting to make its way onto people's spreadsheets, and perhaps software quality will start to become a more important factor as a result.  (Uncle Bob just smiled when I typed that, I'm sure of it.)  So, as I mentioned at the beginning, there was a faint glimmer of a point to be made in this ramblings.  But he failed to effectively make it.

Project Management Sucks Too

This was the section that I feel had the most potential for insightful content.  The author's mistake here, however, is that he opens with this:
"In order to escape a job where the future is bleak for older programmers due to the rapid depreciation of computer programming knowledge capital, computer programmers face the need to move up to management or likely wind up as underemployed fifty-year-olds, only suitable for lower paying IT jobs like 'QA' because they no longer know how to use the latest and supposedly greatest programming tools."
So he bases the entire argument upon an earlier flawed premise whereby he assumes that there is no further upward mobility for a programmer once he's been writing code for ten years.  I assure you that there is.  (Not to mention that he demonstrates a complete and utter disrespect for QA professionals, which just further solidifies my observation that he doesn't actually know much about software development and is nothing more than a code monkey who picked up a book on .NET, dragged controls onto forms for a few years, and never learned anything of substance.)

I do like his observation about how project managers aren't really "managers" in the corporate organization chart sense.  In my experience that is often the case.  So I can see where it's a bit of a misleading title.  I have a kind of a love-hate relationship with project management.  I hate doing it, and I love working with someone who's good at it.  He's right when he says that writing status reports blows.  And he comes close to making a good point when he says that upper management values project management simply for those reports and charts and graphs that make upper management feel happy.

Now, of course, there's a lot more to project management than just writing status reports.  (At least there is for real project managers, not random business folks who are just given the title of project manager.)  Tracking work items, clearing road blocks, maintaining communication across teams and disciplines, and in general facilitating the work of the other members of the team.  (Apologies to any project managers who want to modify or add to that list.  I genuinely don't know a lot about project management, and I'm really glad that you do.)  This is invaluable.  Putting a bunch of programmers into a room, no matter how good they are, does not ensure good results.  Adding a project manager to the mix does not, by itself, ensure good results either.  But that doesn't invalidate the position.

He's right about one thing... If one doesn't want to make the transition from programmer to project manager, then one shouldn't attempt it.  Indeed, if one doesn't even know what project managers do, then one shouldn't volunteer to be a project manager.

In the midst of all of this nonsense, however, he does make one really good point:
"This trend, in which people without computer programming experience manage computer programming projects, is a result of the low prestige of computer programming. People with high prestige jobs, like surgeons, would never allow themselves to be managed by non-surgeons. In a complicated medical procedure there will be a head surgeon overseeing the surgery, and not a project manager without any medical training. Lawyers have Model Rule 5.4 which makes it unethical for non-lawyers to manage lawyers."
This reminds me of Robert Martin's ongoing point (or perhaps even crusade) about how, as an industry, we need to become better at self-regulating.  (Yes, I mentioned his name twice in one blog post.  It's not fanboyism, it's just that his writings have brought forth a lot of good points about the industry in general.)  Indeed, it always bothers me when technical decisions about the software are being made by non-technical personnel.  (Or, even worse, by former technical personnel who failed to advance their technical careers and just went into management by default as a result of seniority... which I feel is the author's path, unfortunately.)  We do need more crossover between skilled developers and skilled management, because the reality is that non-technical personnel (the people who created and continue to run the majority of businesses which employ us) call the shots.  Many of them are even very good at calling the shots, and have successful businesses to prove it.  But in their calling of said shots, they need someone who speaks their language.  They are under no obligation to learn anything about software development, and it's our job as professionals to communicate our recommendations and requirements effectively.

The Working Conditions Suck

This can happen anywhere, honestly.  My mother works in a grocery store, and the conditions suck.  A friend of mine is a police officer, and the conditions suck.  It's more about the employer than the industry.  Yes, programmers are often left behind when it comes to office working environments.  This is, of course, not unilaterally true.  But, as with any profession, it does happen.  This is why it's important to continue to improve one's skills and professionalism, so one can find better jobs.  If, as is the case with the author's original premise, one simply gives up on learning anything new and stagnates in one's career, then one shouldn't be at all surprised that one can't find better opportunities.  Perhaps instead of just blaming the industry and whining about it, the author should take some initiative and advance his career.

For a look at the author's professionalism, let's see what he says here:
"If you walk over to the graphic arts department, you will see really big monitors. The graphics people could surely make do with smaller monitors, but even though they make less money than computer programmers, they have been able to convince higher level management that their work requires better hardware. When computer programmers request better hardware, they are often seen as whining geeks who just want to waste the company’s money on unnecessary high-tech toys."
Writing is a text-only medium, so tone can be difficult to convey.  Was he being sarcastic, or did he genuinely just say that "the graphics people could surely make do with smaller monitors"?  In his plight for better working conditions, he just did the exact same thing that he claims other departments are doing.  He claimed that "those guys don't need it, I need it."  I would think a better point would be that everybody needs it.  That's part of being a professional... respecting other people's jobs.

And what, exactly, was his point with "even though they make less money than computer programmers, they have been able to convince higher level management that their work requires better hardware"?  That was even more condescending than his earlier remark about QA.  His overall lack of professionalism is superbly exemplified here.  Honestly, I can't even formulate a response to this part, so I'm just going to walk away.

But before I do, I'll draw one last bit of attention to the end of that paragraph.  Yes, the graphic arts department has convinced management to provide better hardware.  And, yes, when the author tries to do the same he is seen as a whining geek who just wants high-tech toys.  But, given his other statements in that paragraph and throughout his post in general, I'm inclined to believe that this has less to do with the fact that he's a programmer and more to do with the fact that he's an unprofessional whiner.  Management can smell that from a mile away.  If the sum total of his plea to management was nothing more than, "But they got new monitors!  I want a new monitor!  That's not fair!" then it's pretty plain to see why he didn't get his way.  As I said earlier, it's our job as professionals to communicate effectively.

So What's a Good Profession?

Here he closes his argument by telling people that they should just be accountants or lawyers instead.  I definitely don't follow the logic here.  It seems like he just trailed off and forgot to write an ending for his diatribe.  He reasons that one can only be a lawyer if one graduates from an ivy league school, and one can be happy as an accountant because one can still do that when one is fifty years old.  (Which again reiterates his notion that he doesn't plan to advance his career in any way after doing it for at least ten years.)

So, if someone is passionate about software, but doesn't see a lot of money in it, then one should just choose a career with more money even though one is not passionate about that profession?  Wrong.  Just plain wrong.  If one is passionate about those other fields, then they're certainly options.  But if one isn't inclined to care about those fields in the first place then how can one expect to excel in them?

Ultimately, I don't recommend taking career advice from someone who hates their job, doesn't have any ambition to excel in that job, is horrendously unprofessional, and believes that the mark of a good career choice is decided primarily by which kids were more popular in school.

Monday, January 23, 2012

Stored Procedures and SQL Injection

Every once in a while in my career, I hear some speak some variation of the following statement:
We should use stored procedures because that will prevent SQL injection attacks.
And it causes me pain every time I hear it.  Why?  Because it's incorrect, and worse because it's a dangerous mentality to espouse.  There is no magic bullet.  There is no one thing to do or one policy to implement which would keep one's code and servers safe from nefarious forces.  And statements like the one above make it very hard to explain to people that:
Security is a process, not a product.
Recently I was asked to come up with an example of how a stored procedure could be open to a SQL injection attack.  ("Asked" is a generous word.  The body language implied more of a dare, with a hint of a scoff.)  Sure, no problem.  Here it is:
CREATE PROCEDURE [dbo].[ThisIsATest]
@clause nvarchar(20)
AS
BEGIN

DECLARE @SQLQuery AS NVARCHAR(500)
SET @SQLQuery = 'SELECT * FROM [User] WHERE [user_name] = ''' + @clause + ''''
EXECUTE sp_executesql @SQLQuery

END
And you call it with this:
EXEC  [dbo].[ThisIsATest]
      @clause = N'test'' OR 1=1--'
It's a contrived example, but understand that I didn't write this example from scratch. I pulled it from production code (someone else's) and simply changed the names, removed pieces unnecessary to the example, and added the injection in the calling code.

Now, this isn't rocket science.  The input just needs to be escaped.  The point that I was making in the conversation which prompted this was to simply call attention to the fallacy of the aforementioned statement.  Assuring upper management that their software is safe because of the use of stored procedures is misleading and wrong.  It will lead to directives from on high which demand the continued use of stored procedures, naturally for the purpose of protecting code.  These directives will continue after the developer who made the aforementioned statement has left.  And there remains a likelihood that the code is open to SQL injection, despite assurance from senior leadership that it is not.

So what does prevent the SQL injection?  In the above code, properly escaping the input.  (Though I've seen a lot of production code in a lot of companies where that wasn't the case.)  Ah, so then escaping the input is the magic bullet?  No.  I'm sure there are other examples of nefarious attacks that can get around other magic bullets.  I can't think of one off the top of my head right now, but that doesn't mean it doesn't exist.

Never assume absolute security.  Test it.  All the time.  Consider the notion that the most secure installations (both virtual and physical) in the world are secure not only because they hire experts to set up their security, but also because they hire experts to break their security.  If your system isn't actively fending off attacks, how can you be sure that it's capable of doing so?

Thursday, January 19, 2012

Test Coverage

100% test coverage doesn't mean that every method has a test.

100% test coverage means that every code path has a test.

Helper methods, getters and setters, etc. will be tested by testing the business logic that uses them. The tests express the business logic, not the implementation.

For example, this does not need to be tested:

public int GetFooValue()
{
  return this.fooValue;
}

This, however, does:

public void UpdateSomethingBasedOnFooValue()
{
  if (GetFooValue() > SOME_BUSINESS_CONSTANT)
  {
    SomeExternalSystem.Update(GetFooValue());
  }
}

It's a contrived example which has no actual business meaning, of course. So I should add context...

If the business doesn't know what a FooValue is, if it's an implementation detail that means nothing to the business, then it's not part of the tests.  It's not a requirement that came from the business and isn't translated into a test.  However, the business does care about "updating something base on something else."  That was a requirement, and it means something to the business.  That has tests.

Any time I see implementation details with direct tests (such as pass-through DAL methods with no logic, getters or setters, or just about any private method), I immediately suspect that the tests weren't actually created to validate the business logic and requirements.  But that, instead, they were created after-the-fact, possibly by the same developer who wrote the code.  This dramatically increases the chances that the tests are worthless.

Tuesday, January 17, 2012

The Cost of Quality

There's been a lot of discussion on my employer's Yammer boards lately regarding the value and importance of unit tests.  The discussions were mostly inspired by a recent post by one of our former colleagues, as well as by a response by one of my favorite authors.  Being a consultancy, the topic in general is often discussed on our team.  After all, having a comprehensive suite of passing tests is the way to demonstrate that what we delivered is what we promised.

(On a side note, I found Uncle Bob's response to be a bit too preachy and dogmatic for my tastes.  I'm a huge fan of his work, and I completely agree with what he's saying, so don't get me wrong.  I just found how he said it this time to be a bit too emotionally charged.  Of course, he has no shortage of other material which conveys the point in a more client-friendly manner, and he's entitled to have the occasional rant just like the rest of us.  So while I would argue his point to clients, I just wouldn't use that particular blog post to support my argument.)

Amid the discussions were references made to various studies and papers on the cost of quality in software.  A quick Google search led me to this, which itself references further works, and so on.  This turned out to be fantastic material for making the case for unit tests and good code design when trying to convince non-technical decision makers (managers, et al).

I particularly like the segregation of costs into buckets.  Something like this:


The magnitude of the costs can clearly be seen as increasing from left to right.  Being able to manage software quality with automated tools is very cheap, whereas external failures which drive away customers is very expensive.  Clear and simple.

But there's more.

I'm sure we've all been in this situation.  We've all tried to push for up-front investment in code quality (which is poorly worded, because I still maintain that it takes equal or less effort to initially write good code than bad code, but that's another discussion entirely), or tried to explain to the owner of a legacy codebase that their code is of poor quality and heavy re-factoring is going to be necessary.  And the counter arguments, from a management perspective, are often centered on cost.  I've heard many variations on the same central argument:
"Rather than invest too much in the code, we can just focus more on QA.  We can have junior (read: inexpensive) resources do our testing, developers can test their changes, etc.  Just validate your work and it'll be fine."
So, where does this fall in the buckets?  Clearly the manager is saying that he would prefer to sink his money into Appraisal Costs than Prevention Costs.  So, let's take the case of a legacy codebase that just, quite simply, doesn't allow for any kind of automated testing.  Whether it was written by amateurs who didn't know what they were doing, whether it was actively decided by management that automated testing is not to be considered, or whatever the reason... that's not important.  The net result is the same.  Automated testing can't be done in this case without a major up-front investment.  So the business has decided to prefer Appraisal Costs:


A simple business decision, and the business has every right to make that decision.  So now that the decision has been made, that's the end of it, right?  Management decided to standardize on Appraisal Costs, so that's the standard going forward, right?

Wrong.  See, things change.  This decision would be the end of the discussion if this change to the software was the end of the changes.  Is your business growing or changing?  Is your software growing or changing to accommodate it?  I certainly hope so, because a lack of change is usually a sign that the business is in trouble or not adapting to market forces.

The software is getting more complex.  And that poorly designed code isn't helping.  If you haven't seen this happen, understand that I envy your career.  Because of my past four jobs, three of them have exhibited this behavior in one way or another.  QA was having a harder and harder time keeping up, and the software was only getting worse.  Basically, this was happening:


From the perspective of somebody who cares about costs, that's a frightening trend.  Management has already decided that Prevention Costs are not a consideration.  But now that decision is bleeding into Appraisal Costs.  And we're starting to feel some Internal Failure Costs.  And decisions like "We should educate our users on the known issues" or "We should document the bugs better" don't really solve the problem.  They just add documentation to the problem.  (Consider other problems in life.  I could explain to you at length why your car won't work.  But just putting some gas in it will be more productive in the long run.)

I hate to run around yelling that the sky is falling, but the costs speak for themselves.  If one takes a step back and considers the simplest view of the facts:
  • The business decided to standardize on Appraisal Costs
  • The business has incurred Internal Failure Costs
These two facts together lead me to a single conclusion:
  • The business' decisions don't control its costs
Again, frightening.  Can that box be pushed back to the left?  Sure, but it'll cost you.  (Ok, I kind of intended that pun.  But it's true.)  But how much resistance does that big red strike provide?  How much effort is it going to take to move that box to the left?

I can't answer that question.  So, instead, I propose an alternate approach entirely.  Don't move the box to the left.  Don't fight to stay in Appraisal Costs.  Instead, start focusing on Prevention Costs.  Start... re-factoring.  Don't fight the code you have, replace it with the code you want.

(Yes, managers... replace.  I know you spent money on that code, but that doesn't mean it's worth anything.  That code is increasing your costs.  If you're in a position where you can't replace your legacy code, that means you're not in charge.  The legacy code is in charge.  It's making the decisions for you.  Code should be replaced.  Even good code should be replaced.  With better code.)

To continue the loosely-held 10,000-foot view, consider this:


Yes, the reality of the situation has continued to bleed into Internal Failure Costs.  In the short run, that can happen.  We can try to minimize it, but it can happen.  The thing is... It was going to happen anyway.  We didn't create that problem by taking this route.  In fact, we've lessened it.  The big red strike is continuing its rightward journey.  But that's OK.  We've gone around it entirely.

Does it cost time and money to do this re-factoring?  Of course.  Everything costs time and money.  It's just a question of how you want the graphs to trend.  We've already established that forces beyond the control of management have caused that big red strike to move and grow.  But we can make use of the forces we do control to mitigate the problem.

So keep focusing on those Prevention Costs.  Aim for this:


Great Scott, that big red strike has grown.  It's out of control!  Well, yes.  That's right.  And now, because we've standardized on Prevention Costs, we don't need to control those other forces.

Now what will happen if that big red strike continues to grow?
Costs will decrease.

Now we're no longer fighting external forces.  Where we were previously fighting (that is, spending money) for the sole purpose of maintaining Appraisal Costs, now we're not fighting anything at all.

We are the music makers; We are the dreamers of dreams.

Tuesday, January 10, 2012

Gah, I Missed a Whole Month Again

Well, to be fair, it's been a busy month.  Remember that relocation for a new job many moons ago?  Well, I've finally managed to get my family relocated to join me.  So there's been much moving and much drama.  Not a lot of free time.

Additionally, as a consultant, there are busy periods.  Usually the time spent wrapping up one project and starting another.  This is one of those periods.

Finally, I've taken up an additional writing project above and beyond this blog.  For a while now my Stack Overflow profile has said:
"Career aspirations involve becoming a better developer, a better architect, and maybe even getting published once I find something about which to write."
Well, I have found something about which to write.  It's a little slow going at first, but it's going and that's the important part.  I'm actually quite excited about it.  Whether it eventually becomes a published book is another story entirely, but it's looking good from a very early stages point of view.  (So far I'm mostly reading through related and inspirational books, taking notes, getting my thoughts on paper, etc.  I'm drawing a lot of writing inspiration from Bird by Bird by Anne Lamott and my writing is currently in an early "short assignments" stage, not yet at "shitty first drafts.")

And the beat goes on, da da dum da dum da da...