- 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(){ /* ... */}
}
推薦閱讀
- 機器學習系統:設計和實現
- MySQL數據庫應用與管理 第2版
- RTC程序設計:實時音視頻權威指南
- 數據結構(Python語言描述)(第2版)
- Mastering ServiceNow(Second Edition)
- Scientific Computing with Scala
- Creating Stunning Dashboards with QlikView
- C#開發案例精粹
- Vue.js 2 Web Development Projects
- Building Serverless Architectures
- Arduino Wearable Projects
- 零基礎看圖學ScratchJr:少兒趣味編程(全彩大字版)
- 從零開始學Unity游戲開發:場景+角色+腳本+交互+體驗+效果+發布
- Learning ClojureScript
- Python for Secret Agents