当前位置:网站首页>Learn the specific technical learning experience of designing reusable software from the three levels of class, API and framework
Learn the specific technical learning experience of designing reusable software from the three levels of class, API and framework
2022-06-23 00:44:00 【Xiao Wang is not tired】
One . Software reuse
Software reuse refers to the development of new software systems , Reuse existing software or software modules , The software can be pre-existing software , It can also be a dedicated reusable component . The software reusability affects the production efficiency 、 Software quality and system maintainability .
Mainly introduces several aspects of reuse :
( One ) Software reuse based on program library
Program library is the most basic part of software reuse 、 The most common form . Libraries are often used 、 A collection of verified normalized programs or subroutines . The program in the library is a frequently used function . Libraries are usually compiled binary executables or virtual machine executables , Put them in the catalog , Set the environment variable , After being introduced into the program, it can be like an ordinary function 、 object 、 Class, etc . Procedural language ( Such as C) The library is mainly a variety of functions . The program libraries of object-oriented languages are collectively called class libraries , The essence is a comprehensive object-oriented reusable type collection , Including the interface 、 Abstract classes and concrete classes . Libraries can be built into the language system , It can also be independently developed by the third engine . Different language packaging and bowing | The form of using the library is slightly different . The keywords that reference the library in the program are include、using、 import、 with etc. . Except that libraries in the same language can be referenced , Current programming languages also allow bow | Into libraries in other languages , The most common is C The library of languages . Use the third-party development program library and use the system program library , There is no difference in essence . Usually understanding API Design 、 Look up API send F The way 、 Learn the demonstration code and practice constantly .
( Two ) Framework based software reuse
Framework method is component technology 、 The combination of software architecture and application software development . Frameworks usually appear in the form of component libraries , But the component library is only an important part of the framework , The large-scale reuse of component libraries requires a framework . A framework is a partial code reuse , Part is design reuse , Sometimes analysis can be reused . Frameworks can be represented in code , It can also be directly executed or reused .
The development of framework starts from code 、 Design and analysis reuse the software at three levels :
Code reuse . It becomes very easy to build applications from existing component libraries , Because the components adopt the interfaces uniformly defined by the framework , Thus, the communication between components is simple .
Reuse design . It provides reusable Abstract algorithms and high-level design , And can decompose the large system into smaller components , And can describe the internal interface between components .
Reuse analysis . If all personnel analyze the affairs according to the idea of the framework , Then it can be divided into the same components , Adopt a similar solution , So that the analysts who adopt the same framework can communicate with each other .
( 3、 ... and ) be based on API Software reuse
A typical example is to implement or call a function procedure :
(1) When implementing a function , Parameter types of the functions have never been seen before , But we can learn this new through intelligent perception API And correctly get the information we expect from the parameters .
(2) When you call a function , We need to pass in parameter types we haven't seen before , Prompt through intelligent perception , We can know how to construct or get these types and pass them in correctly .
(3) After calling a function, we get the return value , We haven't seen this type before , But through intelligent perception , We can learn this new type , And know how to use this return value correctly .
Two . class ,API, frame
( One ) Design reusable classes
stay OOP Design reusable classes in , Encapsulation and information hiding , Inheritance and rewriting , polymorphism , Subtypes and overloads , Generic Programming , Behavior subtypes and Liskov The principle of substitution (LSP), Combination and delegation .
( Two )API
API It's the application programming interface , Interface to a library or framework . well API It should have the following properties :
Comprehensibility : For an excellent API Come on , The concepts involved should be within the user's understanding , Even if there is a new concept, it should be progressive . Uniformity : Maintain compatibility down . visibility : It is best to provide an entry for users API The starting point of the . Simple tasks should have simple solutions : therefore API It should be layered . Protect investment : Be kind to API Users of . Try to find a way to make API Nice . Such as method name , Such as structure, etc .
Write a API The following aspects need to be considered :API One thing should be done , And did a good job .API It should be as small as possible , But not too small .Implementation Should not affect API. Documentation is important . Consider performance consequences .API Must coexist peacefully with the platform . Class design : Minimize variability , follow LSP principle . Method design : Don't let the customer do what any module can do , Timely error reporting .
( 3、 ... and ) frame
frame (Framework) It's a reusable design of the whole or part of the system , It represents a group of abstract components and methods of interaction between component instances ; Another definition is , The framework is an application framework that can be customized by application developers .
The former is from the application side and the latter is from the purpose side . In order to increase the reusability of code , You can use delegation and inheritance mechanisms . meanwhile , In the process of using these two mechanisms to increase code reuse , We also add relationships between different classes accordingly ( Delegation or inheritance relationship ). And for a project , The dependencies between different classes can be regarded as a framework . A large-scale project may consist of many different frameworks .
Framework and design pattern :
frame 、 Design patterns are always confusing , In fact, there are differences between them . Components are often code reuse , And design patterns are design reuse , The frame is somewhere in between , Partial code reuse , Partial design reuse , Sometimes analysis can be reused .
There are three levels of reuse in software production : Internal reuse , That is, the abstract block that can be used in the same application ;
code reuse , That is to say, general modules are combined into libraries or toolsets , So that it can be used in many applications and fields ;
Reuse of application framework , That is to provide a common or off the shelf infrastructure for a specific domain , For the highest level of reuse .
Frame is similar to design pattern , But there is a fundamental difference .
A design pattern is a description of a recurring problem in a certain environment and a solution to the problem , It's more abstract than a framework ; Frameworks can be represented in code , It can also be executed or reused directly , For patterns, only instances can be represented in code ; Design patterns are smaller elements than frameworks , A framework often contains one or more design patterns , Frameworks are always for a specific application area , However, the first mock exam can be applied to various applications . so to speak , Frameworks are software , Design patterns are the knowledge of software .
The frame is divided into white box frame and black box frame .
边栏推荐
- 最安全的现货白银的心理分析
- Typecho imitation of Lu Songsong's blog theme template / Technology Information blog theme template
- 打新债属于什么理财产品?
- 二叉树转字符串及字符串转二叉树
- OLAP - Druid introduction
- ROS2暑期学校 ROS2 Summer School 2022-转-
- Project directory navigation
- Graphite statsd interface data format description
- Express, route, request object, response object, middleware, EJS template
- Shell 日志与打印输出
猜你喜欢

How about precious metal spot silver?
因为我说:volatile 是轻量级的 synchronized,面试官让我回去等通知!
![[go] go modules GETTING STARTED](/img/0a/58c50bb624c91b88a88aea280aa650.jpg)
[go] go modules GETTING STARTED

Kunlundb query optimization (II) project and filter push down

Typecho仿盧松松博客主題模板/科技資訊博客主題模板

EasyCVR使用RTMP推流时不显示界面如何解决?

Oracle ASM uses the CP command in asmcmd to perform remote replication

图神经网络有哪些用途和应用?

SAP mm me27 create intra company sto order

Typecho imite le modèle de thème du blog Lu songsongsong / modèle de thème du blog d'information technologique
随机推荐
Tidb monitoring upgrade: a long way to solve panic
OSPF comprehensive experiment
Is it reliable to get new debts? Is it safe?
通过天天基金投资基金安全吗?我打算开户买基金
How to refine permissions to buttons?
Swiftui swift tutorial 14 useful array operators
[go] go mod mode, package 12import/add is not in goroot
瑞达期货安全么?期货开户都是哪些流程?期货手续费怎么降低?
Shell 日志与打印输出
BGP联邦综合实验
SAP UI5 应用开发教程之一百零三 - 如何在 SAP UI5 应用中消费第三方库试读版
[machine learning watermelon book] update challenge [Day1]: 1.1 INTRODUCTION
What financial product does the new bond belong to?
SAP mm transaction code vl04 create outbound delivery for sto
百度交易中台之钱包系统架构浅析
2022天梯赛-全国总决赛复盘赛
Cadence spb17.4 - Allegro - optimize and specify the polyline connection angle of a single electrical line - polyline to arc
Introduction to the use of opencvsharp (C openCV) wechat QRcode decoding function (with source code attached)
3DMAX modeling notes (I): introducing 3DMAX and creating the first model Hello World
How to solve the problem that easycvr does not display the interface when RTMP streaming is used?