What’s in a [Route] Name?

In ASP.NET MVC-land, there’s no such thing as a location that you or I think of. It’s all controllers, actions, and route values.

Someone forgot to tell relative URLs that.

If you’re using a relative URL in ASP.NET MVC, sooner or later you’ll bump up into the same problem I did.

You have a route, it looks like this:

         routes.MapRoute("Edit",
                "{controller}/{action}/{id}/{*pagename}",
                new { controller = "Page", action = "Edit", id = "", pagename="" }
                );

 

You would expect that anything pointing to:

http://localhost:3919/Page/Edit/11?pagename=news

and:

http://localhost:3919/Page/Edit/11/news

would match, right?

They do. Except when you want to include a physical resource. You know, like a script.

Your script folder is a physical location, these routes are not. But the script doesn’t know that.

If you were to drag the script from the Visual Studio IDE to the editor window, you’d get something like the following:

<script src="../../Scripts/tinyMCE/tiny_mce.js" type="text/javascript"></script>

Guess what? That matches the first route, but not the second. Ooops.

If you’re going to use a static resource in ASP.NET MVC, be aware of two things:

1. controllers and route values aren’t tied to any particular paths.

2. Static resources care about paths.

I blame part of this on Visual Studio. ASP.NET MVC shouldn’t let you shoot yourself in the foot so easily. It knows you’re dealing with MVC, it should give you absolute paths when you drag and drop items.

Who has two thumbs and feels embarassed that he spent an hour debugging this issue, down to a line-by-line compare of the differing files? This guy.

It’s up to Us

We complain about companies. We complain about our working environment, or how we don’t have automated builds, or how we just can’t seem to get managers to realize we need large monitors and little interruptions.

The companies aren’t the problem. We are.

The last time you talked to a recruiter (headhunter or otherwise), what questions did you ask him? If you’re like me, you asked about the job, the company, the pay, the benefits, and whether it’s a contract or permanent position.  And just like me, you became the problem.

The reason why companies don’t improve our work environments is because we don’t hold their feet to the fire. We don’t ask the questions that need to be asked.

It’s up to us to ask the right questions.

The Joel Test is a good place to start. It’s written by someone who is respected both by businesses and by the software community.  Better than all that is the fact that his name wasn’t something like “Vladlimir”. That doesn’t sound good at all. “The Vladlimir Test” (bonus points if you say it with a faux russian accent).

  1. Do you use source control?
  2. Can you make a build in one step?
  3. Do you make daily builds?
  4. Do you have a bug database?
  5. Do you fix bugs before writing new code?
  6. Do you have an up-to-date schedule?
  7. Do you have a spec?
  8. Do programmers have quiet working conditions?
  9. Do you use the best tools money can buy?
  10. Do you have testers?
  11. Do new candidates write code during their interview?
  12. Do you do hallway usability testing?

The Joel test should be the first thing you send to a recruiter. Don’t continue the conversation until you have an answer to your questions.

 

Repetition, Repetition, Repetition.

It sounds obstructionist, I know. But unless you’re living under a bridge (how’s the wifi access?), you’re hurting yourself by not doing this. When you send this to every recruiter you come in contact with, and your friends do the same, they start to become immersed in our culture. They see it repeatedly, and it becomes a part of their contact with their client.  Their clients then realize that we mean business, and they’ll start to institute change.  It won’t happen overnight, but it will happen.

Expand. Once you get employed, bring it up to your manager. Be that instrument for change. Institute those items that your team is missing on this list. When you leave your company, point out specific reasons why you left — be sure to include some bullet points from above.

Why the Joel Test?

Well, the “George Test” isn’t written yet. But I do have some questions that I pose. I don’t just pose these questions for their direct answers, but because of what those answers tell me about the company.

1. How’s the Internet Access?

Companies that blocking software rank low on my list of companies to call “Home”. I surf the internet looking for answers, and when a programming site gets blocked, I have to spend time to find a way around that. That’s time I’m not being productive.

2. How much overtime do you expect?

Deathmarches suck. I left a company because of a continual death march.  It wasn’t one or two, it was endemic in the company — and it came from the top down. The company was ‘sales driven’ and that included selling items that weren’t actually in the product yet. Since we were ‘contractually obligated’ to provide those features, the deathmarches were to implement those features before the client walked. If they waffle when they answer that question, beware. There are studies that prove that working more than 40 hours a week is harmful. Any software team that doesn’t know that isn’t worth working for.

3. What’s the dress code?

This gives me an idea of what type of company it is. If it’s a software company, generally it should be quite relaxed (Dress pants and a button down together are a stretch). There’s no need for it not to be. The more time developers have to spend on dry-cleaning, the more work turns into a chore.

4. Do you conduct Code Reviews? Brown Bag Lunches?

5. How many meetings do you have?

When programmers are in meetings, they aren’t productive. Normally, they’re bored and wondering why they’re in the meeting in the first place. Meetings should be kept to a minimum. As in a number less than 2 per week. 0 is good. I like 0.

6. Do you pay for me to attend professional conferences?

If you want the best, you’d better pay for the best. If you want to be cheaper and pay for the good or mediocore, you better be willing to pay to make them better. If you want a warm body, talk to someone else. I spend my free time coding, talking to others about code, or reading about code. Conferences are the ‘next level’. They are the thing that re-energizes the masses (In fact, every Microsoft Conference invariably reinvigerates the masses for about 6 months until everyone realizes it’s bullshit. See: “Cloud” computing).

7. Why should I work for you?

This is a way to see what businesses are passionate about what they do. The ones that aren’t don’t need your dedication and time.

 

Practical Uses For Fizzbuzz – Part 2

Wasn’t it your own Hartley who said, nothing reveals humanity so well as the games it plays? Almost right. Actually, you reveal yourselves best in how you play.
– Q to Riker, “Hide and Q”
Star Trek: The Next Generation

How someone writes code can tell you a lot about them.

Fizzbuzz, although simple, provides plenty of fodder for discussion, and in that discussion can show you whether or not a programmer has the chops to produce quality code.

Fizzbuzz can be used to validate resume buzzwords.  If someone declares themself as an ‘Expert’ in C#, it’s really easy to see if they really are. I mean, an Expert should know the modulus operator, right?

Take this example:

 

for (i = 1, i <= 100, i++) 
{      
    if (i mod 5 == 0 && i mod 3 == 0) 
        print “fizzBuzz”;     
    else if (i mod 5 == 0)
        print “buzz”;
    else if (i mod 3 == 0)
        print “fizz”; }
}

There are a few good starting points to be made from this piece of code: 1. What is the modulus operator in your favorite languge? 2. Where’s the bug? 3. How can we improve this code to reduce duplication?

If the candiate believes that the modulus operator for their favorite language is mod, and they aren’t in Visual Basic, then the interview should be terminated. There’s no sense in going past that point.

While there isn’t a bug in this code per se, it could use some refactoring; the logic is left wanting, to put it simply. The order of operations is opposite of what you’d expect.  3 comes before 5, and in any loop 3 will always come before 5. This isn’t a bug, but it is a logical error, and fixing logical errors are central to debugging harder problems.  If your maintanence programmer has to figure out why you did something counter intuitively, it heightens the chance that he’s going to make a mistake.

Finally, the code can be improved substantially by using a string variable and appending each part to it.  If a candidate has gotten past the first gate and into the second, this question will help shape your mind on what sort of programmer they are.

Example ‘fixed’ code:

for (int i = 1; i <= 100; i++)
{
    string output = String.Empty;
    if (i % 3 == 0)
        output += “fizz”;
    if (i % 5 == 0)
        output += “buzz”;
    if (output == String.Empty)
        output = i.ToString();
    Console.WriteLine(output);
}

It doesn’t have to be a complex code sample to be of use in an interview, but it does have to be done on the spot. Using a code sample is the only way to really see what sort of code the programmer turns out.

Don’t neglect this tool when interviewing programmers, or your bottom line will regret it.

Design for ColorBlindness

But all the colors mix together – to grey. – Dave Matthews Band “Grey Street”

I wrote about my colorblindness yesterday.

It was hard to write that sentence, and even harder to write that post yesterday. I used the word ‘disability’ in my post yesterday.  I didn’t put that word in there, my fiancee did. That’s how hard it is for me to write about it. 

It shouldn’t be, but it is. 

There’s embarassment, sure. Even more is that when you’re blind, people get why that’s an issue. There are best-practices out the wazoo. But when you’re colorblind, the level of caring about your web experience ranks somewhere between apathy and ignorance.

But it is a disability. It is not as severe as blindness or deafness, to be sure. But unlike blindness, it has no representation in the minds of website designers. It’s a non-issue.

At one time we had to worry about colors. Remember these?

Web Safe Color Palette. Notice how the greens and reds are separated

We’ve come a long way in the battle for web design. We’ve even come to the point where we can laugh at our former works of art. At one time, there was a notion of web-safe colors. As soon as technology allowed, we tore down that wall and kept its ruins as mementos of a barbaric time. We congratulated ourselves and heralded a new age, instituting best practices for accessibilty and starting an entire cult based around fixing web accessibilty. We thought we won, but we didn’t.

Date Usability, Don’t Just Flirt With Her

 Accessibility is usability’s sister. The one you have to impress to score a date with Usability. The annoying one that you’d rather tune out completely, but can’t. we missed this in our celebration.

Examples of our failure are everywhere, even from Google:

So which graph is green, smart guy?

The annoying sister butts in again. Were it not for the numbers, there’d be no way for me to tell which one is which.  Even with the numbers, I still have to do mental gymnastics, the very kind usability experts rail against.

Stack Overflow recently started including vote totals; If you click on a vote it tells you how many were upvotes and how many were downvotes.  The original implementation (left) was fine. No need to change it. But the website creator decided to change it to a green color to indicate ‘good’ and a red color to indicate ‘bad’:

This seems easy to figure out.It all looks green to me.

So, which one’s better?  I see color, but they both look an annoying shade of red, one darker than the other.  It would have been better never to institute the ‘fix’ at all.  The newest iteration shows a + and a – next to the votes — which is also helpful, but it doesn’t take away from the pain the second image induces when I look at it.

Let me say that again:

Trying to distinguish red from green is painful.

Design for Colorblindness

You may wonder why you even need to design for colorblindness.

If you’re a web-based business, 1 in 12 of your customers are colorblind.

 

Here’s how to cater to the colorblind demographic:

1. Keep conflicting colors apart. Red and Green shouldn’t be in the same zipcode. We can see them fine when they’re apart, but when they’re together, we get headaches.

2. Study up on Colorblindness. See what it’s like to be colorblind.

3. Don’t use colors as the only distinguishing information; and obey rule #1.

4. If you must use colors (like on a graph) then make sure to use Colorblind safe colors.

 

Bottom line: paying lip-service to accessibility means paying lip-service to your customers.

 

 

The Web hates colorblind people

If You're Red Green ColorBlind, you can't see that this is supposed to be the number '74'.

I’m Red-Green Colorblind, and it embarrasses me.

I didn’t realize I was red-green colorblind until I enlisted in the Army.  During my trip to MEPS, I took a red-green colorblind test for my Military Occupational Specialty (A fancy phrase for ‘Job’) 13F (Another fancy code that means ‘Forward Observer’).

I failed the test. 

I’m not sure how I was still placed in that job, because by all rights someone should have stopped the placement — but who am I to argue? I enjoyed the hell out of my time in the Army and am really glad someone screwed up their job that day. 

That was the day I woke up; the day I found out I’d been missing something all those years.  I was 17.

I’m 27 now. Being fully aware of my disability I have to ask my fiancee if what I’m wearing ‘works’. She spends extra time ribbing me for this. I think she’s getting paid to do it. She mutters something about kindergarteners knowing their colors. I wonder why I fell in love with a teacher.

Being red-green colorblind means that I can’t tell red and green apart when they’re together. 

There's Red in there, I hope.

Christmas is a nightmare for me.

There are different levels to color-blindness, I happen to fall in the deuteranopic category.  That means that dark green looks black to me, and red and greens resemble each other when they’re close together.  I can tell a shade difference at times, but it’s only for specific shades. 

It’s embarrassing because whenever I think of my colorblindness,  I think of how we’re an unrepresented minority, almost forgotten in the web-design landscape. You often hear Web designers talk about accessibility for blind people, but how often do you hear them talk about accessible websites for colorblind individuals?

Where you see a cascade of colors, I see grey. 

Where you see joy and festivities around the holidays, I dread parties because I might comment on someone’s red dress and then find out it is green. 

Where you look at clever color schemes and see that the voting mechanism is seperated by more than one dimension, I’m constantly reminded of what I cannot see. 

Is it the end of the world?  No.  Does it royally suck?  Yeah. 

Tell someone in a wheelchair that they can’t have access to the building simply because it’s old and doesn’t have a ramp.  See how far that gets you.  We cater to all other disabilities, but if you’re colorblind, you get nothing.

If you’re a web developer, design for colorblindness.You wouldn’t antagonize any other disability, so antagonize us?

Spend time in our shoes: see what it’s like to be colorblind on the internet.

 

Nesting Tags inside an Anchor Tag in ASP.NET MVC

I’ve been working on an ASP.NET MVC project and needed to nest an <h2> element inside of an anchor tag because of a CSS-only menu I am using.

<a href="http://somethinghere.com/page/1"><h2>Link Text</h2></a>

If you use the traditional ActionLink method in ASP.NET MVC, you can’t do that. At least, I haven’t found a way how.

I did find a work-around, courtesy of Stack Overflow:

<a href="<%= Url.Action("show", "page", new { id = Parentpage.Id }) %>"><h2><%= Parentpage.PageName %></h2></a>

It’s a hack, but it produces the correct output.

Practical uses for FizzBuzz Part 1

In the Army, there were generally questions about soldiering that personnel looking for promotion would be asked. They would spend a day going before a promotion board in their crisp uniform and be asked questions about being a soldier.  Questions like: What are the different MOPP Levels? What is the process for clearing a weapon jam in an M16?  What is the effective range of a M16? What is “Danger close” for an MLRS? 

In case you were wondering, “Danger Close” for an MLRS is a whopping 1km x 1km.

Sadly, software development doesn’t let me ask such cool questions. I have to stick with things like “What is inheritance and what is composition, and when would I use either?”

However, much like the questions the Army promotion boards ask, these questions we ask developers are just as useless.  A great soldier may not know the effective range of an M16, but he can hit what he can see — and that’s even better.

A software developer may not know the word ‘composition’, but they recognize bad design when they see it; and they recognize good design when they see it.

This makes a change of tactics necessary, as it were.

Don’t ask questions about Object Oriented design — have the candidate design something for you.  Don’t ask questions about code — have the developer write code for you.

 

The easiest way to do the first is to use something like Monopoly to conduct the interview. To do the second? Something like Fizzbuzz would do just as well.

 

The great thing about Fizzbuzz (even though it’s shockingly simple) is that it can serve to show a few things:

1. Does the candidate know the language? (If someone is using ‘Mod’ in C#, that’s a good sign they don’t really work in that language much (which is doubly disconcerting if the word ‘Expert’ is next to ‘C#’ on their resume)

2. How do they structure their code? Do they go for the elegant solution? The Simple solution?

3. It provides a basis for refactoring. This shows you if they can think about the potential problems in their code.

 

    for (int i = 1; i <= 100; i++)
{
string result = String.Empty;
if (i % 3 == 0)
result += "fizz";
if (i % 5 == 0)
result += "buzz";
if (result == String.Empty)
result = i.ToString();
Console.WriteLine(result);
}

In our next wonderful adventure, I’ll go into how to use a simple programming exercise to determine a candidate’s ability.

How I became a programmer

You know those kids who learn to program in assembly at age 12?

I wasn’t one of those.

I grew up around PCs, I was even the first kid on my block with a Local Area Network, but I didn’t program for a long time. I didn’t even know it was possible.  My journalist father was on the cusp of the Computer User revolution; but he didn’t know enough to know how computers were programmed.

Ergo, he didn’t tell me.

In 1993, my school’s computer lab received 386 and 486 PCs. I found the BASIC interpreter and did stupid things like:

10 PRINT "HI THERE"
20 GOTO 10

I was sure I could do more with it; but didn’t have the vision to know what the ‘more’ part was. It was a novelty, but not a terribly interesting one without context.  Later on that year I opened up the GORILLA.BAS file; but I just didn’t have the vision to play around with it. The game worked the way I wanted it to; why muck with it?

Gorilla.Bas - An oldie and a goodie

 

Then I was introduced to the TI-93+; a programmable calculator with its own assembly language. Cool, now this has potential, I thought. I had no idea what to do with it; but I at least knew it was there.

I gamed through High school; but never took Mathmatics past Algebra III — I had a high school teacher who was more interested in her Yearbook duties than she was in teaching math.  That was a bummer because up until that point, I thought I was pretty good at math.

I attempted to get into a public university for Computer Science, but was told quite pointedly that I didn’t have the math pre-requisites to do so. I ended up winning a four year full Leadership scholarship for a local Catholic college — and they had Computer Information Systems. Huzzah.

I took Java the first semester along with Introduction to Computer Architecture and Systems; but again the vision thing blocked my path. The Architeture class took me through the physical bit flipping and memory address allocation and whatnot that happens at the very core of the microprocessor, but the Java course was so far removed from that that it didn’t make sense to me how they connected. I needed to go lower level. So I took C++. At the time the public view of Java centered around rotating cubes, and while I dig rotating cubes, I didn’t see how a rotating cube mapped to a memory address instruction.

While taking C++, I had a healthy dose of Data Structures and Algorithms and Database Design. Now this had potential. Finally, something that made sense. The courses were a lot of fun, and although I momentarily bombed on Pointers, I figured those out and was well on my way to doing fun things… Except for the fact that these classes were for the lowest common denominator, in a school that was defined as a Liberal Arts school.

Once again: bummer.

To pass the time, and because someone told me that it was the basis for all web development at that time, I learned Perl (this was right around the time PHP 4 was released, back when it was called Personal Home Page (yikes!)). and proceeded to use it for every day scripting.

Junior year I rounded out the rest of the undergrad CS curriculum (save the senior project courses that closely mirror what software developers actually do on a day-to-day basis), and started drawing up ideas for websites. My first idea was a website that users could log on to to rate and share their experiences at private retailers, a la Kudzu.com (which came 2 years later). I never got very far because I was called up, but I always wonder what would have happened if I had launched that site.

Right as I began my senior year, the government decided that it needed me to fulfill my reserve obligation. My Army National Guard Unit was called up and off I went to Iraq.

After I got back from Iraq, I wrote VBA code in for the Army unit I was assigned to. They used an Access Database to track everything that happened in their unit. My job was to make it generate pretty reports and create whizbang features that allowed them to track the disposition of members of the unit daily, and then generate pretty reports for multiple government agencies.  Before I got there, it took an entire day and coordinating with 5 people to do. After I finished, it took 10 minutes and no coordination.

Not bad, huh?

After that ended, and three years after I was called up, I took off the uniform for the last time and went to finish college.  My senior year consisted of a senior project that required us to pick from a stack of problems and fix one of them.  Typically, the local non-profits would ask the College’s CIS chair if he could spare a few students to write a program for them; we were those few students.

I led a group to design, implement, and deploy a Winforms based client-tracking system for a local non-profit charity. The code wasn’t tiered very well, it had an ugly 1-form-tabbed interface, and it crashed a lot. But it worked. This was my second real taste of success.

Due to domestic constraints at the time, I lived in an area that had very little programming prospects for me; and ended up taking a job as a Perl Web Application Developer about 60 miles away.  The work wasn’t much fun, but that was because I was the lone contractor on that particular project.  Thinking that this was how programming was, I opted to leave the job when the contract was up and go into Systems Administration.

How different these two worlds are!  As a programmer I rarely spoke with others, but as a System Administrator, I was in a new environment almost daily, doing something new and different. The job was as varied as the day is long; and there were always improvements to be made.  I promptly used Perl to automate system administration tasks (like waking up the PCs for disk defrags, keeping an active display of which computers were up, etc). Once I finished there, I used C# and the SendKeys API to automate the startup of the Point of Sale computers.

I was good at System administration, but I was in a place where there wasn’t much of a future.  How many SysAdmins do you know that start their own company?

So I went back to programming, and have been for the past few years.

Did I mention that I love every minute of it?

The 5 types of Programmer companies

I recently had a chat with a recruiter about why I wasn’t interested in a prospect. This is the answer I gave him:

In answering your question, it’s necessary to list the categories we (Software developers) put companies into.  Depending on where a developer is at in his career, different types of companies may occupy a different order.  The ordering of the list changes depending on the developer. This is by no means canonical.

Software development jobs generally fall into one of a few categories:

1. Startup – ‘Fun’ atmosphere, chaotic, making new things, generally at the cutting edge; fails easily, pay isn’t as good, but the other benefits (working from home, relaxed dress code, casual work atmosphere) make up for it. Long hours at times. Developers care about the company and their work. Selling environment may dictate ‘ship now, fix later’ mentality (that normally leads to project failure down the road)

2. Private Company that sells software as its primary business function – Developers treated well, first class citizens; pay is very competitive and benefits are outstanding. Normally right around 40 hour work weeks (there’ve been numerous studies that show as knowledge workers work longer hours, they perform more poorly mentally); dress code varies, but normally Jeans and button down or something along those lines. Well defined process; Developers care about product and company, vested interest to see it do well.

3. Private firm that sells something else and makes software as a ‘supporting’ function – Developers more often than not are second class citizens; restrictions on what developers can do; working with new technology or making changes ‘for the better’ is hard. Pay is great, but it’s a mixed bag as to whether the other developers really care or if they’re just collecting a paycheck. Dress code is conservative.

4. Private Firm support government entity – Somewhere between 2 and 3, depending on the company.

5. Public (government) entity – Not cutting edge at all (in most cases); heavy restrictions on what a developer can do; watched like a hawk; change is unheard of.