当前位置:网站首页>.NET六大设计原则个人白话理解,有误请大神指正
.NET六大设计原则个人白话理解,有误请大神指正
2022-07-03 14:44:00 【徐子骞】
开闭原则:对扩展开,对修改闭,接口就是很好的例子,可以在源码的基础上扩展,但是不可以更改源代码
单一原则:职能单一,一个类代表一块功能。
里氏转换原则:子类可以当作父类使用,子类需要继承父类的所有方法
依赖倒置原则:依赖于抽象接口,不要依赖于具体实现,尽量使用接口去封装共同点
接口隔离原则:将臃肿庞大的接口拆分成更小的和更具体的接口,不是共用性很高的方法抽离出来再封装成一个接口,
需要使用新接口里的方法再去继承新的这个接口,如果放在一个接口里很多子类并不需要里面的部分方法,就显得这个接口比较臃肿,
不要为了省事去把所有的方法放到同一个接口。
迪米特法则:降低类之间的耦合。每个类尽量减少对其他类的依赖,使得功能模块功能尽可能独立。比如需要通过类1的展示方法展示类1和类2的数据
不要在类1中直接写展示类2的逻辑代码 ,而是在类2中写完展示类2的方法,然后以参数形式传给类1的展示方法一个类2的对象,
然后调用类2的展示方法
边栏推荐
猜你喜欢

表单文本框的使用(一) 选择文本

Zhonggan micro sprint technology innovation board: annual revenue of 240million, net loss of 17.82 million, proposed to raise 600million

Tailing rushes to the scientific and Technological Innovation Board: it plans to raise 1.3 billion, and Xiaomi Changjiang is the shareholder

MySQL multi table query subquery

On MEM series functions of C language

tonybot 人形机器人 查看端口并对应端口 0701

retrofit

NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon

Implement Gobang with C language

The picture quality has been improved! LR enhancement details_ Lightroom turns on AI photo detail enhancement: picture clarity increases by 30%
随机推荐
tonybot 人形机器人 首次开机 0630
Bucket sorting in C language
7-3 rental (20 points)
Ultra simple mobile map development
Table of mathematical constants by q779
Zzuli:1054 monkeys eat peaches
Tonybot Humanoïde Robot Infrared Remote play 0630
FPGA blocking assignment and non blocking assignment
556. The next larger element III
Tailing rushes to the scientific and Technological Innovation Board: it plans to raise 1.3 billion, and Xiaomi Changjiang is the shareholder
分布式事务(Seata) 四大模式详解
Stop asking yourself if you are suitable for software testing
【7.3】146. LRU缓存机制
[opengl] bone animation blending effect
dllexport和dllimport
DDK for XP
[opengl] face pinching system
提高效率 Or 增加成本,开发人员应如何理解结对编程?
The latest M1 dedicated Au update Adobe audit CC 2021 Chinese direct installation version has solved the problems of M1 installation without flash back!
PS tips - draw green earth with a brush