Chapter 11 — Advanced OOP: abstract, mixins, enums
Part 1A — Learn Dart · Chapter 11 of 62 · 7 h
Chapter 11 — Advanced OOP: abstract, mixins, enums
Level: intermediate Estimated time: 7 h Prerequisites: Chapter 10 — Encapsulation, inheritance, polymorphism What you will be able to do by the end: design a clean class hierarchy with abstract classes, interfaces, mixins, enums, and extensions, and choose the right tool for each need.
11.0 — Chapter objectives
By the end of this chapter, you will be able to:
- explain why single inheritance is not always enough;
- understand what an abstract class is;
- use the
abstractkeyword; - write an abstract method, that is, a method without a body;
- understand why an abstract class cannot be instantiated;
- mix concrete and abstract methods in the same class;
- understand the notion of an implicit interface, specific to Dart;
- use the
implementskeyword; - clearly distinguish
extendsfromimplements; - implement several interfaces on a single class;
- explain the problem that mixins solve;
- declare a
mixinand apply it withwith; - apply several mixins and understand the resolution order;
- restrict a mixin with the
onkeyword; - declare and use an
enum; - write a
switchon an enum; - use
values,index, andname; - write an enhanced enum with properties and methods;
- add features to an existing type with
extension ... on; - choose between composition and inheritance;
- know which tool to use for which need.
Comments
Comments are powered by GitHub Discussions
Sign in with GitHub to join the discussion