SOLID

Design.

Code Reviews?

kachra code likha hua hai.

Yaar Maza nahi araha.

Yeh konsi SCIENCE hai?

Is line se kya hota hai?

Kachra code:

1. Intehai Complex

2. Change a thing and boom!

3. Code like Thor's hammer

4. Unusable Code

 

Never call someone's baby

ugly.

Good

DESIGN?

Uncle

Bob's

SOLID principles

SINGLE RESPONSIBILITY

OPEN / CLOSE

LISKOV SUBSTITUION 

INTERFACE SEGREGATION

DEPENDENCY INVERSION

SINGLE RESPONSIBILITY

PRINCIPLE

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

Good Package Names

net/http

encoding/json

os/exec

Bad Package Names

server

helpers

ctrls

OPEN CLOSE PRINCIPLE

Software entites should be open for extension, closed for modification

LISKOV SUBSTITUTION PRINCIPLE

Two types of substitutable, if they exhibit behavior such the caller is unable to tell the difference

INTERFACES

Small Interfaces, Simple implementations.

INTERFACES

type Reader interface {
   Read(p []byte) (n int, err error)
}

INTERFACE SEGREGATION PRINCIPLE

Clients should not be dependent on methods that they don't use

DEPENDENCY INVERSION PRINCIPLE

High level modules should not depend on low level modules, both should depend on abstractions.

Auth Service

User Service

CYCLIC DEPENDENCY

Auth Service
User Service
Manager/Ctrl

ACYCLIC DEPENDENCY

net

IN TERMS OF GO

http
rpc

Fin.

Solid design

By Minhaj Khan

Solid design

  • 136