1/16/2008

 

Pain Points of Using XAML or WPF

Pain Point 1: XAML always create the controls by its default constructor

This means, you need to have a default constructor for you control, and the constructor will always be used by XAML. So, you can not use constructor dependency injection to pass things like services, gateways to your control. Also, you will not have chance to pass data in constructor, although the data might be must-have for the specific type of control

Paint Point 2: can not control XAML to create or not to create some part of GUI

Sometimes, the GUI is not static. It could be dynamic because the GUI would be different for the data it is presenting, such as for a meeting in the past it should show a adding note button, for a meeting in the future it should not. And more often, the security control requires the GUI to be different according to the role.

Paint Point 3: XAML is using XML, which contains too many visual noise

compared to things like YAML, XML is definitely not very friendly to our eyes. The things worse than XML I can come up is the braces of Lisp. Also, XML makes it harder to edit manually

Paint Point 4: Layouting in Grid

Using grid layout currently requires you to specify the row and column for all the children of a grid. It is very error-prone when the grid becomes large. But grid is a must-have for any non-trivial GUI, and there is not replacement for it yet.

Paint Point 5: Things not checked in compiling time

There are lots of things not checked by the compiler in XAML. Things like binding, resource looking up for example. And it is harder to cross reference between xaml and code.

Paint Point 6: More files

one file for xaml one file for cs. It requires more steps to create a new user control and is confusing to new comers.

Paint Point 7: Separating concerns

the default way events get handled is in the partial class of the XAML. It is not a good way of separating concerns and not good oo design. the windows and user controls usually doing too much in rich client application. It is not the fault of XAML in general, but it is not promoting a good model either by its weird way of hooking up event in xaml.

Paint Point 8: Hard to test

It is hard to test in many ways. First, not easy to inject dependency means you can not mock those expensive things like network connection. Second, creating a real window is taking more than ten seconds. Third, many things are in a static singleton model like resource looking up and the single instance application object.

Paint Point 9: Control lazy created with uncertain lifecycle

controls of list item in a list view were lazy created. We can not get those controls easily, and we even can not be sure they are created or not. only those who are visible will be created.

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]