Slide 1

Slide 1 text

Katerina Trajchevska From Good to SOLID Architecture

Slide 2

Slide 2 text

Katerina Trajchevska ● Senior Software Engineer & co-founder of Adeva ● Remote Work Advocate ● Community Volunteer ● Consultant with startups and Fortune 500 companies Software Engineer and co-founder of Adeva

Slide 3

Slide 3 text

@ktrajchevska The state of software development Cutting costs by sacrificing good software architecture.

Slide 4

Slide 4 text

@ktrajchevska SOLID Design Principles ● Encourage writing code that is: ○ Easier to read and understand ○ Easier to maintain ○ Easier to extend ● Introduced by Robert Martin (Uncle Bob), named by Michael Feathers.

Slide 5

Slide 5 text

Single Responsibility Principle A class should have one, and only one, reason to change.

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

@ktrajchevska Single Responsibility Principle ● A class should only do one thing. ● Find one responsibility and move everything else out of the class. ● Very precise names for many small classes > generic names for large classes.

Slide 8

Slide 8 text

1 2 3

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Open/Closed Principle An entity should be open for extension, but closed for modification.

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

@ktrajchevska Open/Closed Principle ● Extend functionality by adding new code instead of changing existing one. ● Easily extend the system; never break it. ● Example: Open Source library

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Liskov Substitution Principle Let φ(x) be a property provable about objects x of type T. Then φ(y) should be true for objects y of type S where S is a subtype of T.

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

@ktrajchevska Liskov Substitution Principle ● Any class should be able to substitute its parent class without breaking the program. ● Every class that implements an interface, must be able to substitute any other class that implements the same interface without breaking the program. ● Every part of the code should get the expected result.

Slide 25

Slide 25 text

Returns Illuminate\Support\Collection

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Returns array

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

Returns Illuminate\Support\Collection

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Interface Segregation Principle No client should be forced to depend on methods it does not use.

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

@ktrajchevska Interface Segregation Principle ● A client should never be forced to depend on methods it doesn't use. ● Changing one method in a class shouldn’t affect classes that don’t depend on it. ● Replace a large interface with many small, specific interfaces.

Slide 36

Slide 36 text

Illuminate\Database\ Eloquent\Model: 1600+ lines of code

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

Dependency Inversion Principle High-level modules should not depend on low-level modules. Both should depend on abstractions.

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

@ktrajchevska Dependency Inversion Principle ● Never depend on anything concrete, only depend on abstractions. ● High level modules should not depend directly on low level modules. ● Able to change an implementation easily without altering the high level code.

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

@ktrajchevska The results of SOLID Cutting costs by implementing good software architecture.

Slide 48

Slide 48 text

@ktrajchevska ⚠ Words of caution ● SOLID design principles are principles, not rules. ● Know your trade-offs and use common sense when applying SOLID. ● Avoid over-fragmenting your code. ● Don’t try to achieve SOLID, use SOLID to achieve better developer experience.

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

@ktrajchevska Final Thoughts ● SOLID helps you achieve code that’s easy to maintain, extend and understand. ● Spend more time writing and less time reading code. ● Always know your trade-offs and use common sense.

Slide 51

Slide 51 text

SOLID is your tool, not your goal.

Slide 52

Slide 52 text

Thank you @ktrajchevska Connecting tech companies with world-class developers