<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 #)