Understanding and Using System.Transactions

These are some resources to help grasp System.Transactions functionality and use it effectively in your projects: Features Provided by System.Transactions to create transactional applications Implementing an Implicit Transaction using Transaction Scope MSDN Magazine Articles by John Papa: ADO.NET and System.Transactions Revisiting System.Transactions These are specific to TransactionScope (the way to go in most cases): Here is a practical example of Using TransactionScope to handle transactions in .net. This article in MSDN Magazine gets in depth with the way a TransactionScope like functionality can be implemented. Gives you a good understanding of what is happening under the hood when using TransactionScope in some Repository implementations in multi-threaded scenarios. This CodeProject article is another example of implementing a transactional repository. There are […]

Solution to the fetch puzzle

Here is a brute force solution to the fetch problem – Basically, at each step there are three possibilities : 1. You can fill a bucket. 2. You can transfer water from one bucket to the other one. 3. You can dump out the water from a bucket. In this brute force solution, I try each one of these steps and then try all three again after each one of the previous steps. And on and on untill I get the required amount of water in one of the buckets. Check it out. Source code is on my github repo – https://github.com/ashtewari/fetch Here is a brute force solution to the fetch puzzle. The puzzle goes like this – You have two […]

Solve puzzle with code

Here is a quite common programming interview puzzle – You have two buckets. A 3 gallon bucket and a 5 gallon bucket. Buckets are not marked or graduated. You are to fetch 4 gallon of water in a single trip to the river. How will you do it? Obviousy, this question is asked by changing the capacities of the two buckets and the amount of water to be fetched. Your mission, should you choose to accept it, is to write a program to solve this puzzle in a generic way. Your program should take 3 inputs – capacities of the two buckets and the amount of water to be fetched. After solving the puzzle, your program must write out the […]

Using Model-View-ViewModel in WPF Applications

I am presenting at SoCalCodeCamp this weekend (January 30th, 2010) – Advanced WPF – Using Model-View-ViewModel in WPF Applications. Agenda : 1. Roles of the M-V-VM triad 2. Why use M-V-VM ? 3. Characteristics of the ViewModel 4. Build a Sample WPF Application using M-V-VM Resources : MSDN Magazine Article and Sample Application Download Martin Fowler’s description of the ‘Presentation Model ‘ Jeremy Miller’s ‘Build Your Own CAB’ series

Dial Gauge is a ProgressBar

I am not just being philosophical here. In WPF, ControlTemplates allow you to transform a control’s appearance. This is not the same as applying stylesheets. This is an entirely new level of customization. What you see in the screenshot below looks like a Dial but is actually a simple ProgressBar control wearing a “Dial” template. The Dial template was created using Microsoft Expression Blend . Include the ControlTemplate as a Window.Resource and then assign it to ProgressBar element’s Template attribute : Of course that is not all. The ControlTemplate must define some named elements of FrameworkElement type. Charles Petzold has explained it in detail : MSDN Magazine Article. So, I will not repeat it here. The sample code can be […]