Chris Donnan : Programming - Brooklyn Style
software, trading, family, fun
Posted .net, wpf on Friday, September 5th, 2008.
General WPF + WPF Blogs:
http://wpfwiki.com/
http://www.beacosta.com/blog/ (great for databinding)
http://blogs.msdn.com/mikehillberg/default.aspx
http://joshsmithonwpf.wordpress.com/
http://blogs.msdn.com/wpfsdk/default.aspx
http://drwpf.com/blog/Default.aspx?base
http://karlshifflett.wordpress.com/
http://wpfdisciples.wordpress.com/
Unit Testing WPF
http://miketwo.blogspot.com/2007/03/unit-testing-wpf-controls-with.html
http://www.codeproject.com/KB/WPF/unittestingwpf.aspx
WPF Articles
http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx
http://blogs.msdn.com/mikehillberg/archive/2006/09/14/WpfTraceSources.aspx
http://www.codeproject.com/KB/WPF/UserControlAsDataTemplate.aspx
http://www.codeproject.com/KB/WPF/VMCommanding.aspx
Fav Tools:
Posted .net, wpf on Monday, September 1st, 2008.
After ~1 mont of earnest all day type WPF programming, I have come to see the wisdom of the much blogged about, microsoft touted/ originated Model-View-ViewModel pattern for WPF apps.
After many years of all day Windows Forms programming, I had my style down. WPF, I have been doing pet projects with it for ~1.5 years. Now, using it for day to day work, I am finding myself doing things differently. I feel the WPF coding evolving towards something and I think I have organically evolved my current work to Model-View-ViewModel.
Here is a linkfest:
- The DataModel-View-ViewModel pattern series This is basically the pivotal series on the topic
- Here is Josh Grossman’s (2005) article on the topic, how it the pattern has been used in Expression (Sparkle) design
- This is an aside article, but I empathise as I believe I began down the same route (binding directly to the raw datamodel, as opposed to the ViewModel)
- A good practical article from Josh Smith on using the pattern with the WPF tree view
- Another article from Josh Smith, a bit of an extension, but I have been looking for a more natural feel for commands, this seems a good match.
I managed not to say anything, but to include a bunch of good ref’s and say that I am feeling increasingly at home with WPF.
As long as I can be productive for my business, write less code that is more maintainable, I will be a happy camper. I am still reaching for a good way to have dependency injection fit in fundamentally into my WPF work. It is there, but I want it deeper!
-Chris-
Posted wpf on Tuesday, August 26th, 2008.
So in my last post, I blogged about WPF components. I have veen deep with the ones I mentioned and more in the past 2 weeks and I have reached some conclusions about WPF component vendors. I have also eval’d more vendors out there to add to my list.
So last post, I was continuing to actively review:
- Infragragistics
- ComponentOne
- Developer Express
- Syncfusion
I was mainly looking @ their grids as my #1 needed component. I can say that I have spent a fair bit of time now with each one, and I have some solid opinions. I have also drilled down a level and reviewed the suites from other vendors including:
- Xceed
- Telerik
- DivElements
- and even Nukeation’s Reuxables reusable WPF themes
At the end of the day, there is actually a fair bit of usable vendor software out there. The grid was by far the hardest to select as there are just so many ‘bells and whistles’ you can have in a grid product.
My WPF Vendor Grid Rankings
- Xceed
- Infragistics
- ComponentOne
- DevExpress
- Telerik
- Syncfusion
That is not uber-precise, but it is my general feeling. Here is a random list of features I was looking for:
- performance
- summaries
- hierarchical data
- quality data-templating
- general ‘feel’ of the grid
- sorting
- skinning
- auto-filter
- any Excel-like features
- API feel
- out of the box embedded editors
- documentation/ examples
Other WPF components (excluding the grids)
That ranking is just for my grid. Interestingly, my least favorite grid implementation was Syncfusion’s, but they actually had the best (IMO) general controlls suite; The Syncfusion WPF Tools set. I compared this with Infragistics control suite for the most part. I did look at all the above mentioned vendors, and the ones in contention were mainly Syncfusion and Infragistics.
Infragistics seemed to focus on ‘bling’. They had really nice carousel controls, but financial apps are no place for those unfortunately. They had a few basic ‘editors’, but syncfusion just had a few more.
Docking and Ribbon control; both Syncfusion and Infragistics offered good Ribbon controls and Docking controls. They all look the same. The APIs are very similar (unsurprisingly). I liked them both.
Explorer bar; Infragistics latest CTP has an explorer bar, and Syncfusion has one out. Infragistics gave me some bugs while working with it, so I could not get too deep. It kept blowing out my XAML files unfortunately. I am sure it is just fine, once it is out of beta.
Syncfusion also has a handy Autocomplete control. It is not fantastic, but it was in use in minutes and I got good use of it fast. Infragistics has no analogy.
Syncfusion has the following controls:
- Ribbon
- Explorer bar
- Autocomplete
- Task bar
- Docking
- Font list/ combo box
- Gallery (cool)
- Datetime edit
- Numeric Up/ down
- Color Picker
- Advanced Tree View
- Clock
- Masked Text Box
- Integer Text Box
- Double Text Box
- Calendar Edit
I could go on and on. Essentially, this is what I have so far. I hope it is helpful to someone/ anyone!
-Chris-
Posted .net, wpf on Sunday, August 10th, 2008.
Well, I have been building toy projects with WPF for some time now. I have been monitoring and trying Acropolis, Prisim and whatever the heck they call prism now. I have been closely monitoring the landscape of 3rd party vendors.
In order to be productive and deliver real, purposeful applications I need to be able to focus on the business domain (finance/ trading in my case). I DO NOT want to build low level widgets. I do not want to rebuild the wheel. In order to do this, I need to use a component vendor. This gives your application ‘perceived integrity’ inasmuch as your users will see something and touch something that looks like a modern application, not a 1995 web page with java applets and midi songs.
So - I have been following the big vendors and their WPF offerings:
* Infragistics
* Syncfusion
* ComponentOne
* Developer Express
I have ben waiting for Developer Express in particular to come out with their grid offering. They released it not too long ago. Syncfusion also released their grid not too long ago. Infragistics has had the longest lived WPF product suite. Grids are the most important component in my world. The other components are also important, but grids are king in my world.
I need minimally:
* Grid
* Docking/ MDI management
* Toolbars/ Ribbon
* General Editors
DevExpress
As far as grids go, DevExpress is my favorite WinForms grid provider. It is fast, flexible, good in every way. Their WPF grid is nice enough, but not nearly as plush as their WinForms grid.
Their other great component is their layout component. It is still not in their WPF Suite. Unfortunately, they only have a chart offering and a grid. They are not quite there yet.
* Grid
* Charts
Syncfusion
At one point (in WinForms days), Syncfusion was the darling of wall st IT departments. They were fast, the only one that did a good enough job supporting real time market data. At a point, the rest of the grid vendors caught up and in Developer Express’ case, surpassed Syncfusion. Their WPF grid offering feels immature to me. Aside from a grid they do have a more complete offering than say Developer Express:
* Grid
* Docking
* Several nice editors
* Charts
* Ribbon
* Taskbars/ Groupbars
* An auto-complete control
All in all, they have a nice package, notwithstanding the grid which as I mentioned - feels immature.
Component One
I have never really been a big fan of Component One. Their WPF Offering still has an uncomfortable feel to me. They currently offer:
* Grid
* Schedule
* Charts
* Reports
I have played with the grid a bit. I wanted to like it, but it just doe snot feel right to me… I realize that is qualitative, but so be it.
Infragistics
Well, Infragistics has the best grid currently. It does the most stuff, feels the realest, seems the most extensible. It just does what you expect. Now in WinForms land the Infragistics grid always had a big API, but it generally was SLOW. With my former employer we had several meetings with the people responsible for WPF at Infragistics and they were very reactive to our performance requirements. They also just came out with their Docking Manager, which was missing and important. Their current suite consists of:
* Grid
* Carousel
* Charts
* Several Editors
* Docking
* Ribbon
There are a number of smaller vendors that have one bit or another. This is OK for open source stuff - but I really do not want 10 different micro component vendors. Ideally, we could have 1 vendor. In the past I have almost always had 2 vendors - Infragistics for everything but the grid, then developer express or syncfusion for the grid.
Conclusion
I think that in conjunction with Prism, there is a farily compelling platform for building non-trivial front office trading applications presently. With the current ’stuff’ that is out there, we should be able to focus on the business facets, and deliver a real application in a timely fashion.
Posted way off topic on Thursday, July 31st, 2008.
In or yard, we have the hugest spider web I have ever seen - by far. Now perhaps I have not spent enough time in the wilds of the wold, but this web starts AT THE PHONE LINE up some… 15 feet at least up. It runs across the stairs up to the outside - this stairway is likely 3-4 feet across. The ‘core’ of the web must be around 3-4 feet across, and the extensions run way up to the phone lines. Anyhow - here is a semi-good shot of the spider web.

It made for an interesting camera exercise. It is really the 1st time I was able to USE the manual focus WELL to achieve a purpose. I was able to lower the F down a bit to get the background blurred out a bit. I was able to use a prime lens (although I DID get some good shots with my Sigma zoom) and creep up to see it out a window. Cameras are cool - but I am SUCH an amateur, trying to use my prosumer Canon XTi. I also noticed that the image stabilizer for my Sigma zoom lens has been OFF… Lessons…
-Chris-
Posted .net, c# on Thursday, July 31st, 2008.
In this segment, we will discuss pushing in singletons that you have already created and adding a simple generic hook point.
Here is our starting test. We want to create something outside the container, then add it as a singleton.

This is trivial, we simple give it a delegate that returns that instance when it is called.

Here our lambda is just going to return that instance. (PS - this is a C# lambda expression, google it.).
But wait, what is wrong here… was it so trivial? Well, how about disposal? Do we want to dispose this thing when our container is disposed? I do not think so… So we can create a policy that does not dispose.
Here is a test:

Let us split our SingletonCreationPolicy into 2 parts - 1 that is the same in both cases - the creation bit, and 2 - the disposal bit we can ‘add on’ in only the case we want it in. This results in:
In our Kontainer class:

the basic singleton creation policy is broken out (back to):

And finally, the Disposable version of the policy for ‘container managed’ singletons:

OK, so that code allows us to push singletons into the Kontainer and allows them to be disposed correctly. (Note the use of protected auto-properties. Less code - I like it).
Hook points
Many 3rd party vendors have used events as hook points for some time. I think grid control products like DevExpress’s XtraGrid have gone far and wide using events as the primary ‘hook points’ to their APIs.
In order to give similar behavior to SpringFramework’s IObjectPostProcessor, we can add an event for a similar effect. Let us start with a test:

We want to hook onto the point when a user is ‘getting’ an object. and ‘do something’ before they actually get it. In this case, we are getting drastic; we are completely replacing what the container has internally. Most usages would be more benign most likely.
We change our Get method, add a GettingObject event and allow callee’s to each have a go at the returning object. So our Kontainer class changes like:

This will happily allow callers to modify the created object and return to the ultimate caller of Get the result. It id the event listener’s perogative to elect to process the created object based either on the object itself or on the label.
So; there you have a nice way to push instances of objects into the container and a cheap hook point to ‘do stuff’ when the user calls to Get.
More soon;
Chris
Posted Family on Thursday, July 31st, 2008.
I love being a dad. I have always been a self proclaimed ‘child monger’; making faces at kids on the subway and such. Kids generally like me and I like them. Kids generally smile at me, respond to me - and mostly they give me an excuse to act like a 3 year old myself.
Having just spent a few weeks with my kids; Gabe (who turned 6 yesterday) and Micah (3.5) and I have been thinking about them a lot. I aspire to be a good daddy. Gabe has told me on a few occasions that I am a ‘good daddy’ so I wanted to write up a quick retrospective of a few weeks with the kids - where am I doing well as a dad, where do I need to work, what do they respond to, etc.
My goals as a dad
- To make my boys know they are loved and valued
- To make my boys respect themselves and others
- To prepare my boys to be flexible to lives that change
- To instill in my boys the passion for whatever they find in their lives to care about
- To instill a love of learning in my boys
- To help prepare them to have healthy, meaningful, rewarding relationships with others
- To help them love and respect each other as brothers, people, and friends
My mechanisms for achieving these goals
- Listen to them, be attentive
- Give them boundaries and let them know where they are
- Talk to them at their level
- Put them in good schools
- Cooperate with my wife, align our expectations, talk about the kids
- Spend time with them one-on-one and with the whole family
- Use an even tone when speaking to them
- Think about parenting
- Read about parenting
Where can I improve?
After a few weeks of being with the kids all day, every day - here is what I think I can improve on:
- Micah is still ‘the baby’ a bit. I need to align myself with Gabe as much as Micah when there are arguments, battles, etc. Little boys fight - it is important to make them both know they are respected and have a voice when they get in a tussle.
- Patience. There is no end to the amount of patience that you need to have as a parent. My wife is more patient than I. I have patience, I could use more.
- Evenness of speech. I simply need to keep an even tone when speaking to the boys, when they are in a fight, when they are being nutty, when they are doing anything - I need to have an even tone. This is a ’subclass of’ patience I think.
Divisiveness/ Togetherness
Whenever you have greater than 1 child, it is important to drive them together. My wife Shannon and I work hard at driving our sons together and are very cognizant of ‘not driving wedges’ between our sons. It is very easy to be divisive or cause dynamics that make kids resent one another. “Why is HE getting all the attention?”, “Why am I always getting in trouble?”, etc. This is one of those areas that I think Shannon and I are doing well, but only because we are ALWAYS really thinking of how to avoid driving wedges between our boys, and focusing on how to coerce them into brotherly love.
Boundaries
I thought that the idea of boundaries and their importance needed a quick comment. I think that the concept of boundaries is one of the most central and critical concepts in parenting. Kids thrive on strucuture and expectations. Kids need to know where the ‘edges’ of their lives are. It is SO important (IMHO) to let kids know where their bounds are in their lives. How do you do this? Well, mostly by telling kids where the boundaries are, offering a penalty for violating (and the hard bit) following through with the penalty WHENEVER the violate the boundary. CONSISTENCY is KING with kids.
I read in some book about parenting once; (psuedo-quote) “Kids do not hear what you say, they hear the actions”. So if you say something like “if you color on the wall; then you will go to bed early”, then the child colors on the wall and they DO NOT go to bed early, then the kids learn they DO NOT REALLY HAVE A BOUNDARY.
A general concept in my life that I try to adhere to is; having a STRICT match between my word and my actions. Child rearing is one area of life where the benefits of this mantra are clear. It is clear that this is an important concept to live by in other relationships, work, etc - but in parenting - it is just in your face. When you violate your word, you kids learn that their boundary is NOT where you SAID, but where you acted. They learn you are malleable, and they try to push you and cajole you to sort out where that actual boundary is.
Anyhow - there is my humble 2 cents on being a good daddy. I am not saying I AM a good daddy, just that I want to be
I will ALWAYS be improving in this, and I will ALWAYS need to improve here.
-Chris-
Posted .net, c# on Thursday, July 31st, 2008.
In this segment, we will make our stuff dispose nicely.
1st - let us look @ our creation policies in a bit more detail:
Here is the simplest possible one - a prototype creation policy. It will simply call the user’s func each time it is called, passing in the calling container for possible child dependency resolution :

The singleton creation policy is a bit more:

This policy uses the user supplied func to create a value 1x, then returns the value for all subsequent calls.
Now - why is this relevant? Well in order to dispose properly, we need to make our container disposable and implement that so - in normal form - here is a test and a little class to help test:


All we want to do is to dispose our container and ensure that any disposable items are disposed - for creation policies that want it as such.
So - we will add a dispose method to our container:

Our container has a field that is a dictionary of string to Definition. The list of values is a list of definition. If our definition has a disposable creation policy, we dispose it. This is using LINQ to select the values in an orderly fasion and a functional-esque call to dispose each in the ToList().ForEach(lambda) call.
We updated our singleton creation policy to look like this:

So - now our singleton creation policy will dispose singletons when the container disposes. If a caller supplies any disposable custom creation policy - it will also dispose as per their mechanism.
Now - I need to make sure that I throw exceptions ‘at the door’ when users provide bad data, or use the container incorrectly. After that, I need to make a pass at thread safety for the container…
Posted .net, c# on Wednesday, July 30th, 2008.
In Part 1 of this short series, we outlined the basic behavior for the simplest possible DI container; what I’ll call Kontainer.
In this segment, we will write some code to make those tests pass. In order to allow us to make those tests pass, I wound up doing the following:
- Keep a list of definitions that are registered with the container
- Abstract the idea of an object definition
- Abstract the idea of a creation policy such that singleton and prototype are instantiations of a creation policy, but we could add other creation policies externally if we want.
This led to the following basic code:
The basic class to hold the definition:

The policy used to govern the creation of the objects in the user provided Function

A slightly modified version of the registry part of the container

and the basic bits of the core container


In order to test sub-property resolution, I also added the following test:

What is that all about? Well, the Function signature takes an argument for the calling container so that the class being built can resolve its own dependencies via the container.
This code was sufficient to make our basic round of tests pass. In addition, it was a little bit of relatively simple code. Furthermore, we can handle other creation policies aside from singleton and prototype. In order to prove that out, I added the following test:

And the other test creation policy:

This is a ’singleton per thread creation policy’. This creation policy allows there to be a singleton created per thread. It uses primative locking style that we may change when we make the ‘whole shebang’ thread safe. Essentially - this will allow us to just prove out that we can supply alternate creation policies.
In the next part - we will sort our the disposal needs…















