- 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(){ /* ... */}
}
推薦閱讀
- Java程序設計實戰教程
- Getting Started with ResearchKit
- JIRA 7 Administration Cookbook(Second Edition)
- Mastering Articulate Storyline
- Python高級編程
- Mastering LibGDX Game Development
- 微服務從小白到專家:Spring Cloud和Kubernetes實戰
- 微信小程序開發與實戰(微課版)
- 智能手機APP UI設計與應用任務教程
- Node學習指南(第2版)
- Python 3 Object:oriented Programming(Second Edition)
- Ext JS 4 Plugin and Extension Development
- 數據分析與挖掘算法:Python實戰
- Python第三方庫開發應用實戰
- Docker on Windows