当前位置:网站首页>.NET六大设计原则个人白话理解,有误请大神指正
.NET六大设计原则个人白话理解,有误请大神指正
2022-07-03 14:44:00 【徐子骞】
开闭原则:对扩展开,对修改闭,接口就是很好的例子,可以在源码的基础上扩展,但是不可以更改源代码
单一原则:职能单一,一个类代表一块功能。
里氏转换原则:子类可以当作父类使用,子类需要继承父类的所有方法
依赖倒置原则:依赖于抽象接口,不要依赖于具体实现,尽量使用接口去封装共同点
接口隔离原则:将臃肿庞大的接口拆分成更小的和更具体的接口,不是共用性很高的方法抽离出来再封装成一个接口,
需要使用新接口里的方法再去继承新的这个接口,如果放在一个接口里很多子类并不需要里面的部分方法,就显得这个接口比较臃肿,
不要为了省事去把所有的方法放到同一个接口。
迪米特法则:降低类之间的耦合。每个类尽量减少对其他类的依赖,使得功能模块功能尽可能独立。比如需要通过类1的展示方法展示类1和类2的数据
不要在类1中直接写展示类2的逻辑代码 ,而是在类2中写完展示类2的方法,然后以参数形式传给类1的展示方法一个类2的对象,
然后调用类2的展示方法
边栏推荐
- How to color ordinary landscape photos, PS tutorial
- 556. 下一个更大元素 III : 简单构造模拟题
- C language fcntl function
- 动态获取权限
- Zzuli:1057 prime number determination
- Dllexport and dllimport
- 【7.3】146. LRU缓存机制
- Zzuli:1047 logarithmic table
- US stock listing of polar: how can the delivery of 55000 units support the valuation of more than 20billion US dollars
- Zzuli:1043 max
猜你喜欢
![[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?](/img/f6/fe61c84f289f0e74a45946dac687a6.jpg)
[qingniaochangping campus of Peking University] in the Internet industry, which positions are more popular as they get older?

Dllexport and dllimport

Happy capital new dual currency fund nearly 4billion yuan completed its first account closing

retrofit

Detailed explanation of four modes of distributed transaction (Seata)

Implement Gobang with C language

远程服务器后台挂起 nohup

Use of constraintlayout

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

Sword finger offer 28 Symmetric binary tree
随机推荐
Frequently asked questions: PHP LDAP_ add(): Add: Undefined attribute type in
Zzuli:1058 solving inequalities
Pyqt interface production (login + jump page)
Time conversion ()
天谋科技 Timecho 完成近亿元人民币天使轮融资,打造工业物联网原生时序数据库
Creation of data table of Doris' learning notes
Zzuli:1055 rabbit reproduction
Showmebug entered Tencent conference, opening the era of professional technical interview
Zzuli:1042 sum of sequence 3
Zzuli:1046 product of odd numbers
Niuke: crossing the river
Etcd cluster permission management and account password usage
Code writing and playing method of tonybot humanoid robot at fixed distance
To improve efficiency or increase costs, how should developers understand pair programming?
7-3 count the number of words in a line of text
Container of symfony
C language dup2 function
Stop asking yourself if you are suitable for software testing
Why is this error reported when modifying records in the database
NOI OPENJUDGE 1.3(06)