Onion Peels Blog

powered by Bloget™ - "One File, One Binary, One Blog"

Friday Links

Links I found interesting this week.

Understanding IIS7 Request Restrictions on Windows Vista - Just how many concurrent requests does IIS7 allow?

Wicked Code: Silverlight Page Turning Made Simple - Great introduction to the world of Silverlight. Cool page turning demo.

Bright Focus - Firefox add on that highlights buttons, links and textboxes similar to what Safari does.

11 More Visual Studio Shortcuts You Should Know - I particularly like the CTRL + "K" + "M" tip.

Solar House - Great looking sun space that can reduce utility bills significantly.

Addictomatic: Inhale the Web - Search with an emphasis on blogs and news sources.

When Is - Dates of Religious and Civil Holidays Around the World.

Copy Link Text (CoLT) - tiny extension for Firefox which makes it easier than ever to copy a hyperlink’s associated text

Terrafugia, Inc. - The Transition® is a roadable Light-Sport Aircraft that will be able to land at the airport, fold up its wings, and drive on the road. Cool videos

Luxim Plasma Light Bulb Kicks Some Serious LED Butt - See a bulb the size of a puffed rice used as a street light. Way cool

Simultaneous Invention - Great inventions created by the same people at the same time. Though provoking

Change the Font of Command Prompt Window to Consolas - Use the superior Consolas ClearType font in your DOS box.

Is Google trying solid-state disks? - Rumor has it Google is trying out solid state disk drives to lower energy costs.

Json.NET Library - Json.NET library makes working with JavaScript and JSON formatted data in .NET simple

Nissan plans electric car by 2010 - Nissan plans to be the first major automaker to ship a plug-in electric. Looks like a toaster to me

MyColors - Change your desktop to look like Vista. From StarDock, makers of Window Blinds. Nice

Create a Live Survey for your Site with GoogleDocs - Create surveys and collect results with GoogleDocs.

Choosing the Right Garbage Collector Settings for Your Application - Great article on tweaking the garbage collector settings in .NET applications.

Google Doctype - A Wiki style online encyclopedia for Web authors

SpaceTime 3D Browser - A unique and free browser application that time lines your browsing habits. Nice 3D effects. Not sure how useful it really is however.

Posted  Friday, May 16, 2008  |   0 Comments
Tags  Links 

 

Links 2008-05-09

I'm moving like cold molasses this morning with this head cold. Still, the blog must go on. Here's some stuff I found interesting this week when I didn't have a head cold.

Programmers Don't Read Books -- But You Should - Jeff Atwood's, "Coding Horror" is always a great read. I've read most of the books he recommends here.

Better Pull Quotes: Don’t Repeat Markup - CSS Tricks contains some very useful code, like this gem.

A Great Visual Studio Add-on You Must Have - I've used power commands for a while now. Seamless and useful.

K-Meleon: It's like Firefox, without the bloat - It's a little to light for my tastes but who knows, maybe you'll like it.

Five command line tools to detect Windows hacks - Command line tools for the discriminating administrator.

LyX – The Document Processor - I still have my circa 1984 TeX reference. Still the best way to do book publishing. LyX is a combination of tools that makes TeX and LaTex a bit more word processor like.

Fax Documents Over the Internet for Free to any Phone number in US - Send unlimited number of faxes without registration, there are no ads attached to the fax sheets and each fax document can have up to 20 pages.

Understanding IIS7 Request Restrictions on Windows Vista - Just how many concurrent connections does Vista support. Answer, it depends...

Posted  Friday, May 09, 2008  |   0 Comments
Tags  Links 

 

DRM Free Music at Amazon

Jeff Atwood, the author of the fabulous Coding Horror blog, has a great write up about buying DRM (Digital Rights Management) free software from Amazon.com. I never bought music from ITunes simply because of the DRM issues. However, like Jeff, I vote with my wallet and buy music from Amazon.com precisely because it is DRM free. What cracked me up the most however was some of the comments he makes along the way.

You'll get no argument from me that the RIAA and the major record labels are as close as you can get to pure evil while not actively killing small children, puppies, and kittens. Well, not in public, anyway. I'm sure they'd be charging us a trillion dollars per song -- no, per byte of the song -- if they could get away with it.

I like good writing and I like it even better when the author has the confidence to poke fun at issues without being tasteless. Something I'm going to strive for.

Posted  Thursday, May 08, 2008  |   0 Comments
Tags  Life 

 

Programming WCF Services

My two favorite .Net programming books just happen to be by the same author - Juval Lowy. The first book, "Programming .NET Components", is a well worn companion that often is not on my desk because I loan it out so often. And now, "Programming WCF Services" occupies the #2 slot of .Net book favorites.

Lowy's writing style is terse, concise and yet somehow compelling. I find myself often rereading chapters after working through some programming issue related to the subject matter. It's always interesting to me how I can reread a chapter a few weeks or months later and find fresh insights. There's a certain layering of knowledge that reveals itself in subsequent readings that's hard to explain.

Lowy's treatment of the subject matter is encyclopedic with numerous examples and countless insights. Lowy does an excellent job of describing the motivation behind each and every example giving the reader ample information to understand exactly what problem is being solved. There's a certain "economy of motion" in the text that is both refreshing and inspiring at the same time. 

If there's one flaw in the book it's that the excellent, "Introduction to Service-Orientation" is in the wrong place. It's in Appendix A, at the back of the book. If anything, this must read chapter should be the introduction to the book. It provides the key motivation for using and designing around WCF Services.

Judging from the comments on Amazon.com, I'm not alone in my praise for this book. Of the 47 reviews, 40 are 5 star ratings. This is not a book for beginners and I suspect even moderately skilled programmers will find sections of this book challenging, but if you're serious about your craft, then this is a must have reference.

 

C#'s Unsung Hero

I was updating some legacy Windows C++ code last night and the pain of using it hit me like a ton of bricks. In particular, the string handling was a nightmare. Here are all the ways I found strings used in this program:

  • CString
  • Bse_String (private class)
  • OLESTR
  • LPCTSTR
  • LPSTR
  • wchar_t (include const and pointer variants)
  • TCHAR (include const and pointer variants)
  • char (include const and pointer variants)
  • STL string
  • BSTR
  • _bstr_t
  • CSimpleStringT

What a mess. And worse still, this only address the width of the characters, not the encoding. Now admittedly, some of macro types overlap but still if you haven't used this stuff in a while, it is hard to remember what maps to what.

And then there are all the _t variants for the library methods. For instance, _tstrcpy replaces strcpy. Finally, there are macros to help with conversions like W2A, T2W, CA2T, etc.

C# String handling is light and breezy by comparison. There's one class and it pretty much deals with everything concerning string handling. Encodings are equally easy and the support for common encodings like UTF-8 are supported. Ever try to do UTF-8 in C++?

And what about localizations? I never did get the hang of the C++ locale and facet classes. In C# (well .Net really) it's built-in.

So here's to C#'s unsung hero, the humble and unifying String class.

 

Links - 2008-05-04

Seems like there is a lot more to read as of late on the Web. Either that or I'm just bored.

StuffSafe - Online home inventory. I made the mistake of using Microsoft Money's home inventory years ago. Don't do the same.

Tip: Silence Window's Command Line Error Beep - This is one of those priceless little tips I should of thought of.

XS EULA Generator - Need a quick end user license agreement (EULA)? This is the way to go.

Google Recipe Search - In beta. Very cool.

The Vulcan Project - Maps of pollution hotspots by NASA. Very interesting...

ThreeSharp Library for Amazon S3 - Open source project in C# for interacting with Amazon's very cool S3 storage service.

NeoLoad - Performance testing for Web applications. Looks interesting.

Ajaxload - Ajax loading gif generator. There are a lot of these on the net. This allows better color control.

Fold Laundry Faster - Stupid pet trick for folding shirts. Guess I'm a sucker for short cuts.

Students can Get Free Microsoft Software - If you're a student, you could save some serious coin here.

Feed Analysis for your FeedBurner Feeds - Forecasts the performance of your blog based on FeedBurner statistics. I'm doomed according to their analysis.

Windows Utility to Create Self-Extracting Archives - IExpress is part of Windows and does a decent job of building self archiving files. Who knew?

 

Using Attributes to Exclude Code from Coverage in TestDriven.Net

There are times when you don't want your coverage level penalized for code not covered. Often this occurs with code that is produced from a code generator. Since TestDriven.Net invokes NCover with the //ea CoverageExcludeAttribute switch, it's relatively easy remove code from the coverage statistics.

First, define the CoverageExclude attribute. Make sure to declare it outside of any namespace scope (I made this mistake and struggled for 10 minutes to figure out why it didn't work). It's best to define the attribute in your non-test code to reduce couplings between assemblies. The attribute requires no methods beyond the default constructor.

public class CoverageExcludeAttribute : System.Attribute { }

Then decorate the modules, classes, methods and propertes you want to exclude.

[CoverageExclude]
public class SomeClass { }

The next time you run TestDriven.Net and select coverage, the decorated code will be excluded from coverage.

You can capture more information about who excluded the code and why by doing the following:

public class CoverageExcludeAttribute : System.Attribute
{
    public string Author { get; private set; }
    public string Reason { get; private set; }

    public CoverageExcludeAttribute(string author, string reason)
    {
        Author = author;
        Reason = reason;
    }
}

(Don't you just love auto implemented properties?)

Use it as follows:

[CoverageExclude("Mike", "I not sure yet")]
public class SomeClass { }

If you want reports produced by NCoverExplorer to report these exclusions, you can use the techniques documented here.

 

Commonly Botched Interview Questions

Lately, I've had to do a some interviewing for new positions that have opened up here. My interview style is to not ask too many questions and to try and get the candidate to talk about themselves. Still, there a few technical questions I ask just to make sure the basics are understood. It's surprising how candidates with many years of experience can't answer the following:

  • Define Inheritance - I think most candidates have a notion of what this is but manage to stumble around for 5 minutes or more answering it. What's strange is that it can be described pretty much in one sentence. Answer: Defining new classes from existing classes.
  • Define Polymorphism - I would love it if a candidate asked "Ad-hoc or Parametric?" But they never do. Again, I usually get a 5 minute answer that sort of approximates what I'm looking for. Often they define by example using the classic "Shape, Square, Triangle" example. Answer: Allows values of different data types to be handled using a uniform interface. Parametric Polymorphism is defining a type without mention of any specific type (also called generic programming). Ad-hoc Polymorphism - characterized by overloading (defining multiple methods with the same name but different types) and overriding (overriding or replacing existing code).
  • Define Encapsulation - Again, I get a lot of hemming and hawing on this one often. Many candidates have a notion of what this is and try to define it by giving examples. It can be answered in a number of ways but mostly what I'm looking for is here is a mention of information hiding and separation of concerns.
  • What's the difference between malloc and new? - This is the easiest one of the bunch and it rarely gets answered correctly. Answer: malloc allocates memory from the heap, new allocates objects from the heap.

As you can see, there's not much in the way of language specific stuff here. I'm more concerned with whether the concepts are in place. Good people will pick up new languages easily if the concepts are well understood. If the candidate misses these, it's pretty much over from my perspective. By the way, we're hiring...


 

C# 2.0 ?? Operator

I'm surprised how many of my colleagues don't know about this little operator. Termed the null coalescing operator, it returns the left hand operand if not null, else the right hand operand. It makes for handy shortcuts in code and I think actually improves the readability when used judiciously. Here's an example:

Console.WriteLine(name ?? "Unspecified");

Seems self-explanatory and it's fewer keystrokes to boot. It's also nice for lazy evaluation type statements:

public User TheUser
{
  get { return theUser ?? (theUser = new User()); }
}

Phil Haack postulates that this operator is thread safe based on an examination of IL. Don't know if that is true since I'm no IL expert either but since the left hand side is evaluated only once, there's a strong indication that it is.

There's also a good article about the null coalescing operator at the Code Project.

Finally, you can use ?? with value types in limited situations as described here.

 

Software Architecture - why does it sometimes fall short?

I'm asking the question because more and more my responsibilities are shifting into the area of architecture. As a developer, I've always eyed architects with a bit of suspicion. After all, they don't program so how much do they really know? And do they really have to live the consequences of their designs the way developers do? I sometimes wonder. Still, there is a need for an over-arching view of the subsystems and how they work. I guess what bugs me about architecture is that it's often done up front and then left to rot as the project develops.

And why is this? I think it comes down to enforcement. Unlike code where you can apply static analysis, write unit tests and do code reviews to verify results, architecture tends be a bit more slippery. How often do you hear in a code review that such and such an implementation violates the architecture?  In my experience, not often.

A colleague of mine wrote an interesting paper about this and brilliantly summed up the problem (at least for me) in two sentences.

What this means in practical terms is that architecture specifications must be enforced by peer reviews or other means external to the programming language and development environment itself. Being non-local means they can be easily broken, and if they are indeed valued by the organization as a whole, adherence to an architecture document needs to be enforced externally.

He's spot on when he says being "non-local means they can be easily broken." Developers can easily do end-runs around architectures both intentionally and non-intentionally. It's an important matter for the architecture team to remain ever vigilant in monitoring the development of the software.

And the best way to do that in my opinion is that architects need to do implementation. That's right, hands on coding. It doesn't have to be a big part of the project but it's important that they "put hands" on the system and live with their decisions. Day to day interaction with the code and the team is important from so many perspectives. Beware the non-coding architect!

 

previous | next

powered by Bloget™