Business Validation Logic Code Smell

后端 未结 14 1118
醉酒成梦
醉酒成梦 2021-01-17 17:54

Consider the following code:

partial class OurBusinessObject {
    partial void OnOurPropertyChanged() {
        if(ValidateOurProperty(this.OurProperty) ==          


        
14条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-17 18:12

    Distaste for the term 'code smell' aside, you might be right - depending on where it's coming from, silently changing the value is probably not a good thing. It would be better to ensure your value is valid instead of just reverting to the default.

提交回复
热议问题