Home SOCRA : Cours du 30 avril
Post
Cancel

SOCRA : Cours du 30 avril

Clean code, what is it ?

What is your pain ?

  • Bugs ?
    • Not cool when a client find a bug
  • Coding style ?
    • Having a bad coding style
  • Working with others ?
    • Coordinating actions

Developer life…

By code :

  • Compilation failed
  • Seg fault
  • Stack overflow

By client :

  • ASAP
  • Bad UX
  • Not working

…is awesome !

  • We create products
  • We discover new trades
  • We learn !

Software craftmanship manifesto

Technical debt impact

  • Code readbility
  • New features development
  • Bug fixing

Be…

Simple rules

Bugs are everywhere : one operation per line helps you identify the location

become :

Do not ask twice for the same thing, it improves your system perfs

become :

  • Use explicit names
  • Read your code
  • Code phrases

How ?

OO Principles

  • Encapsulation
  • Inheritance
  • Polymorphism
    • Overloading
    • Templates / Generics
    • Subtypings

S.O.L.I.D. Snake

  • SRP : Single Responsibility Principle
  • OCP : Open/closed principle
  • LSP : Liskov Substitution Principle
  • ISP : Interface Segregation Principle
  • DIP : Dependency Inversion Principle

Single Responsibility Principle

A class should have only one reason to change.

Open/Close Principle

Software entities should be open for extension, but closed for modification.

Liskov Substitution Principle

Interface segregation principle

Many client-specific interfaces are better than one general-purpose interface.

Dependency Injection Principle

One should “depend upon abstractions, not concretions”.

Be Agile

V Cycle

Agile

SCRUM

Methodology

  • Product owner
  • Scrum master
  • Developer team
  • Backlog

Workflow

  • Sprint Meeting Planning
    • Plan what needs to be done for the next version
  • Daily Scrum Meeting
    • where are we at
  • Sprint Retrospective
    • what is well done, what is not, etc.

KANBAN

Tickets per action

Think tests

Why do we test ?

  • Tests to help understand requirements
  • Tests protects future developments
  • Tests are a fall protection
  • We are human after all

How do we test ?

  • Unit Test : Focus on ONE function usage, mock dependencies
  • Integration Test : Crosses the boundary between components
  • Behaviour Test : An example of the user using the system

The test pyramid

TDD : Test Driven Development

No code without a test

  1. Write a test which fails
  2. Write the code which fulfil the test
  3. Refactor source code (feature and test !)

What is a good unit test ?

  • Easy to understanf, clear when it fails
  • Determinist
  • Focused
  • AAA : Arrange / Act / Assert

BDD : Behaviour Driven Development

The double loop

Test coverage

This post is licensed under CC BY 4.0 by the author.