-Corrado
Nice post.
Cheers,
k-dawg
Laurent
-----Original Message-----
From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com]
On Behalf Of Kent Boogaart
Sent: Thursday, March 26, 2009 8:21 PM
To: WPF Disciples
Subject: [WPF Disciples] View Models: POCOs versus DependencyObjects
Hi all,
Best,
Kent
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.238 / Virus Database: 270.11.29/2024 - Release Date: 03/26/09
07:12:00
Here's more on T4: http://www.hanselman.com/blog/T4TextTemplateTransformationToolkitCodeGenerationBestKeptVisualStudioSecret.aspx
-----Original Message-----
From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com] On Behalf Of Colin Eberhardt
Sent: Thursday, March 26, 2009 10:54 PM
To: WPF Disciples
As for coercion, DPs are great for that. I find coercion a bit hard to grasp
when you start with it (I know that many of my ex-colleagues at Siemens had
a really hard time understanding how it works), but the fact that the
original value is preserved and restored automatically is pretty cool. The
marshalling is great too, though one might argue that it is a bit too "black
magic" and that marshalling the values "by hand" brings more clarity to the
code.
Cheers,
Laurent
-----Original Message-----
From: wpf-di...@googlegroups.com [mailto:wpf-di...@googlegroups.com]
On Behalf Of ken...@internode.on.net
Sent: Friday, March 27, 2009 10:34 AM
To: WPF Disciples
Thanks again,
Kent
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.0.238 / Virus Database: 270.11.30/2025 - Release Date: 03/26/09
20:05:00
Wow! There's no way I can catch up on all the disciples mail in the last few days... so I'm just weighing in on this one and then marking the rest of them as read.
Great post, as usual, Kent. I'm pretty sure I've said this before, but I fully concur... unless you have a very solid reason to be a DO, don't. POCOs are the way to go for 99% of all VM classes (and usually the other 1% too).
That is not to minimize the power of DPs in any way! (Note that DOs only exist to support DPs and the property engine.) DPs were simply designed with the framework in mind (hence their inclusion in the framework assemblies). If you're not in the element tree and/or not a visual, you don't receive a lot of the major benefits of DPs. In that case, they are just overhead.
I often refer to the property engine in WPF as the "coolness engine". It enables all the cool stuff like binding, animation, triggers, default values, property invalidation, property inheritance, attached properties, etc. For controls, user controls, freezables, and other view-specific objects, I almost always use DPs so that I can leverage this coolness.
I developed my WPF snippets for DPs, routed events, and commands (I think most have seen them already, but if not, they're available here) specifically to address Colin's point. They allow me to minimize syntax errors and other trivialities and they bring uniformity to my code. If you don't have your own snippets, feel free to try mine. I'm not trying to self-promote or anything (because unfortunately, I haven't found a way to monetize these... "if only I had a nickel for every..." :-p). It really is about efficiency and error reduction.
I'm sure T4 templates are great too, but I like having DP declarations inline so I can quickly see them when necessary. Since my DPs are wrapped in #region..#endregion blocks, they can be collapsed most of the time but still accessible for tweaking when necessary (without worrying about what the next codegen pass will do). Still, if anyone builds a set of T4 WPF templates, I'd be willing to give them a try.
Wrt auto-marshalling property changes, I'm not a huge fan but I understand why they did it. Solving an issue under the covers (which people tend to perceive as black magic cuz they don't take the time to look at what is really happening) is not always the best approach... especially if that voodoo only works in certain circumstances (e.g., supports background changes to bound properties but not bound collections).
Lots else to comment on... but not enough time. I'll just side with all the smart people. You know who you are. ;-)
Dr. WPF - Online Office at http://www.drwpf.com/blog/