‘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

Quick Tip: Serializing an Object Field as an XML Attribute

The addition of the XML Serializer is one of the reasons I really love version 2 of the .NET Compact Framework.  I use the XML Serializer in very nearly every application I write; to save application state, data files, etc.  By default, the XML Serializer will create a child node for every field in a…

1