当前位置:网站首页>.NET六大设计原则个人白话理解,有误请大神指正
.NET六大设计原则个人白话理解,有误请大神指正
2022-07-03 14:44:00 【徐子骞】
开闭原则:对扩展开,对修改闭,接口就是很好的例子,可以在源码的基础上扩展,但是不可以更改源代码
单一原则:职能单一,一个类代表一块功能。
里氏转换原则:子类可以当作父类使用,子类需要继承父类的所有方法
依赖倒置原则:依赖于抽象接口,不要依赖于具体实现,尽量使用接口去封装共同点
接口隔离原则:将臃肿庞大的接口拆分成更小的和更具体的接口,不是共用性很高的方法抽离出来再封装成一个接口,
需要使用新接口里的方法再去继承新的这个接口,如果放在一个接口里很多子类并不需要里面的部分方法,就显得这个接口比较臃肿,
不要为了省事去把所有的方法放到同一个接口。
迪米特法则:降低类之间的耦合。每个类尽量减少对其他类的依赖,使得功能模块功能尽可能独立。比如需要通过类1的展示方法展示类1和类2的数据
不要在类1中直接写展示类2的逻辑代码 ,而是在类2中写完展示类2的方法,然后以参数形式传给类1的展示方法一个类2的对象,
然后调用类2的展示方法
边栏推荐
- 分布式事务(Seata) 四大模式详解
- Find books ()
- Tonybot Humanoïde Robot Infrared Remote play 0630
- C language to realize mine sweeping
- Pyqt interface production (login + jump page)
- NOI OPENJUDGE 1.4(15)
- [graphics] efficient target deformation animation based on OpenGL es 3.0
- NOI OPENJUDGE 1.3(06)
- 2021-10-16 initial programming
- My QT learning path -- how qdatetimeedit is empty
猜你喜欢

Puzzle (016.3) is inextricably linked

My QT learning path -- how qdatetimeedit is empty

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

PS tips - draw green earth with a brush

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

Use of constraintlayout

Bucket sorting in C language

天谋科技 Timecho 完成近亿元人民币天使轮融资,打造工业物联网原生时序数据库

The latest M1 dedicated Au update Adobe audit CC 2021 Chinese direct installation version has solved the problems of M1 installation without flash back!

How to query the baby category of tmall on Taobao
随机推荐
Use of form text box (I) select text
7-3 count the number of words in a line of text
洛谷P5536 【XR-3】核心城市 题解
Yolov5进阶之九 目标追踪实例1
C language to implement a password manager (under update)
光猫超级账号密码、宽带账号密码 获取
NPM install is stuck with various strange errors of node NPY
tonybot 人形机器人 红外遥控玩法 0630
Piwigo 2.7.1 sqli learning
远程服务器后台挂起 nohup
Puzzle (016.3) is inextricably linked
Bucket sorting in C language
Puzzle (016.4) domino effect
puzzle(016.3)千丝万缕
Zzuli:1043 max
Analysis of gene family characteristics - chromosome location analysis
Detailed explanation of four modes of distributed transaction (Seata)
retrofit
Tonybot humanoid robot infrared remote control play 0630
Awvs batch operation script