当前位置:网站首页>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. .
边栏推荐
- When was the autowiredannotationbeanpostprocessor instantiated?
- Could not get unknown property ‘*‘ for SigningConfig container of type org. gradle. api. internal
- kolla-ansible部署openstack yoga版本
- Cyclic displacement
- Prototype mode, Baa Baa
- Use jedis to monitor redis stream to realize message queue function
- Security problems in wireless networks and modern solutions
- Daily production training report (17)
- ES6的搭配环境
- About abstact and virtual
猜你喜欢

Redis discovery bloom filter

Gram 矩阵

LeetCode_ Binary search tree_ Simple_ 108. convert an ordered array to a binary search tree

【 langage c】 stockage des données d'analyse approfondie en mémoire

Gram matrix

Ribbon load balancing service call

Adapter mode

Could not get unknown property ‘*‘ for SigningConfig container of type org.gradle.api.internal

Leetcode513. Find the value in the lower left corner of the tree

操作符的优先级、结合性、是否控制求值顺序【详解】
随机推荐
The news of thunderbolt
生命原来如此脆弱
ES6的搭配环境
MySQL数据库-01数据库概述
LeetCode_ Binary search tree_ Simple_ 108. convert an ordered array to a binary search tree
BOM文档
Consul service registration and discovery
机器学习 05:非线性支持向量机
Explore small program audio and video calls and interactive live broadcast from New Oriental live broadcast
【C語言】深度剖析數據在內存中的存儲
Kolla ansible deploy openstack Yoga version
Internship May 29, 2019
421- binary tree (226. reversed binary tree, 101. symmetric binary tree, 104. maximum depth of binary tree, 222. number of nodes of complete binary tree)
冒泡排序(Bubble Sort)
Could not get unknown property ‘*‘ for SigningConfig container of type org. gradle. api. internal
The use of loops in SQL syntax
String类学习
Gram 矩阵
[MySQL] MySQL million level data paging query method and its optimization
Navicat如何将当前连接信息复用另一台电脑