0%
Constructors and Modeling — Chapter 09

Chapter 09 — Constructors and Modeling

Part 1A — Learn Dart · Chapter 09 of 62 · 7 h

Chapter 09 — Constructors and Modeling

Level: beginner / intermediate Estimated time: 7 h Prerequisites: chapter 08 — Introduction to OOP (class, object, property, method, this) What you will be able to do by the end: create complete, valid objects from the very first line of their life with constructors, expose computed values with getters, and translate a written description in French into a coherent set of classes.


09.0 — Chapter Objectives

By the end of this chapter, you will be able to:

  • explain precisely why a class without a constructor is a problem;
  • recognize and use the default constructor;
  • write a custom constructor;
  • use the this.property shorthand syntax;
  • use named parameters with curly braces { };
  • make a named parameter mandatory with required;
  • declare optional parameters and give them a default value;
  • write named constructors such as Player.debutant() or Enemy.boss();
  • initialize a property with an initializer list : x = ...;
  • protect your objects with assert;
  • write a const constructor and explain what it provides;
  • write a factory constructor and explain when it is useful;
  • write a getter, a setter, and computed getters;
  • override toString() to display a readable object;
  • turn a written description in French into a set of Dart classes;
  • apply a list of modeling best practices.

Comments

Comments are powered by GitHub Discussions

Sign in with GitHub to join the discussion

Link copied!