- Learning Dart
- Ivo Balbaert Dzenan Ridjanovic
- 225字
- 2021-07-19 18:33:43
Chapter 3. Structuring Code with Classes and Libraries
In this chapter we will look at the object-oriented nature of Dart. If you have prior knowledge of an OO language, most of this chapter will feel familiar. Nonetheless, coding classes in Dart is more succinct when introducing some nice new features such as factory constructors and generalizing the use of interfaces. If you come from the JavaScript world, you will start to realize that classes can really structure your application.
Data mostly comes in collections. Dart has some neat classes to work with collections, and they can be used for any type of collections. That's why they are called generic. As soon as you get a few code files in your project, structuring them by making libraries becomes essential for code maintainability. Also, your code will probably use existing libraries written by other developers; to make it easy, Dart has its own package manager called pub. Automating the testing of code on a functional level is done with a built-in unit test library.
We will look at the following topics:
- Using classes and objects
- Collection types and generic classes
- Structuring your code using libraries
- Managing library dependencies with pub
- Unit testing in Dart
We will wrap it all up in a small but useful project to calculate word frequencies in an extract of text.
- 廣電5G從入門到精通
- 黑客攻防實戰技術完全手冊:掃描、嗅探、入侵與防御
- 物聯網工程規劃技術
- Hands-On Chatbots and Conversational UI Development
- JBoss EAP6 High Availability
- Go Web Scraping Quick Start Guide
- Practical Web Design
- Getting Started with Grunt:The JavaScript Task Runner
- 圖解手機元器件維修技巧
- 工業互聯網創新實踐
- 深入理解OpenStack Neutron
- Hands-On Bitcoin Programming with Python
- LwIP應用開發實戰指南:基于STM32
- 物聯網與智慧農業
- 數字王國里的虛擬人:技術、商業與法律解讀