Friday, February 19, 2010

Silverlight – my dumb blonde partner.

Reading a book on Silverlight 3.0 right now and can’t stop from getting excited from time to time – how is it possible that with all the validation guidance from WPF and ASP.NET MVC somebody in MS just returned back 10 years and provided a pattern of validation via exceptions for Silverlight??!!image

Can the justification possibly be that it was too much of bytes to incorporate IDataError pattern from WPF? I’m afraid it is a “blond” factor and not amount of bytes behind that design.

Look at this code from Brad Adams’s blog with title “Design Guidelines, Managed code and the .NET Framework” (http://blogs.msdn.com/brada/archive/2009/07/24/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-part-11-the-client-only-world.aspx):

        [DataMember()]
        [Key()]
        [ReadOnly(true)]
        public int EmployeeID
        {
            get
            {
                return this._employeeID;
            }
            set
            {
                if ((this._employeeID != value))
                {
                    ValidationContext context = new ValidationContext(this, null, null);
                    context.MemberName = "EmployeeID";
                    Validator.ValidateProperty(value, context);
                    this._employeeID = value;
                    this.OnPropertyChanged("EmployeeID");
                }
            }
        }

And Validator.ValidateProperty(value, context) throws an exception so SL controls can apply templates for invalid data.

Both the code above and design concept are more than ugly (from many viewpoints) and are a huge design step back compared to asp.net mvc and wpf. Shame!

Nothing that can’t be worked around / substituted, but the payload of dead bytes from the “dumb blonde” designer will still be there.

BlondeFalsies

No comments: