Project Overview
Part of the Object Oriented Programming section of Coddy's Dart journey — lesson 101 of 110.
Challenge
EasyIn this chapter, you'll build a Library Management System that combines classes, encapsulation, and design patterns into a working application.
Let's start by setting up the project structure with a simple Book class - the foundation that all future lessons will build upon.
You'll create two files:
book.dart: Define aBookclass with three properties:isbn(String),title(String), andauthor(String). Include a constructor that initializes all three properties, and override thetoString()method to return the book's information in the format[isbn] title by author.main.dart: Import your book file and create two books to verify your class works correctly. Create a book with ISBN978-0-13-468599-1, titleThe Pragmatic Programmer, and authorDavid Thomas. Create a second book with ISBN978-0-596-51774-8, titleJavaScript: The Good Parts, and authorDouglas Crockford. Print both books (which will use yourtoString()method).
This simple structure establishes the file organization pattern you'll follow throughout the project. In upcoming lessons, you'll expand this with user classes, borrowing logic, and more!
Expected output:
[978-0-13-468599-1] The Pragmatic Programmer by David Thomas
[978-0-596-51774-8] JavaScript: The Good Parts by Douglas CrockfordTry it yourself
import 'book.dart';
void main() {
// TODO: Create a book with ISBN '978-0-13-468599-1', title 'The Pragmatic Programmer', and author 'David Thomas'
// TODO: Create a second book with ISBN '978-0-596-51774-8', title 'JavaScript: The Good Parts', and author 'Douglas Crockford'
// TODO: Print both books (this will use the toString() method)
}
All lessons in Object Oriented Programming
1Fundamentals of OOP
External FilesLibraries & ImportsIntroduction to OOPClasses vs ObjectsThe this KeywordMethodsInstance VariablesConstructor BasicsRecap - Simple Calculator4Null Safety
Intro to Null SafetyNullable vs Non-NullableThe ? and ! OperatorsLate Keyword & Null SafetyNull-Aware OperatorsNull Safety in ClassesRecap - User Profile System7Abstract Classes & Interfaces
Abstract ClassesAbstract MethodsInterfaces in DartImplicit InterfacesImplementing vs ExtendingMultiple InterfacesRecap - Shape Calculator10Collections & Generics
List, Set, Map OverviewType-Safe CollectionsGeneric ClassesGeneric MethodsGeneric ConstraintsIterable & IteratorRecap - Generic Storage13Advanced OOP Concepts
Composition vs InheritanceExtension MethodsCallable ClassesSealed Classes (Dart 3)Records (Dart 3)Patterns & Matching (3.0)Enums with Methods16Project: Library Management
Project OverviewBook and User Classes2Constructors in Dart
Default ConstructorNamed ConstructorsInitializer ListsConstant ConstructorsFactory ConstructorsRedirecting ConstructorsRecap - Shape Builder5Encapsulation
Public vs Private MembersThe _ Prefix ConventionLibrary-Level PrivacyGetters & Setters DepthInformation HidingRecap - Student Records8Mixins
Introduction to MixinsCreating MixinsUsing Multiple Mixinson Keyword in MixinsMixin vs InheritanceMixin vs InterfaceRecap - Animal System11Special Methods
toString() OverridehashCode & == OverrideComparable Interfacecall() MethodnoSuchMethod OverrideRecap - Custom Collection14Design Patterns Part 1
Intro to Design PatternsSingleton PatternFactory PatternObserver PatternStrategy Pattern3Class Properties
Instance vs Static MembersFinal & Const FieldsLate VariablesStatic Methods & FieldsGetters and SettersRecap - Bank Account Manager6Inheritance
Basic InheritanceThe super KeywordMethod OverridingThe @override AnnotationThe final Class KeywordConstructors & InheritanceRecap - Employee Hierarchy9Polymorphism
Polymorphism BasicsPolymorphism via InterfacesRuntime Type CheckingThe is & as OperatorsCovariant KeywordRecap - Payment Processor