Methods

In this section we'll review:

  • What are methods - a better way to organize code
  • We'll extract the order validate logic, to the ValidateOrderDateMethod
protected override void OnSavingRow()
{
-   if (u.Year( Orders.OrderDate) < 1990 || Orders.OrderDate.Year>2020)
-   {
-       Message.ShowError("Invalid Year");
-   }
    ValidateOrderDate();
}

void ValidateOrderDate()
{
    if (u.Year(Orders.OrderDate) < 1990 || Orders.OrderDate.Year > 2020)
    {
        Message.ShowError("Invalid Year");
    }
} 
  • Demo how to use the "ExtractMethod" automatic refactoring from Visual Studio


Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com