Đôi khi, các tài sản IsNew có thể hữu ích cho nhà phát triển giao diện người dùng cũng. Một số hành vi giao diện người dùng có thể khác nhau cho một đối tượng mới hơn là một đối tượng hiện có. Khả năng chỉnh sửa dữ liệu quan trọng chính của đối tượng là một ví dụ này là thường có thể chỉnh sửa chỉ | CHAPTER 3 BUSINESS FRAMEWORK IMPLEMENTATION 115 Sometimes the IsNew property can be useful to the UI developer as well. Some UI behaviors may be different for a new object than an existing object. The ability to edit the object s primary key data is a good example this is often editable only up to the point that the data has been stored in the database. When the object becomes old the primary key is fixed. IsDirty An object is considered to be dirty or changed when the values in the object s fields do not match the values in the database. If the values in the object s fields do match the values in the database then the object is not dirty. It is virtually impossible to always know whether the object s values match those in the database so the implementation shown here acts on a best guess. The implementation relies on the business developer to indicate when an object has been changed and thus has become dirty. The current status of the value is maintained in a field Private mIsDirty As Boolean True The value is then exposed as a property Browsable False _ Public Overridable ReadOnly Property IsDirty As Boolean Get Return mIsDirty End Get End Property Notice that this property is marked as Overridable. This is important because sometimes a business object isn t simply dirty because its data has changed. For instance consider a business object that contains a collection of child objects even if the business object s data hasn t changed it will be dirty if any of its child objects have changed. In this case the business developer will need to override the IsDirty property to provide a more sophisticated implementation. This will be clearly illustrated in Chapter 7 in the implementation of the example business objects. Also notice that the property is adorned with the Browsable attribute from the System. ComponentModel namespace. This attribute tells data binding not to automatically bind this property. Without this attribute data binding would automatically display .