当前位置:网站首页>.NET六大设计原则个人白话理解,有误请大神指正
.NET六大设计原则个人白话理解,有误请大神指正
2022-07-03 14:44:00 【徐子骞】
开闭原则:对扩展开,对修改闭,接口就是很好的例子,可以在源码的基础上扩展,但是不可以更改源代码
单一原则:职能单一,一个类代表一块功能。
里氏转换原则:子类可以当作父类使用,子类需要继承父类的所有方法
依赖倒置原则:依赖于抽象接口,不要依赖于具体实现,尽量使用接口去封装共同点
接口隔离原则:将臃肿庞大的接口拆分成更小的和更具体的接口,不是共用性很高的方法抽离出来再封装成一个接口,
需要使用新接口里的方法再去继承新的这个接口,如果放在一个接口里很多子类并不需要里面的部分方法,就显得这个接口比较臃肿,
不要为了省事去把所有的方法放到同一个接口。
迪米特法则:降低类之间的耦合。每个类尽量减少对其他类的依赖,使得功能模块功能尽可能独立。比如需要通过类1的展示方法展示类1和类2的数据
不要在类1中直接写展示类2的逻辑代码 ,而是在类2中写完展示类2的方法,然后以参数形式传给类1的展示方法一个类2的对象,
然后调用类2的展示方法
边栏推荐
- Niuke bm83 string deformation (case conversion, string inversion, string replacement)
- 7-1 positive integer a+b (15 points)
- [ue4] geometry drawing pipeline
- Protobuf and grpc
- My QT learning path -- how qdatetimeedit is empty
- 7-3 count the number of words in a line of text
- retrofit
- 7-10 stack of hats (25 points) (C language solution)
- J-luggage lock of ICPC Shenyang station in 2021 regional games (simple code)
- 【7.3】146. LRU caching mechanism
猜你喜欢

基因家族特征分析 - 染色体定位分析

分布式事务(Seata) 四大模式详解

远程服务器后台挂起 nohup

How to query the baby category of tmall on Taobao

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

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

Paper sharing: generating playful palettes from images

Bibit pharmaceutical rushed to the scientific innovation board: annual revenue of 970000, loss of 137million, proposed to raise 2billion

Qt—绘制其他东西

ConstraintLayout 的使用
随机推荐
Tonybot humanoid robot infrared remote control play 0630
分布式事务(Seata) 四大模式详解
Address book sorting
洛谷P5194 [USACO05DEC]Scales S 题解
Luogu p3065 [usaco12dec]first! G problem solution
556. The next larger element III
亚马逊、速卖通、Lazada、Shopee、eBay、wish、沃尔玛、阿里国际、美客多等跨境电商平台,测评自养号该如何利用产品上新期抓住流量?
Zhejiang University Edition "C language programming (4th Edition)" topic set reference ideas set
tonybot 人形机器人 查看端口并对应端口 0701
牛客 BM83 字符串變形(大小寫轉換,字符串反轉,字符串替換)
Zzuli:1043 max
Write a 2-minute countdown.
Fundamentals of PHP deserialization
7-3 count the number of words in a line of text
How to color ordinary landscape photos, PS tutorial
Zzuli: sum of 1051 square roots
556. 下一个更大元素 III : 简单构造模拟题
556. The next larger element III: simple construction simulation questions
NOI OPENJUDGE 1.6(09)
dllexport和dllimport