SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
SOLID
PRINCIPLES
WITH
TYPESCRIPT
EXAMPLES
ANDREW NESTER
Software Engineer
WHAT IS SOLID?
SINGLE RESPONSIBILITY
OPEN - CLOSED
LISKOV SUBSTITUTION
INTERFACE SEGREGATION
DEPENDENCY INVERSION
BUT WHY?
MORE UNDERSTANDABLE CODE DESIGNS
EASIER TO MAINTAIN
EASIER TO EXTEND
SINGLE RESPONSIBILITY
DO ONE AND ONLY ONE THING
BUT DO IT WELL
WHAT IS WRONG?
class Order {
public calculateTotalSum() {/* ... */ }
public getItems() {/* ... */ }
public getItemCount() {/* ... */ }
public addItem(item: Item) {/* ... */ }
public removeItem(item: Item) {/* ... */ }
public printOrder() {/* ... */ }
public showOrder() {/* ... */ }
public load() {/* ... */ }
public save() {/* ... */ }
public update() {/* ... */ }
public delete() {/* ... */}
}
DIFFICULT TO MAINTAIN
LOTS OF REASONS TO CHANGE
CASCADE CHANGES
BETTER CODE
class Order
{
public calculateTotalSum() {/*...*/}
public getItems() {/*...*/}
public getItemCount() {/*...*/}
public addItem(item: Item) {/*...*/}
public deleteItem(item: Item) {/*...*/}
}
class OrderRepository
{
public load(){}
public save(){}
public update(){}
public delete(){}
}
class OrderViewer
{
public printOrder(){}
public showOrder(){}
}
OPEN - CLOSED
FEEL FREE TO EXTEND BUT
DO NOT MODIFY
WHAT IS WRONG?
class OrderCalculator
{
public calculate(orders): number {
let sum = 0;
for (let order of orders) {
if (order instanceof SingleOrder) {
sum += this.calculateSingle(order);
}
if (order instanceof MultiOrder) {
sum += this.calculateMulti(order);
}
}
return sum;
}
private calculateSingle(order: SingleOrder): number {}
private calculateMulti(order: MultiOrder): number {}
}
DIFFICULT TO EXTEND
DIFFICULT TO REUSE
NEED TO CHANGE
ORDERCALCULATOR
IF NEW TYPE OF ORDERS APPEAR
BETTER CODE
class OrderCalculator {
public calculate(orders: OrderInterface[]){
let sum = 0;
for (let order of orders) {
sum += order.calculate();
}
return sum;
}
}
interface OrderInterface {
calculate(): number;
}
class SingleOrder implements OrderInterface {
calculate(): number {}
}
class MultiOrder implements OrderInterface {
calculate(): number {}
}
LISKOV SUBSTITUTION
IF YOU USE BASE TYPE
YOU SHOULD BE ABLE TO USE SUBTYPES
AND DO NOT BREAK ANYTHING
WHAT IS WRONG?
class Order {
protected items: Item[] = [];
public addItem(item: Item) {
this.items.push(item);
}
public getItems() {
return this.items;
}
}
class OrderCollector {
public collect(order: Order, items: Item[]) {
for (let item of items) {
order.addItem(item);
}
}
}
ACTUALLY NOTHING IS WRONG WITH IT
WHAT IS WRONG?
class Order {
protected items: Item[] = [];
public addItem(item: Item) {
this.items.push(item);
}
public getItems() {
return this.items;
}
}
class FreeOrder extends Order {
public addItem(item: Item) {
if (item.price() !== 0) {
throw new Error();
}
this.items.push(item);
}
}
class OrderCollector {
public collect(order: Order, items: Item[]) {
for (let item of items) {
order.addItem(item);
}
}
}
FREEORDER BREAKS ORDERCOLLECTOR
FREEORDER IS NOT “REAL” SUBCLASS
INHERITANCE SHOULD BE DEFINED BASED
ON BEHAVIOUR
BETTER CODE
abstract class ItemList {
protected items: Item[] = [];
public getItems() {
return this.items;
}
}
class Order extends ItemList {
public addItem(item: Item) {
this.items.push(item);
}
}
class FreeOrder extends ItemList {
public addItem(item: FreeItem) {
this.items.push(item);
}
}
INTERFACE SEGREGATION
SEVERAL SPECIALISED
INTERFACES ARE BETTER THAN
1 ALL-PURPOSE ONE
WHAT IS WRONG?
interface ItemInterface
{
applyDiscount(discount: number);
applyPromocode(promocode: string);
setColor(color: string);
setSize(size: Size);
setCondition(condition: Condition);
setPrice(price: number);
}
DIFFICULT TO REUSE
INTERFACE IS TOO BIG TO IMPLEMENT
POTENTIAL VIOLATION OF
SINGLE RESPONSIBILITY
AND
LISKOV SUBSTITUTION
PRINCIPLES.
BETTER CODE
interface ItemInterface
{
setCondition(condition: Condition);
setPrice(price: number);
}
interface ClothesInterface
{
setColor(color: string);
setSize(size: Size);
setMaterial(material: string);
}
interface DiscountableInterface
{
applyDiscount(discount: number);
applyPromocode(promocode: string);
}
DEPENDENCY INVERSION
DEPEND ON ABSTRACTION NOT
IMPLEMENTATION
class Customer {
private currentOrder: Order = null;
public buyItems() {
if (!this.currentOrder) {
return false;
}
const processor = new OrderProcessor();
return processor.checkout(this.currentOrder);
}
}
class OrderProcessor {
public function checkout(order: Order){/*...*/}
}
WHAT IS WRONG?
LESS FLEXIBLE
DIFFICULT TO WRITE UNIT TESTS
YOUR TEAMMATES WILL NOT
APPROVE THIS CODE
BETTER CODE
class Customer {
private currentOrder: Order = null;
public buyItems(processor: OrderProcessorInterface) {
if(!this.currentOrder) {
return false;
}
return processor.checkout(this.currentOrder);
}
}
interface OrderProcessorInterface {
checkout(order: Order);
}
class OrderProcessor implements OrderProcessorInterface {
public checkout(order: Order){/*...*/}
}
AFTERWORD
SOLID
is not panacea
“All problems in computer science
can be solved by another level of
indirection except for the problem of
too many layers of indirection”
Focus on code complexity management,
do not overcomplicate your code
THANKS!

Contenu connexe

Tendances

Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
backdoor
 

Tendances (20)

Interfaces c#
Interfaces c#Interfaces c#
Interfaces c#
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Builder Design Pattern (Generic Construction -Different Representation)
Builder Design Pattern (Generic Construction -Different Representation)Builder Design Pattern (Generic Construction -Different Representation)
Builder Design Pattern (Generic Construction -Different Representation)
 
Clean code and Code Smells
Clean code and Code SmellsClean code and Code Smells
Clean code and Code Smells
 
Exception handling
Exception handlingException handling
Exception handling
 
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...
Spring Framework Tutorial | Spring Tutorial For Beginners With Examples | Jav...
 
Introduction to Design Patterns and Singleton
Introduction to Design Patterns and SingletonIntroduction to Design Patterns and Singleton
Introduction to Design Patterns and Singleton
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 
Inheritance in Java
Inheritance in JavaInheritance in Java
Inheritance in Java
 
Java collection
Java collectionJava collection
Java collection
 
Solid principles
Solid principlesSolid principles
Solid principles
 
SOLID Design Principles applied in Java
SOLID Design Principles applied in JavaSOLID Design Principles applied in Java
SOLID Design Principles applied in Java
 
Code smells and remedies
Code smells and remediesCode smells and remedies
Code smells and remedies
 
Exception Handling in C#
Exception Handling in C#Exception Handling in C#
Exception Handling in C#
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
Google mock training
Google mock trainingGoogle mock training
Google mock training
 
JPA and Hibernate
JPA and HibernateJPA and Hibernate
JPA and Hibernate
 
Open Closed Principle kata
Open Closed Principle kataOpen Closed Principle kata
Open Closed Principle kata
 
Clean code
Clean codeClean code
Clean code
 
Favor composition over inheritance
Favor composition over inheritanceFavor composition over inheritance
Favor composition over inheritance
 

Similaire à SOLID principles with Typescript examples

Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2
Technopark
 
import java-util--- public class MyLinkedList{ public static void.pdf
import java-util---  public class MyLinkedList{    public static void.pdfimport java-util---  public class MyLinkedList{    public static void.pdf
import java-util--- public class MyLinkedList{ public static void.pdf
asarudheen07
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdf
info30292
 

Similaire à SOLID principles with Typescript examples (20)

Infinum Android Talks #20 - DiffUtil
Infinum Android Talks #20 - DiffUtilInfinum Android Talks #20 - DiffUtil
Infinum Android Talks #20 - DiffUtil
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design Patterns
 
Mattbrenner
MattbrennerMattbrenner
Mattbrenner
 
Java Generics
Java GenericsJava Generics
Java Generics
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Java весна 2013 лекция 2
Java весна 2013 лекция 2Java весна 2013 лекция 2
Java весна 2013 лекция 2
 
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019Lowering in C#: What really happens with your code?, from NDC Oslo 2019
Lowering in C#: What really happens with your code?, from NDC Oslo 2019
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
That’s My App - Running in Your Background - Draining Your Battery
That’s My App - Running in Your Background - Draining Your BatteryThat’s My App - Running in Your Background - Draining Your Battery
That’s My App - Running in Your Background - Draining Your Battery
 
Modularization Strategies - Fixing Class and Package Tangles
Modularization Strategies - Fixing Class and Package TanglesModularization Strategies - Fixing Class and Package Tangles
Modularization Strategies - Fixing Class and Package Tangles
 
Scala on Your Phone
Scala on Your PhoneScala on Your Phone
Scala on Your Phone
 
Solid principles
Solid principlesSolid principles
Solid principles
 
import java-util--- public class MyLinkedList{ public static void.pdf
import java-util---  public class MyLinkedList{    public static void.pdfimport java-util---  public class MyLinkedList{    public static void.pdf
import java-util--- public class MyLinkedList{ public static void.pdf
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdf
 
Kotlin Generation
Kotlin GenerationKotlin Generation
Kotlin Generation
 
It's complicated, but it doesn't have to be: a Dagger journey
It's complicated, but it doesn't have to be: a Dagger journeyIt's complicated, but it doesn't have to be: a Dagger journey
It's complicated, but it doesn't have to be: a Dagger journey
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
 
Navigating the xDD Alphabet Soup
Navigating the xDD Alphabet SoupNavigating the xDD Alphabet Soup
Navigating the xDD Alphabet Soup
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 

Dernier

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Dernier (20)

Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 

SOLID principles with Typescript examples

  • 3. WHAT IS SOLID? SINGLE RESPONSIBILITY OPEN - CLOSED LISKOV SUBSTITUTION INTERFACE SEGREGATION DEPENDENCY INVERSION
  • 8. SINGLE RESPONSIBILITY DO ONE AND ONLY ONE THING BUT DO IT WELL
  • 9. WHAT IS WRONG? class Order { public calculateTotalSum() {/* ... */ } public getItems() {/* ... */ } public getItemCount() {/* ... */ } public addItem(item: Item) {/* ... */ } public removeItem(item: Item) {/* ... */ } public printOrder() {/* ... */ } public showOrder() {/* ... */ } public load() {/* ... */ } public save() {/* ... */ } public update() {/* ... */ } public delete() {/* ... */} }
  • 11. LOTS OF REASONS TO CHANGE
  • 13. BETTER CODE class Order { public calculateTotalSum() {/*...*/} public getItems() {/*...*/} public getItemCount() {/*...*/} public addItem(item: Item) {/*...*/} public deleteItem(item: Item) {/*...*/} } class OrderRepository { public load(){} public save(){} public update(){} public delete(){} } class OrderViewer { public printOrder(){} public showOrder(){} }
  • 14. OPEN - CLOSED FEEL FREE TO EXTEND BUT DO NOT MODIFY
  • 15. WHAT IS WRONG? class OrderCalculator { public calculate(orders): number { let sum = 0; for (let order of orders) { if (order instanceof SingleOrder) { sum += this.calculateSingle(order); } if (order instanceof MultiOrder) { sum += this.calculateMulti(order); } } return sum; } private calculateSingle(order: SingleOrder): number {} private calculateMulti(order: MultiOrder): number {} }
  • 18. NEED TO CHANGE ORDERCALCULATOR IF NEW TYPE OF ORDERS APPEAR
  • 19. BETTER CODE class OrderCalculator { public calculate(orders: OrderInterface[]){ let sum = 0; for (let order of orders) { sum += order.calculate(); } return sum; } } interface OrderInterface { calculate(): number; } class SingleOrder implements OrderInterface { calculate(): number {} } class MultiOrder implements OrderInterface { calculate(): number {} }
  • 20. LISKOV SUBSTITUTION IF YOU USE BASE TYPE YOU SHOULD BE ABLE TO USE SUBTYPES AND DO NOT BREAK ANYTHING
  • 21. WHAT IS WRONG? class Order { protected items: Item[] = []; public addItem(item: Item) { this.items.push(item); } public getItems() { return this.items; } } class OrderCollector { public collect(order: Order, items: Item[]) { for (let item of items) { order.addItem(item); } } }
  • 22. ACTUALLY NOTHING IS WRONG WITH IT
  • 23. WHAT IS WRONG? class Order { protected items: Item[] = []; public addItem(item: Item) { this.items.push(item); } public getItems() { return this.items; } } class FreeOrder extends Order { public addItem(item: Item) { if (item.price() !== 0) { throw new Error(); } this.items.push(item); } } class OrderCollector { public collect(order: Order, items: Item[]) { for (let item of items) { order.addItem(item); } } }
  • 25. FREEORDER IS NOT “REAL” SUBCLASS
  • 26. INHERITANCE SHOULD BE DEFINED BASED ON BEHAVIOUR
  • 27. BETTER CODE abstract class ItemList { protected items: Item[] = []; public getItems() { return this.items; } } class Order extends ItemList { public addItem(item: Item) { this.items.push(item); } } class FreeOrder extends ItemList { public addItem(item: FreeItem) { this.items.push(item); } }
  • 28. INTERFACE SEGREGATION SEVERAL SPECIALISED INTERFACES ARE BETTER THAN 1 ALL-PURPOSE ONE
  • 29. WHAT IS WRONG? interface ItemInterface { applyDiscount(discount: number); applyPromocode(promocode: string); setColor(color: string); setSize(size: Size); setCondition(condition: Condition); setPrice(price: number); }
  • 31. INTERFACE IS TOO BIG TO IMPLEMENT
  • 32. POTENTIAL VIOLATION OF SINGLE RESPONSIBILITY AND LISKOV SUBSTITUTION PRINCIPLES.
  • 33. BETTER CODE interface ItemInterface { setCondition(condition: Condition); setPrice(price: number); } interface ClothesInterface { setColor(color: string); setSize(size: Size); setMaterial(material: string); } interface DiscountableInterface { applyDiscount(discount: number); applyPromocode(promocode: string); }
  • 34. DEPENDENCY INVERSION DEPEND ON ABSTRACTION NOT IMPLEMENTATION
  • 35. class Customer { private currentOrder: Order = null; public buyItems() { if (!this.currentOrder) { return false; } const processor = new OrderProcessor(); return processor.checkout(this.currentOrder); } } class OrderProcessor { public function checkout(order: Order){/*...*/} } WHAT IS WRONG?
  • 37. DIFFICULT TO WRITE UNIT TESTS
  • 38. YOUR TEAMMATES WILL NOT APPROVE THIS CODE
  • 39. BETTER CODE class Customer { private currentOrder: Order = null; public buyItems(processor: OrderProcessorInterface) { if(!this.currentOrder) { return false; } return processor.checkout(this.currentOrder); } } interface OrderProcessorInterface { checkout(order: Order); } class OrderProcessor implements OrderProcessorInterface { public checkout(order: Order){/*...*/} }
  • 42. “All problems in computer science can be solved by another level of indirection except for the problem of too many layers of indirection”
  • 43. Focus on code complexity management, do not overcomplicate your code