Scott Hanselman

Programmers, keep your wits about you and Code Mindfully

April 3, '07 Comments [19] Posted in Programming
Sponsored By

I was talking with Patrick Cauldwell the other day about what makes a "Good Developer." We talked about a number of different characteristics.

My intent was to write up a list of good personality characteristics that describe effective programmers, but Patrick said, "The real problem with most developers is that they don't keep their wits about themselves."

This was like a slap in the face to me. I realized when I was going through the Programmer Phases of Grief that I hadn't kept my wits about me.

You ever have the very frightening experience when you're driving along, perhaps lost in thought, and next thing you know, you've driven two miles and you don't remember the driving process that got you there?

Many of us who've been programming for a long time, or folks who are very gifted and take get from A to C while skipping B, can have these fugue states while programming. I don't literally mean that one blacks out while coding, but rather one goes "running down a one-way dead-end street." A lot of time is wasted before we realize that some original assumption was wrong.

I think one can be a more effective programmer if they can avoid not-thinking. Call it Mindful Coding if you will. The act of actually thinking while writing code is challenging, especially when your mind is jumping to the next idea or if you're writing code you've written a dozen times before.

Sometimes I'll catch myself asking a question of someone around here, and halfway though the question I'll realize that I haven't really THOUGHT about the problem space. For me, and my learning style, this might involve explaining it to someone (often my wife, who nods in all the right places, but cares not about such things) or drawing a picture.

For many, analytical thinking isn't a passive thing. Often just making the decision to "sleep on it" can be all that's needed to break through a hard problem.

"If you can keep your wits about you while all others are losing theirs, and blaming you. . . . The world will be yours and everything in it, what's more, you'll be a man, my son." - Rudyard Kipling

So, I say, programmers, keep your wits about you. Code Mindfully. I vow to try harder.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Hanselminutes on Channel 9 - Video #2

April 3, '07 Comments [0] Posted in Musings | Podcast | TechEd
Sponsored By

It's Video #2 in the Hanselminutes on 9 series.

Rory and I did a few videos together a while back to promote TechEd 2005. (Baby Carrots, Designing Software) They kind of worked, but were perhaps a bit forced. We thought they'd be cool at the time because when Rory and I hang out and just riff, we're a hoot. A hoot and a half, even. So, the Rawdawg got the idea for he and I to wander around Microsoft's Building 42 (Developer Division or "DevDiv") and simply pop in to folks offices and ask them "What are you working on?"

For me, I wanted to get back into the "Roots of Channel 9" - raw discussions, preferably with folks who know what they are talking about.

Here's video #2 in our travels through Building 42 on the Microsoft Campus. We didn't plan anything, nor did we warn folks we were coming.

In this short video, we interviewed Vance Morrison, an Architect on the .NET Runtime Team, specializing in performance issues with the runtime or managed code in general.

We actually stopped and bothered Vance because he had a trebuchet on his desk that we saw through the window. We had to stop.

Vance does some pretty amazing stuff around Managed Code Optimization. Take a look at the micro-optimizations around typeof() calls over at his blog. Vance is a busy guy so this video is only six minutes long. 

The first video in this series is still over here: Hanselminutes on 9 - #1.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Gamma Correction and Color Correction - PNG is still too hard

April 3, '07 Comments [27] Posted in ASP.NET | Musings
Sponsored By

If you're not reading this post in a feed aggregator you can tell that Alexander and I collaborated on a new design over the weekend. (Yes, he was paid.)

By "collaborated" I mean that Alexander is awesome and I learned a bunch of obscure browser-specific nonsense that I didn't know before. I thought that at least some of these problems were fixed by 2007. Oy, what a mess.

I was looking forward to using PNG on this site, and it's the One True Format, right? You'd thing it'd be a no-brainer.

We put that brown background in the header in a div, as a background-image.

<style type="text/css">
#header1 {
height: 79px;
background: url(header-background2-gamma.png) scroll no-repeat;
background-color: #5C4837;
background-position: right 50%;
}
</style>

The original design was fixed in width, so we made it fluid and stretchy. Because the header is a fixed weight, I wanted it to be right-aligned. It's aligned via background-position to the right.

In order to make it stretchy, I made the background color match the left edge of the graphic. This technique worked great in FireFox, but looked lousy in IE6 or IE7. You can see a rendition below or visit a sample page. If you're running IE, you'll see a graphic like the one seen below. If you're running Firefox, you'll see two identical bands.

Nutshell - PNGs look darker on IE than anywhere else. Even IE7 Release!

What different is that, as you probably know, IE doesn't seem support the Gamma Correction data that is added by most PNG-producing applications. Or, it supports it too well! :)

Not only is there crappy PNG support out there, as most don't completely implement other very interesting parts of the spec, like Color Correction, but the spec itself was apparently ambiguous for a number of years.

I went around and collected this bunch of links...

The real frustration for me here, is why should I still care about this stuff? It should be WAY easier...I wonder when the larger problem of color on the web will be solved. I'm really frustrated and a little shocked that I'm still having to sweat this kind of detail these days.

Big thanks to Jon Galloway for helping me figure this out and remove the Gamma Correction from my PNG.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Rescuing the Tiny OS in C#

April 2, '07 Comments [15] Posted in Learning .NET | Programming
Sponsored By

About four years ago (in the middle of the last fifteen years of writing software for money) I graduated from college. I took a round-about way through school at OIT - my four-year degree took eleven years (I actually had to make deals with four different deans to allow me to keep my credits from expiring) but it turned out OK.

Some where in the middle of going to school at night we were asked in an Operating Systems class to write a "Virtual CPU and OS." More of an interpreter, we were given a description of the OS, some op-codes and an ASM-like machine language. We were to write the OS, and feed test programs into the system. It was a fun exercise and a good way to teach folks how virtual memory and memory mapping works, threads vs. processes, etc. I was the only student who chose to write it in managed code. Quite the coup for 2002.

I turned in the project and threw it up on GotDotNet (this link will be dead in July of 2007), but of course, GDN will be gone soon. Just so it wouldn't be lost, it's now available here in C#. It's actually kind of fun, I think, as I put in some "jokes" - funny to me at least. For example, the OS pages it's virtual memory to XML files when it runs out of "physical" memory. It behaves like a real little OS. It'll thrash with low memory, and get fragmented if a lot is going on.

A tiny virtual CPU and OS written entirely in C#. The TinyOS simulates the scheduling, memory management (including paging and virtual memory) and other operations of theoretical Operating System. You’ll see many Framework classes and techniques in use including Regular Expressions, XML Serialization, generated Strongly Typed Collections, XML Comments and a generated Help file. You won’t get much useful work out of the TinyOS itself, but the techniques you’ll learn can be applied to real life.

Since this little ditty, others who really know what they are doing have written more serious OS's in C# that are worth looking at.

I presented on my little CPU/OS at TechEd Malaysia 2002, and the PPT slides are available as well. I also did it again in VB.NET if you like with a little trouble.

I looked at this code in 2005 and was shocked and offended with myself - well, not really, but it was enlightening to say the least. 

Go find some code that you wrote at LEAST FIVE years ago and tell me how it looks today...

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Hanselminutes Podcast 57 - Polita Paulus and The Minutes on Nine #1

April 1, '07 Comments [1] Posted in ASP.NET | Podcast
Sponsored By

My fifty-seventh podcast is up. This episode is the audio portion of the Channel 9 cooperative cross-over video with Rory.

(Disclaimer: To be clear, no one at C9 is paying anyone anything. There's no money involved, but Microsoft DOES have free Diet Coke, and I did take some home with me.)

This podcast is, ahem, audibly-improved (Carl's audio team did the magic) and is the interview we had with actual-ASP.NET developer Polita Paulus from Building 42, along with her boss Matt Gibbs. We literally wandered into their office unplanned and unscripted and had a fine chat. They were both very good sports considering that we pounced on them.

ACTION: Please vote for us on Podcast Alley! Digg us at Digg Podcasts!

Subscribe: Feed-icon-16x16 Subscribe to my Podcast in iTunes

Do also remember the archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.

Our sponsors are Telerik and /n software.

Telerik is a new sponsor. Check out their UI Suite of controls for ASP.NET. It's very hardcore stuff. One of the things I appreciate about Telerik is their commitment to completeness. For example, they have a page about their Right-to-Left support while some vendors have zero support, or don't bother testing. They also are committed to XHTML compliance and publish their roadmap. It's nice when your controls vendor is very transparent.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

  • The basic MP3 feed is here, and the iPod friendly one is here. There's a number of other ways you can get it (streaming, straight download, etc) that are all up on the site just below the fold. I use iTunes, myself, to listen to most podcasts, but I also use FeedDemon and it's built in support.
  • Note that for now, because of bandwidth constraints, the feeds always have just the current show. If you want to get an old show (and because many Podcasting Clients aren't smart enough to not download the file more than once) you can always find them at http://www.hanselminutes.com.
  • I have, and will, also include the enclosures to this feed you're reading, so if you're already subscribed to ComputerZen and you're not interested in cluttering your life with another feed, you have the choice to get the 'cast as well.
  • If there's a topic you'd like to hear, perhaps one that is better spoken than presented on a blog, or a great tool you can't live without, contact me and I'll get it in the queue!

Enjoy. Who knows what'll happen in the next show?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.