当前位置:网站首页>Interface oriented programming
Interface oriented programming
2022-06-26 05:50:00 【self85】
summary : A program is a programmer's response to The abstraction of real life ,“ abstract ” It is also abstract . Different angles or Particle size , The level of abstraction is also different , features , Properties are different . High cohesion and low coupling program and code design , It should be one of the goals that programmers must have in their self-cultivation .
1. The relationship between interface oriented programming and object-oriented programming
Interface oriented programming is one of the quintessence of object-oriented programming , simply .
2. Nature of interface
On the surface , An interface is a collection of method definitions without a body , It can be inherited by other classes or interfaces .C# And C++ One of the differences is the use of multiple inheritance ,C++ There is no limit to multiple inheritance ,C# A single class can only be inherited by one subclass , stay c# If you want to implement multiple inheritance in , It can only be realized through the interface .
The code form of the interface :
public interface plusUI
{
void Eat();
void Sleep();
Control GetUI();
string Title
{
get;
}
}
The essence :
1) In essence , The interface mainly defines rules( The rules ), For the machine vision industry alone , The basic rules that different image processing operators should meet , The basic rules that different camera brands should meet , The basic rules that different motion control cards should meet . No matter which motion control card , Will satisfy initialization ,io Signal reading , Go back to the origin , Operations such as position reading and writing .
2) Granularity or angle , Dimensions, etc . Here you can borrow liucixin's 《 Trisomy 》 Some ideas in , At the same time , We will continue to live in different parallel tracks , Each choice will determine a different direction in the future . frame , class , Method , From the beginning of the design, it represents a kind of thought or an angle of the writer .
In the eyes of zoologists , Both humans and sharks are mammals , In the eyes of geneticists , Both humans and plants are hereditary . Only in terms of lactation in the eyes of zoologists and heredity in the eyes of geneticists , All because they meet a certain rule or requirement , Finally, it is divided into the same category .
Procedure comes from life , Finally, I have to go back to life , Can we continue to abstract the program we are writing from a better perspective , To refine , This is a route that needs constant efforts .
3) The difference between interface and abstract class :
Abstract classes are used for code reuse , And the motivation for using interfaces is to achieve polymorphism . How to choose , You can make a judgment according to the specific situation .
abstract class ShapesClass
{
abstract public int Area();
}
class Square : ShapesClass
{
int x, y;
// Not providing an Area method results
// in a compile-time error.
public override int Area()
{
return x * y;
}
}
Abstract classes must be implemented by their derived classes .
summary : In the big talk design pattern , classical 23 There are three design patterns : Engineering mode 、 Builder pattern 、 Abstract patterns 、 Archetypal model 、 The singleton pattern 、 Adapter pattern 、 Bridging mode 、 Synthesis mode 、 Decoration mode 、 Facade mode 、 The flyweight pattern 、 The proxy pattern 、 The chain of responsibility model 、 Command mode 、 Interpreter mode 、 Iterative mode 、 Mediator mode 、 Memo mode 、 Observer mode 、 The state pattern 、 The strategy pattern 、 Template pattern 、 Visitor mode . Each of these models has its advantages and disadvantages , No need to follow blindly , More time to learn from a hundred schools , For our use , come on. .
边栏推荐
- 423- binary tree (110. balanced binary tree, 257. all paths of binary tree, 100. same tree, 404. sum of left leaves)
- Ribbon负载均衡服务调用
- Bingc (inheritance)
- Household accounting procedures (First Edition)
- pytorch(网络模型)
- ES6的搭配环境
- Project suspension
- 类和对象的学习
- Factory method pattern, abstract factory pattern
- 解决在win10下cmder无法使用find命令
猜你喜欢
![[arm] add desktop application for buildreoot of rk3568 development board](/img/9a/28015cdea7362261c39ffc7f6e13a9.png)
[arm] add desktop application for buildreoot of rk3568 development board

Consul service registration and discovery

【C语言】深度剖析数据在内存中的存储

适配器模式

Pytorch (network model)

pytorch(环境、tensorboard、transforms、torchvision、dataloader)

Status mode, body can change at will

How to associate wechat applet QR code to realize two code aggregation

kolla-ansible部署openstack yoga版本

Household accounting procedures (First Edition)
随机推荐
Prototype mode, Baa Baa
bingc(继承)
pytorch(网络模型)
Pytorch (network model)
Adapter mode
Learn cache lines and pseudo sharing of JVM slowly
ZigBee learning in simple terms lesson 3 external interruption
Feelings of virtual project failure
[arm] add desktop application for buildreoot of rk3568 development board
Machine learning 07: Interpretation of PCA and its sklearn source code
Gram 矩阵
Mise en file d'attente des messages en utilisant jedis Listening redis stream
Sql语法中循环的使用
Navicat如何将当前连接信息复用另一台电脑
REUSE_ ALV_ GRID_ Display event implementation (data_changed)
Posting - don't get lost in the ocean of Technology
Daily production training report (15)
REUSE_ALV_GRID_DISPLAY 事件实现(DATA_CHANGED)
Use jedis to monitor redis stream to realize message queue function
String类学习