This document discusses object-oriented programming concepts in Swift such as inheritance, encapsulation, and polymorphism. It covers inheritance relationships like "is-a" and "has-a" and how inheritance works in Swift with instance variables, methods, and constructors. The document also discusses access permissions and how private variables are inherited but not visible to subclasses.
1 of 39
Downloaded 10 times
More Related Content
Object Oriented Programming in Swift Ch1 - Inheritance
2. References
Agile Software Development: Principles, Patterns,
and Practice ( : )
by Robert C. Martin
Fundamental Object Oriented Programming
by Hsuan-Tien Lin
by Teddy Chen
Essential Object-Oriented Programming
by Josh Ko
10. chi
Admin is a user
can be implemented via has-a:
Everyone has Brokeback Mountain in mind
child
11. Type A inherit TypeB: TypeA is a (special case of) TypeB
TypeSubClass (TypeDerivedClass or ChildClass) inherit
TypeSuperClass (TypeBaseClass or ParentClass)
19. Is-A
is an extended type of
- FunPerson is Person who can tell jokes
is a more concrete/restricted description of
- YoungPerson is Person who is young
(is an update of)
- NewStaff replaces ExistingStaff
21. Over-use of inherit for is-a: 1 class -> 1 instance
Usual goal of OOP: one class, many instances
22. Is-A
Under-user of inherit for is-a: overly complicated class
YowooStaff
Bugs/hacks?
cali = YowooStaff(id: , name: CYLi, title: CFO)