Ben Rees' .Net Blog and Notepad


 while(!goodCode) ape++;

Welcome to my blog site.  This is my notepad and soap-box of ramblings on all things .Net and current .Net projects. Ascendancy to simplicity is a long and complicated journey. Oh, and this site does not use US English spelling
Windows 

Event Deregistration and Memory Leaks

15-August-2010

I think its pretty safe to say we would all recommend deregistering/unsubscribing events when we are finished with them. I know I was told when learning about events years ago, that if you do not, memory leaks would result. After looking into the GC recently I thought it might be interesting to get some specifics around this.
So, what happens when you don't unsubscribe from events and just pray the GC can figure it out? Unsurprisingly some objects stay alive a lot longer than they should. The problem can be summarised as follows:





Parallel Extensions

31-August-2010
The new Task Parallel Library included in .NET4 is an incredibly easy way to parallelise processing, that would otherwise have to be done with such devices as SpinLock, Semaphores, Monitors and others.  Unfortunately those previous devices were crazy easy to get wrong, and remember how they worked after 6 months has elapsed.

One of my favourite sessions at TechEd this year showed in some detail how to Parallise various code fragments using the new constructs.  
Loops are the easiest place to start (shortly followed thereafter with reconsidering all LINQ statements).



Software Design Principles

8-September-2010
Established List of Design Principles:

    Four founding principles of object oriented design: 
    Encapsulation. Organise like themed concepts into one unit (class) that performs one task or a group of similar tasks. These units often mimic real world objects, for example an         employee class may have a name attribute and a promote method. Encapsulation hides implementation details from the consumers, simplifying external use.

    Abstraction. The best definition of abstraction I've ever read is: "An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of object and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer." -- G. Booch. Encapsulation and Abstraction are closely linked and used together. Referring to an object using an appropriate level of abstraction allows grouping of different objects together and treating them alike. 

    Inheritance. Describes various levels of abstraction of an object. A cat class could inherit from Feline, which could inherit from Mammal which could inherit from Animal etc. Each of these levels can describe attributes and actions common to all children that inherit. 

    Polymorphism. By grouping different objects together that all have a common abstract parent actions can be performed on all the objects at once.

Twitter

The gadget spec URL could not be found

Recent blog posts...


Who the hell am I?
Good question, if you find out let me know.  Apart from being a Jedi-Master in the Obvious... I'm currently working in Auckland New Zealand as a .Net software architect specialising in software for WPF and Silverlight. Favourite quote: "Whoop-de-doo... What does it all mean Basil" -Austin Powers.

 
Subpages (50): View All
Comments