#副標=提昇軟體生產力的神兵利器 #大標=應用重構技術活化軟體資產-Refactoring #作者=文/林耀珍 -----box----- #程式1 class Circle { public static double CalcCircumference(double diameter) { return 3.14 * diameter; } public static double CalcArea(double radius) { return 3.14 * radius * radius; } } -----end----- -----box----- #程式2 static void Main(string[] args) { Console.WriteLine("*** Please enter your credentials ***"); // Get user name and password. GetCredentials(); } private static void GetCredentials() { string userName; string passWord; Console.Write("Enter User Name: "); userName = Console.ReadLine(); Console.Write("Enter Password: "); passWord = Console.ReadLine(); } -----end----- -----box----- #程式3 public class MyPoint { public int x; private int y; public int YPos { get {return y;} set {y = value;} } } public class client { public void SetLocation() { MyPoint pt = new MyPoint(); Console.Write("Enter X position: "); pt.x = int.Parse(Console.ReadLine()); Console.Write("Enter Y position: "); pt.YPos = int.Parse(Console.ReadLine()); } public void PrintLocation(MyPoint pt) { // Print new location. Console.WriteLine("[{0}, {1}]", pt.x, pt.YPos); } } -----end----- -----box----- #程式4 interface IShape { void Draw(); Color GetArgb(); Rectangle GetBoundingRect(); } class Shape2D : IShape { public void Draw() { /* Some interesting code. */ } public Rectangle GetBoundingRect() { /* More interesting code. */ } public Color GetArgb() { /* Even more interesting code. */ } } -----end-----