Monthly Archives: May 2010

Teaching C# #

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 #

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 #

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.

Hire Tom! Hire Tom!