c# – 如何修改代码以使其符合Demeter法则
发布时间:2020-12-15 18:18:22 所属栏目:百科 来源:网络整理
导读:public class BigPerformance { public decimal Value { get; set; }} public class Performance { public BigPerformance BigPerf { get; set; }} public class Category { public Performance Perf { get; set; } } 如果我打电话: Category cat = new Cat
public class BigPerformance { public decimal Value { get; set; } } public class Performance { public BigPerformance BigPerf { get; set; } } public class Category { public Performance Perf { get; set; } } 如果我打电话: Category cat = new Category(); cat.Perf.BigPerf.Value = 1.0; 我认为这打破了Law of Demeter / Principle of Least Knowledge? 解决方法
Martin Fowler最喜欢的一句话:
http://haacked.com/archive/2009/07/14/law-of-demeter-dot-counting.aspx (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 使用正则表达式在HTML5模式属性中验证英国国民保险编号/NIN
- 为什么Swift的fatalError参数是@autoclosure?
- c# – LINQ:通过使它们可转换/可比较,对不同类型的集合使用
- 乱象,印迹 正则学习问答
- ruby-on-rails – 从rails控制台获取“SQLite3 :: CorruptE
- VMWare虚拟机安装创建虚拟机的使用教程
- postgresql – 如何更改Postgres中的日期格式?
- c# – TableLayoutPanel的Autoscroll属性不起作用
- Ajax入门实例----HelloWorld附源码详细注释
- 如何在VB6中设置完整的内部版本号(Major.Minor.Build.Revis