SomethingAbout
Architecture

Architecture
IS NOT
Patterns and/or Frameworks

Architecture
is set of constraints

Want to write good and maintainable code?

Tech Debt

GOTO Considered Harmful

but not lethal, and certainly not useless

var x = 2; // value and identifier
// ...
y = x ** 2; // state!

Encapsulation

Law of Demeter

Separation of Concerns

Just different name for decomposition

DRY

Don't Repeat Yourself

Code is not reusable

Abstractions are reusable

Liskov
Substitution
Principle

Coupling & Cohesion

Single Responsibility Principle

Each class should have one and only one reason to change

class MerchantManager
{
    public recalculateSalesLimit(merchant: Merchant): void
    {
        const salesForPreviousMonth = this.orders.salesForPreviousMonth(merchant);
        const salesLimit = Math.max(
            MIN_SALES_LIMIT, 
            salesForThisMonth * 1.5,
        );

        merchant.setLimit(salesLimit);

        this.notifier.send(new SalesLimitUpdated(merchant, salesLimit));
    }
}

Not so good...

Dependency Inversion

Dependency Inversion

Inversion Of Control

Don't call us, we call you

Inversion of Control

Inversion of Control

Open/Close Principle

Open for extension
Closed for modifications

deck

By Sergey Protko

deck

  • 103