Alois Kraus

blog

  Home  |   Contact  |   Syndication    |   Login
  113 Posts | 8 Stories | 297 Comments | 162 Trackbacks

News



Article Categories

Archives

Post Categories

Image Galleries

Programming

C# Programing

Singletons are the easiest programming pattern to learn which seems to be the reason why it is often used in places where it is inappropriate. They are very straightforward to implement and understand. Just create a static field and return the static instance in a public get property. A Logger Singleton is a classic example of this pattern: .cf { font-family: courier new; font-size: 10pt; color: black; background: white; } .cl { margin: 0px; } .cb1 { color: blue; } .cb2 { color: teal; } public class ......

This time I wanted to write something about the .NET Framework that is solved not optimal of the .NET Framework. My unsuspecting victim is the well known System.Diagnostics.Trace class. Static classes have the big plus that they are easy to use but they can be very hard to maintain if you want to extend it (no derivation) and have a lifetime problem with the objects that are created inside it. The Trace facade is in my opinion a prominent example of how you should not design a reliable static facade ......