I understand the refactoring (C #)

Source: Internet
Author: User

<span style= "font-family:arial, Helvetica, Sans-serif; Background-color:rgb (255, 255, 255); " > See an Application interface article today, mainly on how to use. NET built-in features to refactor code, feel a bit of meaning, extract the code from it for future reference. But I have the same question as the author of this article, so refactoring the code is really OK? How is loose coupling achieved? Do not know whether there is a master, you can point? Thank you! </span>

The first is the old code, as follows:

<span style= "FONT-SIZE:18PX;" >public class ClassRegistration     {public        void Create ()         {            //Create registration code         }        public void Transfer ()         {            //class Transfer code         } public        decimal total {get; private set;}     }    public class Registrationprocessor     {public        decimal processregistration (classregistration registration)         {             registration. Create ();            Return registration. Total;         }     } </span>

The following refactoring code:

<span style= "FONT-SIZE:18PX;" >public interface iclassregistration     {        void Create ();        Decimal total {get;}     }    public class Classregistration:iclassregistration     {public        void Create ()         {            //Create Registration Code         } public        void Transfer ()         {            //class Transfer code         } public        decimal total {get; Private set; }     } public    class Registrationprocessor     {public        decimal processregistration (iclassregistration Registration)         {             registration. Create ();            Return registration. Total;         }     } </span>


I understand the refactoring (C #)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.