Tagged: Patterns

N-Tier Patterns Links

Anti-Pattern #1: Tight Coupling
Anti-Pattern #2: Assuming Static Requirements
Anti-Pattern #3: Mishandled Concurrency
Anti-Pattern #4: Stateful Services
Anti-Pattern #5: Two Tiers Pretending to be Three
Anti-Pattern #6: Undervaluing Simplicity

DTO’s, Contract Amendment Pattern, Service Contract and Design Guidelines for Service Contracts, Dealing with Breaking Changes

When to use to IDisposable pattern

Answer: Whenever unmanaged resources need to be cleaned up. If you see class implements IDisposable then it contains unmanaged resouces.

Implementation details can be found here. The main components are

1) Destructor calls a dispose method with a flag to indicate that managed resources cleanup request is not required.

2) Add a dispose method that checks the flag to ensure managed resources are not cleaned up twice. Also cleans up unmanaged resources

3) Dispose function implementation that calls the dispose method with a flag to indicate that managed resources cleanup request is required. Note that¬† GC.SuppressFinalize is called to ensure the finaliser isn’t called that would otherwise cleanup the managed resources

Extra Note: using the using() encapsulation is not recommended for WCF client side proxies, since a number of exceptions can be thrown when it falls out of scope and calls the close method. Details here