Business Validation Logic Code Smell

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

Consider the following code:

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


        
14条回答
  •  孤街浪徒
    2021-01-17 18:30

    You are validating a change after it has been done? Validation should be done before the busyness property is altered.

    Answering your questing: the solution presented in that code snippet can generate big issues in production, you don't know whether the default value appeared there due to invalid input or just because something else set the value to the default

提交回复
热议问题