Teaching C#

Posted by Tom on May 28th, 2010

I’m teaching beginning programming using C# to university business students (CIS) in the upcoming Fall semester.

It’ll be doubly fun, as I’ve never used C# until about a month ago. Sure, I’ve used plenty of other languages, but for some reason, never anything from .NET. (Partly it’s because I’ve used a Mac as my primary machine for nearly six years.) But hey, it’s a great way to follow the advice from Pragmatic Programmer to learn a new language every year. (Next year, I want to pick up Seven Languages in Seven Weeks, and work through that.)

I’ve looked at some of the curriculum previous instructors are using, and while I plan to borrow large chunks of it, there are parts of it that I think emphasize the minuscule details of doing that anyone can pick up instead of the broader theme of how to think like a programmer.

So, for the past couple of months, every time I bump into a programmer I ask, “What’s the most important thing to teach new programmers?” The answers are both varied and consistent. Here’s a partial list of topics I’m considering:

  • Data structures (linked lists, queues, trees (and, in passing, tries), and dictionaries/hashtables)
  • The difference between the stack and the heap (somewhat less important in a garbage-collected environment like .NET, but important to understand, I think)
  • Sorting, especially quicksort, but including bubble sort and a merge-split sort.
  • Big-O (which goes nicely with a discussion on sorting)
  • Some design patterns; at the very least, observer and MVC
  • I’d like to touch on formal grammars, and maybe Regex
  • Resource analysis (memory/disk/processor usage)
  • Some thoughts on user-interface design (e.g., Fitt’s law, using color)

I’d like to emphasize some concepts by showing them in other languages, just to show how the structure remains the same. I hope I can do this without being too confusing. (Of course, what I’d really like to do is cram an entire undergraduate CS degree into a one-semester course, but that isn’t going to happen.)

Please email me or leave suggestions about what I should (or should not) add.

Post Script: While you’re sending me your ideas, I’m open to suggestions on what book I should use. I’ve spent hours already combing through C# books, and while there are some excellent reference books out there, I’ve not been impressed with most of the teaching books. l’m currently leaning toward Head First C# (2nd ed.) because I’m impressed with the Head First series, although I’m just now going through this book in depth.

Images inside a CSS file

Posted by Tom on May 28th, 2010

I was experimenting with my own version of the CSS3 Awesome button, when I noticed one of the commenters share the base64 encoded version of the semi-transparent PNG image they were using as a substitute for a gradient.

I was using a smaller image, and want to run a conversion of my own (it saves an extra HTTP connection, making it easier on both the client’s browser and the server). A quick trip to Google turned up an online conversion tool that worked great.

Wikipedia also provides sample code for doing conversions with PHP: (Please notice there is no error handling!)
<?php
header('Content-type: text/css');
function data_uri($file, $mime) {
$contents = file_get_contents($file);
$base64 = base64_encode($contents);
return ('data:' . $mime . ';base64,' . $base64);
}
?>
body {
background-image:url('<?php echo data_uri('elephant.png', 'image/png'); ?>');
}

Turbo-charging the color picker

Posted by Tom on May 28th, 2010

It’s probably old hat to anyone doing design for a living, but I found a couple of new color tools for OS X that are making my web design work easier.

I use TextMate for coding, and wasn’t thinking about the CSS bundle item that brings up OS X’s default color picker (Command-Shift-C; the TextMate bundle automatically copies in the color using hex notation), I was pleased by a tip from macosxhints.com showing how to write a one-line Applescript app that shows the color picker.

  1. Open “AppleScript Editor.app” (in the Applications folder)
  2. Enter the following:choose color
  3. Save it. Change the file format to “Application” in the save dialog.
  4. I added an icon I grabbed from iconfactory.com. (Download the icon set you want to use. Right-click on the new application, and pick “Get Info”, and drag-and-drop your desired icon over the application’s icon.)

    Even more turbo-charging the Color Picker

    I also found two free plug-ins for the color picker. The first was “Hex Color Picker” from Waffle Software, which outputs the hex version of a color suitable for CSS (although I’m using the RGB values more and more). The second was a plugin called Mondrianum which utilizes Adobe’s Kuler palette service. To top it off, I learned you can create your own palettes in the color picker (it’s the third tab).

    Awesomeness all around.

Easy is easier than hard

Posted by Tom on April 1st, 2010

I’ve been thinking recently about the rule of thumb: “Make desired behavior easier than undesired behavior.” It’s been a running thread that I’ve connected to several unrelated areas over the past month (My PhD work, Boy Scouts, refereeing soccer, software design, and even parenting.) In the broadest sense, this is what society tries to capture with laws—although not always successfully..

In economic terms, when you add friction to a transaction, the transaction becomes less desirable. The illustration by designer Brad Colbow, “Why DRM Doesn’t Work (or how to download an audio book from the Cleveland Public Library” is a great example, as is a similar graphic from geekologie.com. (It’s also a great explanation of why I dislike animations that can’t be clicked past at the start of so many video games.)

Enabling good behavior (and discouraging undesired behavior) is an undercurrent in the change management literature as well as in the policy compliance literature I’m reading. It explains why lecturing is often the most ineffective method of teaching, because it requires attentive behavior in the listener, rather than enabling it.

It’s a concept I will certainly need to keep in mind as I prepare to teach next semester.

Data visualization and unemployment

Posted by Tom on November 22nd, 2009

I’m fascinated by data visualization. Expressing complex ideas in a simple way is immensely powerful. In my post yesterday, I linked to a
county-by-county time lapse of unemployment rates. I’ve found some interesting images (complete with a thorough explanation) examining the U.S. economy. The article is interesting, but the images, if you’ll pardon the cliché, really are worth a thousand words. A sample of images is included below–visit the full article for more.

Mass-layoff events for 2008-2009:

Percentage of workforce employed in manufacturing (2006):

Unemployment (2008):

A while ago, I asked how government would change if budgets were presented visually. In a similar vein, how would education change if achievement data were also presented visually? Would our decisions change? Why?

All images the article by George Maasry, “US Unemployment in 2009—More Job Losses in Production”, UUorld.com, 2009-03-09.

Unemployment map

Posted by Tom on November 21st, 2009

Daring Fireball pointed to this county-by-county time lapse of unemployment rates. Fascinating. It explains some of the differences I’ve observed in the move from Utah to Georgia.

A few things to notice:

  • Because each frame is a 12-month running average, the map doesn’t show whether some counties have started to pull out of high unemployment.
  • Michigan and Oregon were hurting before the bust really got started.
  • What makes the Rocky Mountain states (the swath starting at Montana and the Dakotas and moving South) have lower unemployment from start to finish?

Why change efforts are difficult

Posted by Tom on October 15th, 2009

I came across a great explanation of what I believe are the primary reasons most organizational change efforts are exceedingly more difficult than leaders initially expect:

[Because] change in organizations typically involves shifts in the way people work, these may introduce feelings of inadequacy and dislocation that potentially challenge people’s identities as competent workers (Ezzamel, Willmott & Frank, 2001; Kondo, 1990). Organizational changes may also reduce or replace meanings and practices that are central to people’s positive view of themselves, such as when they are no longer allowed to engage in activities or use artifacts that had signaled their prestige or prowess to others (Pettigrew, 1985). Furthermore, employees may consider new tasks and new approaches as affording them with less autonomy, responsibility, or standing in the organization than their previous ways of working (Cox, 1997), and they may interpret this as an overall loss of status and thus as a threat to their professional identify. da Cunha, J. V., & Orlikowski, W. J. (2008). Performing catharsis: The use of online discussion forums in organizational change. Information and Organization, 18(2), 132-156. Page 133.

An economist on education

Posted by Tom on October 14th, 2009

I caught on TV tonight an education policy presentation by Julian Betts, Chair of the Department of Economics. Originally presented in April of this year, Dr. Betts discusses peer-reviewed research on testing, accountability systems, charter schools, vouchers, and merit pay systems.

No matter where you fall on these issues, I think it’s worth watching.

Big numbers and visualization

Posted by Tom on September 30th, 2009

Go here first. Then come back. I’ll wait.

The trouble with talking about government budgets, even ones as small as a city or local school district, is that big numbers rapidly lose meaning to people. It’s more visceral to talk about a dozen people (or dollars or “things”) than to discuss a million of then. Big numbers are hard to visualize.

Take dictionaries for example. Without peeking, is 10,000 words a good dictionary? What about 20,000? How many words are there in a typical collegiate dictionary? Take a guess before looking at the answer.

You’ve heard the politicians say it (and it’s true): “A million here, a million there and pretty soon we’re talking real money.” One of the ways I try to make the number a bit more “real” is to estimate how many people could be employed at a particular job for that amount. Try it. How many professional workers (between $50,000–60,000 annual salary) can be employed in government jobs for $1M? (My answer.)

John Gruber linked to a blog called Information is Beautiful, highlighting an impressive infographic comparing budget numbers in the billions. (The same link that starts this post. Once there, click the graphic to see how the data was sourced, along with viewer comments.) Go see it!

How would government change if budget committees published these numbers visually instead of numerically?

1. Dictionaries

Chances are, if you guessed how many words are in a dictionary, you anchored around the numbers I listed above (e.g., 20,000). The number is way too low! At less than two inches thick, the Merriam-Webster Collegiate Dictionary (11th) boasts 10,000 new words in the most recent edition, bringing its total to more than 225,000 definitions. Even the tiny Merriam-Webster’s Pocket Dictionary, a 7 x 4.2 x 1.6 inch paperback, has more than 40,000 words. (^ top)

2. One million dollars

These are rough back-of-the-napkin numbers. YMMV. At $50K salary/year, a company is responsible for an additional $4K in FICA and other taxes. The large non-salary chunk is benefits, which for many government positions the employer pays the lion’s share. If we low-ball the number at $1K/month for a family plan, that’s an additional $12K/year (running total=$66K/year). Throw in a computer workstation (replaced every three years; less often in gov’t), software, tech support, utilities, renting the office space, custodial, parking, worker’s compensation, and who knows what else, and a very low cost estimate (read: wild guess) might be another $5K/year. (running total = $71K/year) And I’m not factoring in 401-K contributions or pension liability, which will probably add another 10% to our figure. (Less for defined contribution plans.) Tack on another 5% to build in a margin of error (total = $75K/year), and one million dollars employs just over 13 people. A baker’s dozen.

Thirteen is not very many—not even enough to add just one employee to every elementary school in Provo, Utah. That figure drops to 10 people if we create higher paying jobs and offer a $60K/year salary. (^ top)

Federal judge ignores rights of individual

Posted by Tom on September 25th, 2009

Via Gruber, who posts following a TechDirt article.

A federal judge denies an individual of property (contents of an email account) without notification, with no opportunity for appeal (the person is not a party to the matter), and with no cause to suspect wrongdoing.

Saith Gruber, who dubs U.S. District Court Judge James Ware “Jackass of the Week”:

This is absurd:

  1. Rocky Mountain Bank emailed confidential financial information to the wrong Gmail address./li>
  2. The bank attempts to force Google to release the name of the owner of the email address. Google refuses without court order.
  3. Federal judge James Ware orders Google to disable the email account — which belongs to someone who did nothing wrong and was sent the email message by mistake.

John Gruber, “Jackass of the Week: U.S. District Court Judge James Ware”, Daring Fireball. Accessed 2009-09-25

I think the post from Technologizer stabs at the root issue, though:

The temptation to heap scorn upon District Court Judge James Ware is obvious, but I’m most appalled by the reported initial actions of Rocky Mountain Bank. Why was anyone there e-mailing Social Security numbers to anyone?“Rocky Mountain Bank: Rocky, Rocky Security!” by Harry McCracken. Accessed 2009-09-25, emphasis added

It’s a good question. Why would any company ever allow sensitive information be sent through an unencrypted medium? Back up a step, though: Under any sane security policy, how could an individual even acquire a list of social security numbers on their desktop in the first place?

UPDATE (2009-09-28): Techdirt reports that Google and the bank have both requested the judge reinstate the account.