- Learning Ionic(Second Edition)
- Arvind Ravulavaru
- 135字
- 2021-07-02 23:24:24
Interface
As we start building complex apps, there will be a common need for a certain type of structure to be repeated throughout the app, which follows certain rules. This is where an interface comes into the picture. Interfaces provide structural subtyping or duck typing to check the type and shape of entities.
For instance, if we are working with an app that deals with cars, every car will have a certain common structure that needs to be adhered to when used within the app. Hence we create an interface named ICar. Any class working with cars will implement this interface as follows:
Interface ICar {
engine : String;
color: String;
price : Number;
}
class CarInfo implements ICar{
engine : String;
color: String;
price : Number;
constructor(){ /* ... */}
}
推薦閱讀
- JSP網(wǎng)絡編程(學習筆記)
- Getting Started with Gulp(Second Edition)
- Spring 5企業(yè)級開發(fā)實戰(zhàn)
- Python數(shù)據(jù)可視化:基于Bokeh的可視化繪圖
- x86匯編語言:從實模式到保護模式(第2版)
- Python應用輕松入門
- 用Flutter極速構建原生應用
- SQL Server 2016數(shù)據(jù)庫應用與開發(fā)習題解答與上機指導
- Mastering Unity 2D Game Development(Second Edition)
- 利用Python進行數(shù)據(jù)分析
- 匯編語言編程基礎:基于LoongArch
- Spring技術內(nèi)幕:深入解析Spring架構與設計原理(第2版)
- Python數(shù)據(jù)可視化之美:專業(yè)圖表繪制指南(全彩)
- 玩轉(zhuǎn).NET Micro Framework移植:基于STM32F10x處理器
- Python Web自動化測試設計與實現(xiàn)