Best of 2006

I started this series last year and thought I would continue the tradition with my best of 2006 collection.For me, 2006 was the year of the .NET Compact Framework Version 2 Service Pack 1.  This release added several new tools for .NET Compact Framework application developers — including support for the MDbg command line debugger. …

0

Recommended Reading IV

It’s been a while since I last recommended a book… in fact, it’s been more than a year.  There are a number of good books on how to write secure code, now there’s one on how to make sure that developers have written secure software: Hunting Security Bugs (Microsoft Press, ISBN: 0-7356-2187) by Tom Gallagher,…

1

Quick Tip: Identifing the interfaces that an object implements

Have you ever wondered what type an object is?  How about what interfaces the object implements?  Using the .NET Framework and .NET Compact Framework, this information is very easy to determine.The first thing we need to know about an object is it’s type.  Every object, including Object, has a method called GetType().  For a given…

1

Quick Tip – Sharing code between multiple projects in Visual Studio 2005

I have long been an advocate for putting common code into an assembly that is shared by applications needing the functionality.  That said, there are times where the separate assembly approach is not appropriate.  For those situations, today’s tip may help make code sharing easier.I have a project (called TestApp) that targets the .NET Compact…

3

What is late binding?

In a nutshell, late binding is run-time resolution / dynamic loading.  Compile time resolution (sometimes called ‘early binding’), uses the compiler and linker to verify that the argument types used to call a function matches the function’s signature.  In my mind, early binding allows me to check my grammar (how I am calling functions) before…

1

Quick Tip: Specifying a field’s name when using the XmlSerializer

Last month, I wrote about how to instruct the XmlSerializer to create an XML attribute for fields in an object.  Today, I’d like to talk about how to specify the name used to represent a field in the resulting XML.By default, when an object is serialized, fields are serialized into nodes with names that match…

1

‘const’ vs ‘static readonly’

I’m a big fan of reusing code whenever and wherever possible.  A long time ago, I wrote an assembly that provided common methods and data to some applications I was writing.  When I first wrote the assembly, I exposedthe common data as public fields decorated with the const keyword, as shown in the example below.public…

3

Is it a field or a property?

I very much value code reviews, as long time readers can attest.  During these reviews, I have often found myself wondering whether a given line references a field or a property.  When reading isolated portions of code, properties can be easily mistaken for fields.  Player player = new Player(“Someone”);String name = player.Name;player.Age = 22;By looking…

5

What is a Side Effect?

We’ve all heard the commercials or read the prescription information sheets describing the possible side effects of medications.  The side effects described are typically negative (ex: upset stomach).  There are other side effects of a more positive nature; a medication helping treat an illness that it was not designed for, etc.  In software, side effects…

1

Separating Application Logic and Data Presentation layers

I’m a big advocate of separating an application’s logic from it’s user interface.  By keeping the logic separate from the data presentation layer (UI), it becomes easy to swap out either component with minimal impact on the other.  In addition to ease of replacing components, keeping the user interface separate from the application logic avoids…

2