Monday, March 17, 2008

IE8, Standards, and Joel is Scary Brilliant

By Joel, I mean Joel Spolsky. Not only does he have great taste in presidential candidates, but he's a person everyone in technology should be reading.

It's good to have idols, I think. I dream of having the perspective and wisdom to write like this.

The IE 8 team is in the process of making a decision that lies perfectly, exactly, precisely on the fault line smack in the middle of two different ways of looking at the world. It’s the difference between conservatives and liberals, it’s the difference between "idealists" and "realists", it’s a huge global jihad dividing members of the same family, engineers against computer scientists, and Lexuses vs. olive trees.

Of course he's talking about how IE8 will handle web standards when so much of the world expects IE to work the way it has always worked. Is there a solution? According to Joel:

There is no solution. Each solution is terribly wrong. Eric Bangeman at ars technica writes, "The IE team has to walk a fine line between tight support for W3C standards and making sure sites coded for earlier versions of IE still display correctly." This is incorrect. It’s not a fine line. It's a line of negative width. There is no place to walk. They are damned if they do and damned if they don't.

His Martian headset analogy is just a bit forced, but totally forgiven. The write-up is brilliant and fascinating.

Like Joel, I'm going to sit back with some popcorn.

...it will be really, really entertaining to watch...

Rob Relyea Hates my Mom

Mom, Dad, Kevin

My mother is a lovely woman. So I'm confused as to why Rob dislikes her so much.

Let me back up. Last August (when I was still at my former employer) I did some demos of new features in WPF 3.5 for Channel 9.

I was happy to see Rob reused some of the same demos for his MIX '08 Talk.

When I was watching the Add-In demo, I was surprise to see the data had remained the same--for the most part. My dad--Robert, my brothers--Brian and John, and I were still in the data set.

image

But my mother--Wynette--replaced by "Web Service". I mean, I know WCF is powerful, but it's a poor replacement for the most wonderful woman in the world--even if she has an uncommon name.

I did find it funny that the last name was left unchanged.

image

So come on Relyea. Let's hear it. I think I deserve an explanation. :-)

Friday, March 14, 2008

Reader Question: "Why WrapperElement<T> instead of Decorator?"

Yuval, via a comment, asks:

Can you explain why you chose to define WrapperElement<T> instead of simply inheriting from Decorator? They seem to be doing the same thing.

Ah, it is good to read my post "Don't subclass a Panel, unless you're making a Panel".

First, where do I used WrapperElement<T>? Well, at the moment, it's used in three places: FlipTile3D, Set, and Transition3D. In all cases it simply wraps a Viewport3D.

Now, could I simply use Decorator? Sure. I could subclass Decorator and do basically the same thing. Even easier: I could subclass Viewport3D.

Why don't I?

It's all about API usability and correctness.

When I write a control (especially for the bag-o-tricks) I try to make it "right".

If these controls subclassed Viewport3D, they should act like Viewport3D. Meaning, they should support someone added arbitrary lights, models, etc. They should support messing with and removing elements that are already added.

I don't want this.

Wrapping everything with a Decorator, just exchanges problems.

If I subclass Decorator, it would imply that I mean people to treat the control like a Decorator, which means accessing and changing the Child property.

I don't want this, either.

WrapperElement<T> does some very simple things.

  • Stores a Framework element as a child visual.
  • Adds it to its visual tree (via AddVisualChild)
  • overrides GetVisualChildCount
  • overrides VisualChildCount
  • overrides MeasureOverride
  • overrides ArrangeOverride
  • Provides protected access to the child so the subclass can play with it, but not the end user.

One should use WrapperElement<T> when one wants to use the implementation of an existing component--Viewport3D, Grid, etc.--but doesn't want the object model of that component exposed.

Make sense?

Thanks for the question, Yuval.

Happy hacking.

Wednesday, March 12, 2008

Consolas: the Coder's Font

Consolas is one of a set of new ClearType fonts that shipped as part of Windows Vista and Office 2007.

It's absolutely beautiful. I love to code in it.

The problem: no applications seem to be smart enough to use it by default. In this post, I'll go through all the places I use monospaced fonts

Visual Studio

Tools->Options->Environment->Fonts and Colors

Set "Plain Text" under "Display Items" to Consolas.

image

Firefox

Tools->Options

Under the Content tab, in the "Fonts & Colors" box, pick "Advanced". In Monospace, pick Consolas.

image

Internet Explorer

Tools->Internet Options

General tab, under Appearance, pick 'Fonts'.

Under "Plain text font:" pick Consolas.

image

.NET Reflector

View->Options

Under 'Appearance', 'Code Font': Consolas.

image

CMD.EXE

(Thanks to Walter for pointing this out to me.)

Yes, even the command window. If you're running Vista, make sure to run this command 'elevated'. You'll have to restart your machine before the setting takes effect.

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont" /v 00 /d Consolas

image

Next, right click on the command window header and pick 'Properties'. You'll probably want to up the font size, too.

image

And there you go. All your most important applications using the nicest monospaced font.

Happy hacking!

Saturday, March 8, 2008

Bag-o-Tricks March '08 Edition

January 12 was my last update to the bag-o-tricks. I couldn’t let two months go by without another refresh. There is a lot of stuff here I've already talked about. The code has been available via SVN for a while, but not in the convenient package.

The Goods

Binaries and Source [zip, 4.17MB]. Tested with Visual C# Express 2008.

The Details

  • VS Copy-to-HTML - New!
    • Blogged about it here.
  • NotifyWorker - New!
    • Blogged about it here.
  • HueConverter - New!
    • Makes it easy to create a pretty spectrum of colors for a number of items
  • Animating Tile Panel
    • Renamed AnimateNewItem property to AnimatesNewItem
    • Made initial load not animate new items
    • Polished the demo code
  • CompositionTargetRenderingListener
    • Added Dispose and used it where appropriate
    • Added WireParentLoadedUnloaded helper method
  • DemoCollection
    • Added Reset command
    • Moved to library assembly
  • Extentions
  • FlipTile3D
    • Moved to WrapperElement<Viewport3D>
  • FolderPicker
    • Moved to new SelectRecursive implementation
  • WPFUtil
    • Added HSB-RGB converter
    • Created ‘Animate’ methods to abstract physics model. Moved FileTile3D, AnimatingTilePanel, and ZapDecorator to these.
  • ZapScroller
    • A lot cleaner. Removed a completely unnecessary layer of complexity.
    • Added the ability to template the buttons. Thanks for the suggestion, Atul.
  • WPF Set
  • General
    • A bunch of renaming of namespaces. Most of the new stuff will exist under J832.Wpf

As always, the SVN location has been updated. Patches are always welcome. (I've had one taker on this. Very cool to do an apply patch. Would love to do it again.)

Enjoy and happy hacking!

Friday, March 7, 2008

iPhone makes me a better person

...or at least it makes me feel that way.

Let's rewind.

When I moved to Seattle in 2002, I had a simple, "candy bar" Nokia phone. I could barely text message with it, but it worked.

My first Windows Mobile phone was the Audiovox SMT5600--a fancy name for the HTC Typhoon. I could sync calendar and contacts over the air with Exchange. I could T9 through my address book.

I felt like I jumped 18 months into the future. I got the upgraded version of the Typhoon (with the weird bump on the top). It ran a newer version of Windows Mobile. It had a prettier screen. Let's say I jumped forward another 6 months.

Then I went BlackJack. Bigger screen. Keyboard. A reasonable browsing experience, at least for GMail. Maybe a jump of a year into the future.

After a brief stint, I managed to loose my BlackJack, and went to BlackJack 2. Slicker look. Newer version of Windows Mobile. Maybe a 6 month jump.

Fast-forward to Sunday. I was snowboarding with some friends. My phone was in my pocket. My pocket was open. I was in the terrain park. I lot my phone.

Damn.

So I go back to the AT&T store. And the iPhone stand starts calling to me.

I have many friends with iPhone.

Both of my brothers have one.

I get one.

It's been less than a week.

Easily a 5 year jump. I feel like I'm living in the future. The thing freakin' rocks. It makes the BlackJack2 look like a joke.

Not only have I ditched Windows Mobile, I've ditched Zune. I've gone to buying MP3s from Amazon's store. Instant gratification. No expiration. No DRM.

This is the future.

It flawlessly syncs with Outlook on my desktop. (I have a friend who's been trying to get it to work with her BlackJack for months.) The experience with iTunes is great. Maps, Email, SMS, all clean and beautiful.

With the announcement of the SDK and Enterprise support (over-the air sync with Exchange, etc) I can't imagine a better setup for a phone.

I'm sure Google will have a cool offer with Android. I'm sure MS is sweating bullets and cranking on some interesting stuff. At least I hope so.

In the end, the bar has been raised--by a lot. All mobile users will benefit in the long-run by the existence of iPhone.

Especially those that have one.

I couldn't imagine going back.

Let me say it again: wow.