SlideShare a Scribd company logo
Softwerkskammer - Coding Dojo
Racing Car Katas
S.O.L.I.D & Refactoring
https://www.slideshare.net/georgberky/solid-refactoring-racing-car-katas
let’s practice together
● all professionals practice
● how about us programmers?
● when was the last time you sat down to really
understand a problem?
● tonight we have time to do that
the ground rules
● write tests
● work together in pairs
● write down
– �: what did you learn
– �: what made you lose focus
– �: what confused you
– � : what annoyed you
● share with everybody
● be excellent to each other
the ground rules
● if you have the keyboard, you get to decide what to type
● if you have the keyboard and you don’t know what to
type, ask for help
● if you are asked for help, kindly respond to the best of
your ability
● if you are not asked, but you see an opportunity for
improvement or learning, choose an appropriate
moment to mention it like the next green test or the
retrospective
from: Emily Bache – The Coding Dojo Handbook
the exercise
● choose one exercise
● add tests for the class
– Leaderboard: add tests using SelfDrivingCar
● write down where SOLID principles were violated
● repeat
● share with your fellow craftspeople
SOLID
● Single responsibility principle (SRP)
● Open/closed principle (OCP)
● Liskov substitution principle (LSP)
● Interface segregation principle (ISP)
● Dependency inversion principle (DIP)
single responsibility principle
● responsibility = reason to change
● if nothing ever changed: no problem
● change is the fundamental reality of our
business
SRP - ExpensesReport
● store/retrieve expenses:
– Excel, CSV, database
– cause: infrastructure
● compile report from expenses
– taxes, sorting
– cause: business rules
● format and print report
– plain text, HTML
– cause: cosmetic
open/closed principle
● open for extension, closed for modification
● huh? ��♂�‍ ️
● when facing change: introduce abstractions
● abstraction = interface (see DIP)
● we need to open/close our design
● this is a voluntary choice
● driven by the fact/requirement of change
● avoid BDUF, practice refactoring
OCP - FizzBuzz
● add one if per number: �
● possible abstractions:
– NumberSayer (immediate choice)
– NumberStrategy (higher abstraction)
● open: extending behavior by adding interface
implementation
● closed: original code does not change when adding a
new number
● cf.: Craig Larman – Protected Variation
Liskov substitution principle
● polymorphism must be transparent to clients
● the client must not care which implementation is used
● instanceof is a smell: broken abstraction
● all contracts of superclass must be kept:
– preconditions
– postconditions
– invariants
– history constraint
LSP - square/rectangle
● class Square extends Rectangle ?
● change width of square
● height has to change too
● contract of Rectangle:
postcondition: setWidth(n) getWidth ()== n⇒
● contract of Square:
invariant: height == width
LSP - square/rectangle
● you cannot drop in a square for a rectangle
● unit tests help you see these contracts
● try to use the same test for subclasses!
● OOP inheritance does not have to follow real
live inheritance
● cf.: design by contract
interface segregation principle
● do not depend on more than you need
● keep your interfaces slim
● extract interface from dependency if you only
use some of the methods
ISP – primitive obsession
● use first class collections:
– do you need all 32 public methods of java.util.List ?
– clarity: Calendar instead of List<Appointment>
● use value types
– DeviceId instead of String
– 76 exposed methods of String
ISP – service locator
● <T> ServiceLocator.getService(Class<T> class)
● infinite number of methods
● ServiceLocator.getService(String.class)
● invisible preconditions:
– serviceClass needs to be in directory
– only discovered at runtime
● constructor:
– explicit precondition
– discovered at compile time
dependency inversion principle
● do not depend on low level details
● depend on high level abstractions instead
● business rules (high level) should not change
when implementation details (low level) change
● e.g. report calculation has to change when data
storage changes?
DIP – button/light
● class Button
– void toggle()
● class LightBulb
– void turnOn()
– void turnOff()
● change: button should work with TV
● class TV
– void powerOn()
– void powerOff()
DIP – button/light
● option 1:
– public Button(LightBulb lightBulb)
– public Button(TV tv)
– void toggle():
● if(lightBulb != null && tv == null) { … }
● if(tv != null && lightBulb == null) { … }
– now add five more classes: �
DIP – button/light
● option 2:
– interface Switchable
● void turnOn()
● void turnOff()
– class LightBulb implements Switchable
– class TV implements Switchable
– public Button(Switchable switchable)
– void toggle(): straightforward
DIP – button/light
● client: Button
– depends on high level abstraction
– “something that can be switched on and off”
– interface, abstract class, multimethod
● low level details:
– turnOn/powerOn, turnOff/powerOff
– depend on abstraction too
– by implementing it
● no dependency on low level details
● interface “owned” by the client
the exercise
● racing car katas
● by Emily Bache & Luca Minudel
● git clone
https://github.com/emilybache/Racing-Car-Katas.git

More Related Content

What's hot

Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
Eyal Golan
 
Visual Studio를 이용한 어셈블리어 학습 part 1
Visual Studio를 이용한 어셈블리어 학습 part 1Visual Studio를 이용한 어셈블리어 학습 part 1
Visual Studio를 이용한 어셈블리어 학습 part 1
YEONG-CHEON YOU
 
유니티 C# 기초 튜토리얼
유니티 C# 기초 튜토리얼유니티 C# 기초 튜토리얼
유니티 C# 기초 튜토리얼
Jemin Lee
 
reporting lesson and exercise 1
reporting lesson and exercise 1reporting lesson and exercise 1
reporting lesson and exercise 1
necrophany
 
Clean code
Clean codeClean code
Clean code
Knoldus Inc.
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
kim.mens
 
Refactoring Techniques
Refactoring TechniquesRefactoring Techniques
Refactoring Techniques
Mayada Ghanem
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English version
saber tabatabaee
 
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~
YEONG-CHEON YOU
 
Code Smells and Its type (With Example)
Code Smells and Its type (With Example)Code Smells and Its type (With Example)
Code Smells and Its type (With Example)
Anshul Vinayak
 
Working with Legacy Code
Working with Legacy CodeWorking with Legacy Code
Working with Legacy Code
Eyal Golan
 
OPAL-RT RT13 Conference: Rapid control prototyping solutions for power electr...
OPAL-RT RT13 Conference: Rapid control prototyping solutions for power electr...OPAL-RT RT13 Conference: Rapid control prototyping solutions for power electr...
OPAL-RT RT13 Conference: Rapid control prototyping solutions for power electr...
OPAL-RT TECHNOLOGIES
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
Sachithra Gayan
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
floydophone
 
Next Generation Functional & Visual Testing powered by AI
Next Generation Functional & Visual Testing powered by AINext Generation Functional & Visual Testing powered by AI
Next Generation Functional & Visual Testing powered by AI
Anand Bagmar
 
course curriculum of BBA (Agribusiness), SAU
course curriculum of BBA (Agribusiness), SAU  course curriculum of BBA (Agribusiness), SAU
course curriculum of BBA (Agribusiness), SAU
Partha Protim Roy Niloy
 
Unit I Testing
Unit I TestingUnit I Testing
Unit I Testing
Dr. Pankaj Zope
 
Clean code
Clean codeClean code
Clean code
Arturo Herrero
 
ISO 26262 Approval of Automotive Software Components
ISO 26262 Approval of Automotive Software ComponentsISO 26262 Approval of Automotive Software Components
ISO 26262 Approval of Automotive Software Components
Real-Time Innovations (RTI)
 

What's hot (20)

Single Responsibility Principle
Single Responsibility PrincipleSingle Responsibility Principle
Single Responsibility Principle
 
Visual Studio를 이용한 어셈블리어 학습 part 1
Visual Studio를 이용한 어셈블리어 학습 part 1Visual Studio를 이용한 어셈블리어 학습 part 1
Visual Studio를 이용한 어셈블리어 학습 part 1
 
유니티 C# 기초 튜토리얼
유니티 C# 기초 튜토리얼유니티 C# 기초 튜토리얼
유니티 C# 기초 튜토리얼
 
reporting lesson and exercise 1
reporting lesson and exercise 1reporting lesson and exercise 1
reporting lesson and exercise 1
 
Clean code
Clean codeClean code
Clean code
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
Refactoring Techniques
Refactoring TechniquesRefactoring Techniques
Refactoring Techniques
 
Tech talks#6: Code Refactoring
Tech talks#6: Code RefactoringTech talks#6: Code Refactoring
Tech talks#6: Code Refactoring
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English version
 
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~
프로그래밍 언어의 F1머신 C++을 타고 Windows 10 UWP 앱 개발의 세계로~
 
Code Smells and Its type (With Example)
Code Smells and Its type (With Example)Code Smells and Its type (With Example)
Code Smells and Its type (With Example)
 
Working with Legacy Code
Working with Legacy CodeWorking with Legacy Code
Working with Legacy Code
 
OPAL-RT RT13 Conference: Rapid control prototyping solutions for power electr...
OPAL-RT RT13 Conference: Rapid control prototyping solutions for power electr...OPAL-RT RT13 Conference: Rapid control prototyping solutions for power electr...
OPAL-RT RT13 Conference: Rapid control prototyping solutions for power electr...
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Rethinking Best Practices
Rethinking Best PracticesRethinking Best Practices
Rethinking Best Practices
 
Next Generation Functional & Visual Testing powered by AI
Next Generation Functional & Visual Testing powered by AINext Generation Functional & Visual Testing powered by AI
Next Generation Functional & Visual Testing powered by AI
 
course curriculum of BBA (Agribusiness), SAU
course curriculum of BBA (Agribusiness), SAU  course curriculum of BBA (Agribusiness), SAU
course curriculum of BBA (Agribusiness), SAU
 
Unit I Testing
Unit I TestingUnit I Testing
Unit I Testing
 
Clean code
Clean codeClean code
Clean code
 
ISO 26262 Approval of Automotive Software Components
ISO 26262 Approval of Automotive Software ComponentsISO 26262 Approval of Automotive Software Components
ISO 26262 Approval of Automotive Software Components
 

Similar to SOLID refactoring - racing car katas

Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytech
yannick grenzinger
 
Software Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeySoftware Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit Dey
Cefalo
 
From Good to SOLID: How to become a better PHP developer
From Good to SOLID: How to become a better PHP developerFrom Good to SOLID: How to become a better PHP developer
From Good to SOLID: How to become a better PHP developer
Katerina Trajchevska
 
OutSystems Tips and Tricks
OutSystems Tips and TricksOutSystems Tips and Tricks
OutSystems Tips and Tricks
OutSystems
 
Log4j2 - A deep dive into the logging services in Mulesoft with On-Prem deplo...
Log4j2 - A deep dive into the logging services in Mulesoft with On-Prem deplo...Log4j2 - A deep dive into the logging services in Mulesoft with On-Prem deplo...
Log4j2 - A deep dive into the logging services in Mulesoft with On-Prem deplo...
MysoreMuleSoftMeetup
 
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif IqbalCode Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Cefalo
 
Intro to java 8
Intro to java 8Intro to java 8
Intro to java 8
John Godoi
 
Software Engineering Primer
Software Engineering PrimerSoftware Engineering Primer
Software Engineering Primer
Georg Buske
 
Rails data migrations
Rails data migrationsRails data migrations
Rails data migrations
Andrei Kaleshka
 
Better java with design
Better java with designBetter java with design
Better java with design
Narayann Swaami
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
Brett Child
 
API Design
API DesignAPI Design
API Design
Tim Boudreau
 
Lecture01 algorithm analysis
Lecture01 algorithm analysisLecture01 algorithm analysis
Lecture01 algorithm analysis
Zara Nawaz
 
Validating big data jobs - Spark AI Summit EU
Validating big data jobs  - Spark AI Summit EUValidating big data jobs  - Spark AI Summit EU
Validating big data jobs - Spark AI Summit EU
Holden Karau
 
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark... Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
Databricks
 
Evolve with laravel
Evolve with laravelEvolve with laravel
Evolve with laravel
Gayan Sanjeewa
 
The benefit of sneezing code into an editor vs clean code
The benefit of sneezing code into an editor vs clean codeThe benefit of sneezing code into an editor vs clean code
The benefit of sneezing code into an editor vs clean code
Dave Hulbert
 
Performance in Geode: How Fast Is It, How Is It Measured, and How Can It Be I...
Performance in Geode: How Fast Is It, How Is It Measured, and How Can It Be I...Performance in Geode: How Fast Is It, How Is It Measured, and How Can It Be I...
Performance in Geode: How Fast Is It, How Is It Measured, and How Can It Be I...
VMware Tanzu
 
[SRD UGM] Sharing Session - Software Testing
[SRD UGM] Sharing Session - Software Testing[SRD UGM] Sharing Session - Software Testing
[SRD UGM] Sharing Session - Software Testing
Ahmad Widardi
 
Production-Ready BIG ML Workflows - from zero to hero
Production-Ready BIG ML Workflows - from zero to heroProduction-Ready BIG ML Workflows - from zero to hero
Production-Ready BIG ML Workflows - from zero to hero
Daniel Marcous
 

Similar to SOLID refactoring - racing car katas (20)

Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytech
 
Software Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeySoftware Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit Dey
 
From Good to SOLID: How to become a better PHP developer
From Good to SOLID: How to become a better PHP developerFrom Good to SOLID: How to become a better PHP developer
From Good to SOLID: How to become a better PHP developer
 
OutSystems Tips and Tricks
OutSystems Tips and TricksOutSystems Tips and Tricks
OutSystems Tips and Tricks
 
Log4j2 - A deep dive into the logging services in Mulesoft with On-Prem deplo...
Log4j2 - A deep dive into the logging services in Mulesoft with On-Prem deplo...Log4j2 - A deep dive into the logging services in Mulesoft with On-Prem deplo...
Log4j2 - A deep dive into the logging services in Mulesoft with On-Prem deplo...
 
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif IqbalCode Smells and Refactoring - Satyajit Dey & Ashif Iqbal
Code Smells and Refactoring - Satyajit Dey & Ashif Iqbal
 
Intro to java 8
Intro to java 8Intro to java 8
Intro to java 8
 
Software Engineering Primer
Software Engineering PrimerSoftware Engineering Primer
Software Engineering Primer
 
Rails data migrations
Rails data migrationsRails data migrations
Rails data migrations
 
Better java with design
Better java with designBetter java with design
Better java with design
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
 
API Design
API DesignAPI Design
API Design
 
Lecture01 algorithm analysis
Lecture01 algorithm analysisLecture01 algorithm analysis
Lecture01 algorithm analysis
 
Validating big data jobs - Spark AI Summit EU
Validating big data jobs  - Spark AI Summit EUValidating big data jobs  - Spark AI Summit EU
Validating big data jobs - Spark AI Summit EU
 
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark... Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 
Evolve with laravel
Evolve with laravelEvolve with laravel
Evolve with laravel
 
The benefit of sneezing code into an editor vs clean code
The benefit of sneezing code into an editor vs clean codeThe benefit of sneezing code into an editor vs clean code
The benefit of sneezing code into an editor vs clean code
 
Performance in Geode: How Fast Is It, How Is It Measured, and How Can It Be I...
Performance in Geode: How Fast Is It, How Is It Measured, and How Can It Be I...Performance in Geode: How Fast Is It, How Is It Measured, and How Can It Be I...
Performance in Geode: How Fast Is It, How Is It Measured, and How Can It Be I...
 
[SRD UGM] Sharing Session - Software Testing
[SRD UGM] Sharing Session - Software Testing[SRD UGM] Sharing Session - Software Testing
[SRD UGM] Sharing Session - Software Testing
 
Production-Ready BIG ML Workflows - from zero to hero
Production-Ready BIG ML Workflows - from zero to heroProduction-Ready BIG ML Workflows - from zero to hero
Production-Ready BIG ML Workflows - from zero to hero
 

Recently uploaded

GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 

Recently uploaded (20)

GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 

SOLID refactoring - racing car katas

  • 1. Softwerkskammer - Coding Dojo Racing Car Katas S.O.L.I.D & Refactoring
  • 3. let’s practice together ● all professionals practice ● how about us programmers? ● when was the last time you sat down to really understand a problem? ● tonight we have time to do that
  • 4. the ground rules ● write tests ● work together in pairs ● write down – �: what did you learn – �: what made you lose focus – �: what confused you – � : what annoyed you ● share with everybody ● be excellent to each other
  • 5. the ground rules ● if you have the keyboard, you get to decide what to type ● if you have the keyboard and you don’t know what to type, ask for help ● if you are asked for help, kindly respond to the best of your ability ● if you are not asked, but you see an opportunity for improvement or learning, choose an appropriate moment to mention it like the next green test or the retrospective from: Emily Bache – The Coding Dojo Handbook
  • 6. the exercise ● choose one exercise ● add tests for the class – Leaderboard: add tests using SelfDrivingCar ● write down where SOLID principles were violated ● repeat ● share with your fellow craftspeople
  • 7. SOLID ● Single responsibility principle (SRP) ● Open/closed principle (OCP) ● Liskov substitution principle (LSP) ● Interface segregation principle (ISP) ● Dependency inversion principle (DIP)
  • 8. single responsibility principle ● responsibility = reason to change ● if nothing ever changed: no problem ● change is the fundamental reality of our business
  • 9. SRP - ExpensesReport ● store/retrieve expenses: – Excel, CSV, database – cause: infrastructure ● compile report from expenses – taxes, sorting – cause: business rules ● format and print report – plain text, HTML – cause: cosmetic
  • 10. open/closed principle ● open for extension, closed for modification ● huh? ��♂�‍ ️ ● when facing change: introduce abstractions ● abstraction = interface (see DIP) ● we need to open/close our design ● this is a voluntary choice ● driven by the fact/requirement of change ● avoid BDUF, practice refactoring
  • 11. OCP - FizzBuzz ● add one if per number: � ● possible abstractions: – NumberSayer (immediate choice) – NumberStrategy (higher abstraction) ● open: extending behavior by adding interface implementation ● closed: original code does not change when adding a new number ● cf.: Craig Larman – Protected Variation
  • 12. Liskov substitution principle ● polymorphism must be transparent to clients ● the client must not care which implementation is used ● instanceof is a smell: broken abstraction ● all contracts of superclass must be kept: – preconditions – postconditions – invariants – history constraint
  • 13. LSP - square/rectangle ● class Square extends Rectangle ? ● change width of square ● height has to change too ● contract of Rectangle: postcondition: setWidth(n) getWidth ()== n⇒ ● contract of Square: invariant: height == width
  • 14. LSP - square/rectangle ● you cannot drop in a square for a rectangle ● unit tests help you see these contracts ● try to use the same test for subclasses! ● OOP inheritance does not have to follow real live inheritance ● cf.: design by contract
  • 15. interface segregation principle ● do not depend on more than you need ● keep your interfaces slim ● extract interface from dependency if you only use some of the methods
  • 16. ISP – primitive obsession ● use first class collections: – do you need all 32 public methods of java.util.List ? – clarity: Calendar instead of List<Appointment> ● use value types – DeviceId instead of String – 76 exposed methods of String
  • 17. ISP – service locator ● <T> ServiceLocator.getService(Class<T> class) ● infinite number of methods ● ServiceLocator.getService(String.class) ● invisible preconditions: – serviceClass needs to be in directory – only discovered at runtime ● constructor: – explicit precondition – discovered at compile time
  • 18. dependency inversion principle ● do not depend on low level details ● depend on high level abstractions instead ● business rules (high level) should not change when implementation details (low level) change ● e.g. report calculation has to change when data storage changes?
  • 19. DIP – button/light ● class Button – void toggle() ● class LightBulb – void turnOn() – void turnOff() ● change: button should work with TV ● class TV – void powerOn() – void powerOff()
  • 20. DIP – button/light ● option 1: – public Button(LightBulb lightBulb) – public Button(TV tv) – void toggle(): ● if(lightBulb != null && tv == null) { … } ● if(tv != null && lightBulb == null) { … } – now add five more classes: �
  • 21. DIP – button/light ● option 2: – interface Switchable ● void turnOn() ● void turnOff() – class LightBulb implements Switchable – class TV implements Switchable – public Button(Switchable switchable) – void toggle(): straightforward
  • 22. DIP – button/light ● client: Button – depends on high level abstraction – “something that can be switched on and off” – interface, abstract class, multimethod ● low level details: – turnOn/powerOn, turnOff/powerOff – depend on abstraction too – by implementing it ● no dependency on low level details ● interface “owned” by the client
  • 23. the exercise ● racing car katas ● by Emily Bache & Luca Minudel ● git clone https://github.com/emilybache/Racing-Car-Katas.git