zoukankan      html  css  js  c++  java
  • 方法对比

    //修改前
    namespace
    CleanCSharp.Methods.Dirty { class Utils { public int Process(Customer customer) { if (string.IsNullOrWhiteSpace(customer.FirstName) || string.IsNullOrWhiteSpace(customer.LastName)) { return -1; } else { var service = new CustomerService(); } if (!service.Save(customer)) { return -1; } else { return 1; } } } }
    //修改后
    namespace
    CleanCSharp.Methods.Clean { class Utils { public int Process(Customer customer) { const int customerNotSaved = -1; const int customerSavedSuccessfully = 1; if (!IsValidCustomer(customer)) { return customerNotSaved; } if (!SaveCustomer(customer)) { return customerNotSaved; } return customerSavedSuccessfully; } private bool IsValidCustomer(Customer customer) { if (string.IsNullOrWhiteSpace(customer.FirstName) || string.IsNullOrWhiteSpace(customer.LastName)) { return false; } return true; } private bool SaveCustomer(Customer customer) { var service = new CustomerService(); var successfullySaved = service.Save(customer); return successfullySaved; } } }
  • 相关阅读:
    requireJS搭建
    html启动本地.exe文件
    自定义input[type="checkbox"]的样式
    使用rem单位时css sprites的坑
    visibility API
    css动画
    去除ios端输入框的弹出
    *java类的生命周期
    处理高并发,防止库存超卖
    java注解的使用
  • 原文地址:https://www.cnblogs.com/gaocong/p/6678023.html
Copyright © 2011-2022 走看看