Tuesday, July 24, 2012

Disconnected WPF Applications

I was recently tasked with presenting a plan to turn an existing WinForms program into an enterprise level application. They wanted to stick with a Windows client, but since each form would already need significant rework to extract the business logic, I suggested moving to WPF using the Model-View-ViewModel (MVVM) presentation pattern.

MVVM is basically a type of Model-View-Presenter (MVP) pattern that makes use of declarative bindings. State and logic are stored in the Presenter (ViewModel) which presents an abstract view of the UI with no knowledge of what View will implement it.

With the Presentation Layer taken care of, it was time to address the heart of the Application. The immediate need was for a smart client, however the solution was still very young and continually changing so it seemed a Service Oriented Architecture (SOA) would provide the most flexability and reuse. The question was how a disconnected client would use services.

Microsoft used to offer an application block for this specific purpose. The Disconnected Service Agent Application Block helped maintain a queue of web service requests while working disconnected (offline), then submit them to the server when it became available. Unfortunately, it is no longer being maintained and I have not found a suggested replacement. My guess is that they would encourage use of Sync Framework, which is designed to synchronize databases and files, but can use custom providers as well.

We're using Sync Framework to replicate data down to the client for offline use, but to utilize SOA and keep business logic/validation on the server we need a way of queuing web service calls and resolving any conflicts that occur. I'm currently in the process of researching whether a Sync Framework custom provider would be a good fit or if the old disconnected service agent application block would be a good starting point.

The existing relies very heavily on SQL stored procedures. Fortunately, Entity Framework (EF4) supports calling the existing stored procedures so they wont all have to be rewritten immediately. The plan is to gradually move business logic up into the application layer and use entity model. I've also added a generic repository to allow mocking.

I welcome feedback and suggestions. If you've tinkered with custom providers for Sync Framework or have suggestions for how to best queue and resolve service calls I'd love to hear from you, either by leaving a comment below or on twitter (@gainesk).

Thursday, July 19, 2012

Water pressure issues? Let it flow!

Most of my articles are about technology and software development, however I recently purchased a new home and, as I worked on various things around the house I realized others might benefit from a few of the more common issues I've addressed. Some of these problems might seem simple to fix, however I figure there are others like me who are learning these things for the first time and might find my experiences helpful.

Problem: Water pressure is fine at first, but within a few seconds flow decreases significantly. The hot water never gets beyond warm, but both hot and cold suffer from the same decreased flow.

Diagnosis: It's important to distinguish between water pressure and volume. Low water pressure results in a lower flow as soon as valve is opened. This can result from undersized pipes or the use of valves/connections that reduce flow as well as simply receiving low pressure from the source. A volume issue results from some restriction farther down the line that allows a higher pressure to build over time, but once that pressure is released (such as in the first few seconds of running water) then the pressurized volume is exhausted and flow is limited by the restriction. If both hot and cold lines suffer from the same symptoms then the problem most likely exists on the main water line before the water heater.

Solution: Every situation is different, but in my case I found that the main cutoff valve at the meter box was not completely open. One and a half turns more and the restriction was gone restoring full flow to the house.

If you've run into a similar problem I'd love to hear about it. Comments are appreciated and you can find me on twitter (@gainesk).