Sharing our knowledge

Michael Sync

Visual Studio 2010 RC Released

February 9th, 2010 by Michael Sync

If you have MSDN Subscription, you can download VS 2010 RC now.

Notes

1. Important to note is that VS RC will not support Silverlight 4 Beta so if you are working on Silverlight 4 development then you should keep VS 2010 Beta only.

2. I’m not able to install it in my office machine. The installation dialog will be disappeared without any message or error after clicking “Install” button. I got this message “[02/09/10,15:45:44] vs70uimgr: [2] UI Thread exiting with error code: -2147172341.” in dd_error_vs_vstscore_100.txt log file. I don’t have any solution for that now. I will update you guys once I found something on this issue.

What do you want in Prism v4.0?

February 8th, 2010 by Michael Sync

Are you a hardcore fan of Prism?

Blaine Wastell, Program Manager of Microsoft Patterns & Practices Client Program, is asking the community to give the feedbacks for Prism 4.0.  You can go to this link and suggest what you wanna see in v4.0..

One interesting thing is that there are quite a few people who like to use both MEF and Prism in their projects. That’s good thing.. I’m also looking for a MEF + Prism guideline.. Glenn, Hope you heard me. :) I’m still waiting for MEF port of Prism Quick Start as well. :)

Moonlight 3.0 Preview 1

February 8th, 2010 by Michael Sync

It might be a bit late but still, I want to let you guys know that Moonlight 3.0 Preview 1 has been released. You can download it from the link below.

Download : Moonlight 3.0 Alpha

But be careful after installing this plugin. You should only use this plugin on trusted sites (e.g. internal or well-known web sites) on non-production computers.

You can read more information in this post http://tirania.org/blog/archive/2010/Feb-03.html

Rules of MVVM??

February 3rd, 2010 by Michael Sync

UPDATE #2:

There is very active discussion about MVVM in WPF Disciples User Group. If you are interested then please read all posts and get invoked in discussion. Here is the link. Update: Here is another one.

As I had a MVVM session at my office, I was re-reading a few articles about MVVM. We have very interesting discussion about MVVM in WPF Disciples User Group as well. You can read that post from here.

Someone in Silverlight Forum (link) posted that ~

“There are currently three main areas of criticism regarding the MVVM pattern. The first is that MVVM currently lacks standardization from Microsoft both in implementation and in toolsets. For example, the community has some lack of clarity about where and whether to implement View logic in the View layer or the ViewModel. Given that the MVVM pattern is still relatively new, and that new tool-sets, walkthroughs, or patterns, such as Onyx, Prism, the Microsoft WPF Toolkit, Crack.net, Caliburn and MVVM Light Toolkit are being released, this problem may be solved over time. Microsoft has announced in discussion boards that the MVVM template pattern will be released in Visual Studio 2010.

The second comes from MVVM creator John Gossman himself, who points out that the overhead in implementing MVVM is “overkill” for simple UI operations. He also states that for larger applications, generalizing the View layer becomes more difficult. Moreover, he illustrates that data binding, if not managed well, can result in a considerable excess of metadata in an application. Given these limitations, MVVM may have a practical minimum and maximum size for the type of application it can support, suggesting it may not perform well with large enterprise applications.

The third is that the exercise in creating large numbers of data bindings to the ViewModel results in duplicate code and maintenance problems. Additionally, because of the nature of the semantics of data bindings, critics suggest that the ViewModel does not directly describe the View.”

So, I was thinking it would be great if John and our WPF/Silverlight community can define some simple and obvious rules for MVVM pattern.I understand that there are a lot of way to implement MVVM but at least, there are some obvious rules that everyone can follow so everyone has same understanding about that pattern.

Here are some of my thoughts about MVVM.

Why MVVM?

  • Testabiltiy ( ViewModel is easier to unit test than code-behind or event driven code)
  • Clear seperation between UX designer and developer
  • Increases the “Blendability” of your view
  • Model never needs to be changed to support changes to the view
  • ViewModel rarely needs to be changed to support changes to the view
  • No duplicated code to update views

Do and Don’t in View

  • shouldn’t contain any logic that you want to test : As Glenn said that MVVM is not code counting exercise, we can write code in code-behind. But you should never write any logic that you want to test. For example: If user select a country then you want to display the list of states or city in your view. This is the business requirement so you should have unit test to test this logic. So, you shouldn’t write it in code-behind.
  • can be a control or Data Template
  • Keep the view as simple as possible. : We can still use Data Trigger or Value Converter or Visual State or Blend Behivor in XAML with care.
  • use attached property if something is not bindable :

Do and Don’t in ViewModel

  • Connector between View and Model
  • Keep View State, Value Conversion : (You can create the data structure that you want to display in ViewModel instead of using ValueConverter. For example: You need to show the Name instead of First Name and Last name. Your Model can have First Name and Last Name but You can create Name property in ViewModel. )
  • No strong or weak (via Interface) reference of View
  • Make VM as testable as possible (e.g. no call to Singleton class)
  • No Control related Stuff in VM ( Because if you are changing the view then you will have to change VM as well. )

Model

  • can be Data Model, DTO, POCO, auto-generated proxy of domain class and UI Model based on how you want to have the separation between Domain Service and Presentation Layer
  • No reference to ViewModel

What do you think about that? Feel free to let me know if you have any comment or suggestion..  Thanks.

UPDATE:

This is the open post. I will keep on updating it based on the feedback. I’m trying to discuss about those rules in WPF Disciples User Group. I understand that there are a few people who don’t want to get invoked in this kinda discussion because it can turn into a fight. Anyway, I will try to discuss with people nicely. :) I will get the feedback several groups like SL MVP/Insiders group, Stackoverflow, Codeproject and etc.

My WPF MVVM Session at Consistel

February 3rd, 2010 by Michael Sync

I gave MVVM presentation at Consistel today. It was 2 hours long section and we had a lot of great discussions about MVVM pattern. Due to the problems with laptop and remote desktop, I was not able to show the demo in my session. I’m going to have another WPF session with my colleague “Nyi Nyi” tomorrow. Thanks to everyone who is attending my session. Especial special thank to Arpad and Maneesh for arranging this session and supporting me in my session.

Topics

  • Understanding MVVM
  • Motivation and benefits
  • Implementing the pattern
  • Dependency Injection and IoC
  • Unit Test and Mock
  • Supporting libraries and frameworks

Download ~

Demo ~

Here is the list of things that I used in

You can also download the demo here.  MVVMDemo.zip (5.34 MB) Note: Unity and Moq dlls are already included in zip file.

As I want to show the team how to write the test, I didn’t write anything for both View and Service. The test below are the BDD (Behavior-Driven Development) Style.  There are a few BDD framework for .NET but I don’t really like any of them so I’m using VS Unit Test with BDD-style test. The main difference between TDD and BDD is that BDD focus more on specification and readability. (Some people said that BDD is TDD done right. :) )

Feel free to let me know if you have any question or comment. Thanks.

3 new websites for Silverlight Community

January 30th, 2010 by Michael Sync

Hi Everyone, I hope you all are doing well. I like to introduce new 3 websites that I created since last year.

Silverlight MVP and Insiders Web Site

URL: http://wsinsiders.com

This site is where you can find all informations about Silverlight MVP and WPF/Silverlight Insiders. You can also read the series of Silverlight tutorials written by Silverlight MVPs and Insiders. Silverlight Tutorials for Beginners is the first series of our tutorials. We are planning to write more tutorials in that site as well. Here is the list of tutorials that we have in our mind.

  • Tutorials for Silverlight Business Application Development – we can write about localization, validation, services. performances, pattern, Prism or MEF
  • Tutorials for Silverlight Control Development : We can read the source code of Silverlight Toolkit and can write something like Silverlight Toolkit Internal.
  • Tutorials for Silverlight Media or Game Development : Pixel Shader or 3D or Effect or Best Practice for video/audio streaming
  • Tutorials for “Designers/Expression Blend : I think it’s very important. the resources for designer are very less. there are a lot of designers who like to learn about how to design theme or XAML or Blend.. We can write about how to create a Mac-style theme, Glassy theme or etc.  Note: The old name of that tutorial was “Tutorials for Silverlight/XAML Designer”. Based on Michael Washington’s suggested, it has been re-named.
  • Tips/Trick : How to add the grouping feature, Excel-like Filering in Datagrid,
  • Tutorials for Silverlight Integration : This is where we can put ‘Silverlight and SharePoint” and “Silverlight and DotNetNuke” Note: Suggested by Michael Washington.

Please let me know if you like to contribute your tutorials as well.

Let me tell you a bit about the history of this site. I created this website on Jan 20, 2009. By the time when I was creating this site, there was no MVP award for Silverlight so there was no Silverlight MVP at that time. We had only WPF/Silverlight Insiders and we wanted to create one website similiar to ASPInsiders website. I wanted to register SilverlightInsiders.com but that domain was not available so I registered http://wsinsiders.com/ and started collecting all information about Insiders. Collecting Insiders information is kinda hard because I don’t have any latest list of Insiders and there are a few people who don’t have any blog or BIO or photo. Once I have collected the information about MVP and Insiders, I started planning to write the tutorials with a few MVPs. Braulio Diez Botella,  Alexander Golesh,  Emil Stoychev,  Einar Ingebrigtsen and Daron Yöndem.  Jocelyn Mae Villaraza from Microsoft Singapore helped us to review those tutorials. It took me around 1 years to finish this website. Anyway, I’m glad that we finally make it.

Please feel free to let me know if you have any suggestion or comment for that site.

Open Source Software in Silverlight

URL : http://silverlight-source.net/

I created this website based on one of my favorite website called Open Source Software in C#. There are a lot of open source Silverlight projects. The problem is that all projects are not mature or active so I was thinking it would be so useful for Silverlight community if we have a website that have all information about  active, mature and awesome Silverlight open source projects. You can also suggest me the project via this page http://silverlight-source.net/suggest-project/.

Singapore Silverlight User Group

URL : http://sgsug.org/

This is the official website for Singapore Silverlight User Group. Me and Justin Lee are running this group. We are gonna have our first meetup on 10th Feb, 2010. If you are in Singapore, please come to our meetup. It’s just a casual gathering. You can wear anything you want to come there.

« Previous Entries