工厂:顾名思义即为可以以加工的形式生成类的对象。需要工厂类、加工方法、产品的模型。
工厂的作用在于解决耦合。
耦合的不良影响:通俗的讲
模块一的实现依赖于模块二,更改模块二后,模块一也得更改,那么二者就有耦合。
大型的程序必然不能出现这种情况,以本人相当匮乏的经验来看,耦合的类设计降低了代码的维护性。
//接口:接口是一种契约
public interface IShowMsg { void showMsg(); }
public class SomeProperty : IShowMsg { public string Size { get; set; } public string Type { get; set; } public void showMsg() { Console.WriteLine("会变的方法");