Welcome to MSDN Blogs Sign in | Join | Help

jaredpar's WebLog

Code, rants and ramblings of a programmer.

Syndication

News

Now Reading

Pragmatic Programmer

Pragmatic programming at it's best. The book is a light read and worth the time

Essential WPF

Thus far the best book I've read on WPF. Gets right down to working with WPF and the goals/history.

Purely Functional Data Structures

Reading this book makes me feel like I'm back in college. It will really get your mind going and is best read with a whiteboard handy.


Browse by Tags

All Tags » C#   (RSS)
Don't mix using statements and lambda expressions
Title pretty much says it all but what good is a rule without any explanation. The main issue here is that at the core, using statements and lambda expressions both alter variable lifetimes. Unfortunately they alter the lifetime in different directions. Read More...

Posted Wednesday, July 16, 2008 8:00 AM by Jared Parsons | 9 Comments

Filed under: ,

Yet another rule for Equality
"If you implement equality in a child class, including operators, you must implement the equality operators in the base class." Unfortunately this is another case of learn the hard way but makes sense when you think about it. The below code snippet is Read More...

Posted Friday, July 11, 2008 8:00 AM by Jared Parsons | 6 Comments

Filed under: ,

Enums vs. Adapters
I like Enums and use them frequently for options and behavior.  To an extent I use Enum's to control behavior.  For example enum Kind { Kind1, Kind2, Kind3 } class Example { private Kind m_kind; public int SomeAction() { switch (m_kind1) { case Read More...

Posted Wednesday, June 18, 2008 8:00 AM by Jared Parsons | 9 Comments

Filed under: ,

Switching on Types
One action I find frustrating in C# is where a particular action needs to be taken based off of the type of a particular object. Ideally I would like to solve this with a switch statement but switch statements only support constant expressions in C# so Read More...

Posted Friday, May 16, 2008 8:00 AM by Jared Parsons | 8 Comments

Immutability and ReadOnlyCollection<T>
I am a huge fan of read only/immutable collections and data. Hopefully the increased exposure through the blogosphere alerted users to the advantages of this type of programming for the appropriate scenarios. I wanted to discuss ReadOnlyCollection<T> Read More...

Posted Tuesday, April 22, 2008 8:42 AM by Jared Parsons | 1 Comments

Filed under: , , ,

Gotcha: Generic overload resolution when called generically
Both VB and C# have a feature of generic overload resolution that is fairly helpful and yet a source of gotchas. Lets say you have two methods with the same number of arguments. One method has arguments with generic types and the other does not. For Example: Read More...

Posted Monday, April 14, 2008 8:30 AM by Jared Parsons | 1 Comments

Filed under: , ,

Design Guidelines: Provide type inference friendly Create function for generic objects
Really this guideline is a bit longer but putting it all in a blog title seemed a bit too much.  The full guideline should read: "If a generic class constructor arguments contain types of all generic parameters, provide a static method named Read More...

Posted Friday, April 11, 2008 8:24 AM by Jared Parsons | 3 Comments

Filed under: , , ,

Have an IComparer<T> but need an IComparable<T>?
Previously we discussed the opposite problem.  This is a lesser but often more frustrating problem because there is no, AFAIK, built in solution for the BCL.  However it's problem that can be solved once and reused with a generic solution. IComparable<T> Read More...

Posted Wednesday, April 09, 2008 8:20 AM by Jared Parsons | 0 Comments

Filed under: , ,

ActiveObject
I've been busy lately and neglected my series on Active Objects .  It's been a fairly busy time for me both in and out of work.  Enough excuses, back to the fun. With the basic PipeSingleReader class, we now have the last piece necessary to Read More...

Posted Sunday, March 30, 2008 12:39 PM by Jared Parsons | 0 Comments

Filed under: , ,

PipeSingleReaderNoLock
Previously we discussed a multi-thread safe queue like data structure using locks as an internal synchronization mechanism. This time we'll look at a version requiring no locks. In the previous version, locks were used to synchronize access to an underlying Read More...

Posted Monday, March 03, 2008 12:46 AM by Jared Parsons | 0 Comments

Filed under: , ,

PipeSingleReader
Before we can get to building an Active Object implementation, there are some more primitive structures we need to define. Active Objects live on a separate thread where every call is executed in a serialized fashion on that thread. The next primitive Read More...

Posted Sunday, March 02, 2008 12:53 PM by Jared Parsons | 6 Comments

Filed under: , ,

SynchronizationContext and Higher Order Functions
It's often useful to ensure that actions occur on specific threads, in particular event handlers.  Take Windows Forms for instance where all operations on a Control must occur on the thread it was created on.  Typically this is not a problem Read More...

Posted Sunday, February 24, 2008 4:42 AM by Jared Parsons | 1 Comments

Factory Methods for Futures
Like most generic classes, I prefer to create Future instances through static factory methods which allows me to take maximum advantage of type inference. In addition to the 2 straight forward declaration of Func<T> and Action, the methods will Read More...

Posted Saturday, February 23, 2008 8:35 PM by Jared Parsons | 1 Comments

Filed under: , ,

Thread Affinity
Part of creating a multithreading program is understanding which threads objects live on.  Seems simple enough and typically is.  However it's nice to insert guarantees to match the design. One type of threading model is for objects or subsets Read More...

Posted Friday, February 22, 2008 8:55 PM by Jared Parsons | 1 Comments

Filed under: ,

Building a Future which returns no Value
In addition to Future<T> there is also the concept of Futures that don't return any values.  Instead the perform the operation and return.  Because there is no additional data to pass between the threads building an Empty Future is fairly Read More...

Posted Monday, February 18, 2008 4:15 PM by Jared Parsons | 1 Comments

Filed under: , , ,

More Posts Next page »
Page view tracker