SlideShare a Scribd company logo
1 of 61
Download to read offline
VictorRentea.ro
1
Clean Code, Two Decades Later
victor.rentea@gmail.com ♦ ♦ @victorrentea ♦ VictorRentea.ro
victorrentea.ro/training-offer
👋 Hi, I'm Victor Rentea 🇷🇴 PhD(CS)
Java Champion, 18 years of code, 10 years of teaching
Consultant & Trainer at 120+ companies:
❤ Clean Code, Architecture, Unit Tes3ng
🛠 Spring, Hibernate, Reac3ve
⚡ Java Performance, Secure Coding
EducaDve Conference Talks on YouTube
Founder of European So<ware Cra<ers Community (6K members)
🔥 Free 1-hour webinars, a;er work 👉 victorrentea.ro/community
Past events on youtube.com/vrentea
Father of 👧👦, servant of a 🐈, weekend gardener 🌼 VictorRentea.ro
3 VictorRentea.ro
a training by
…does one thing well (SRP)
…reads like a story
...was wri3en by someone who cared
Reading a method body does not surprise you
Any fool can write code that a computer understands,
but few programmers know how to write
Clean Code …
Bjarne Stroustrup
inventor of C++
~ Grady Booch
inventor of UML
~ Michael Feathers
Working Effectively with Legacy Code
Martin Fowler
author of Refactoring
~ Ward Cunningham
inventor of Wiki, eXtreme Programming
COMMUNICATE,
DON’T CODE
code that a human can understand
MOV AX, BX
4 VictorRentea.ro
a training by
International Unit of Measure
for Clean Code ?
wtf/min
Acronyms: What a Terrible Failure, What The Feature
VictorRentea.ro
5
2008
1999 2004
a bit of history...
2019
VictorRentea.ro
6
Many Clean Code rules became Obvious
üDon't copy-paste code (DRY principle)
üMethod size < 1 screen
üA boulean parameter can violate SRP
üComments are not needed by expressive code
üCode forma>ng (team stylesheet)
üImmutability = ❤
Duh!!
VictorRentea.ro
7
FIND 5 DIFFERENCES!
This is code copy-pasted 2 years ago 😨
git blame!
Author left
the team 😞
Ask the
business!
They
forgot 😩
Feature?
(only here must cut it)
Bug?
(forgot to cut it here)
VictorRentea.ro
8
Duplicated Code
Is it a bug or a feature?
DRY
Don't Repeat Yourself
becomes horrible when it changes
Code Smells
Today tools can detect
duplicated code
(IDE, Sonar...)
git blame!
Author left
the team 😞
Ask the
business!
They
forgot 😩
9 VictorRentea.ro
a training by
Where did you learn Clean Code from?
• IDE inspec'ons + Sonar/Linters checking code before commit + on CI
• Construc4ve Code Review by Mandatory PR reviewers
• Pair Programming = faster feedback + human interac'on = 🫶
• Books: Clean Code, Refactoring2nd, or Online Catalog: refactoring.guru
• Uncle Bob's Videos: CleanCoders.com (what got me addicted)
• Refactoring Exercises (kata-log.rocks): imitate > explore > +constraints
( x 2 = 😎 )
10 VictorRentea.ro
a training by
#YOLO Developer
# Don't test your code, just ask someone else to do it.
# It works, so why refactor? It's a waste of time! YOLO!
# I don’t always test my code,
but when I do, I do it in production. YOLO!
# Some fix on SO worked but I don't care why! YOLO
git push --no-verify --force -u master YOLO
You Only Live Once !!
11 VictorRentea.ro
a training by
If you don't care about Clean Code,
welcome to
Legacy Code
12 VictorRentea.ro
a training by
FEAR
833| } // end if (leasePlan = null)
// TODO vrentea 2005-03-21 Temporary hack.
Should be removed befor Prod
if (x!=null && x.y!=null && x.y.z!=null)
// When I wrote this only God and I understood it.
Now, only God knows
12
// not sure if we need this,
but to scared to delete
godMethod(... , boolean param12)
THE DEATH OF YOUR CREATIVITY
13 VictorRentea.ro
a training by
I will cover it with
reliable tests
I will NOT
Ship SH*T
I will not harm
a colleague
A task is NOT DONE unless it's CLEAN and TESTED
VictorRentea.ro
14
Plan
Context
Basic Smells
OO Smells
FP Smells
Mastering Code Smells
is the first step towards
Clean Code mastery
VictorRentea.ro
15
“If it stinks, change it.”
— Grandma Beck, discussing childrearing philosophy
Code Smells
Instinct tells you that
this code will hurt you later
VictorRentea.ro
16
Code Complexity is Always Growing
Code Smells
ß 5 lines of code J
VictorRentea.ro
17
Monster Method God Class Many Parameters
Stuff that grew too big
SRP violation
Code Smells
18 VictorRentea.ro
a training by
Functions Shall be SMALL
SmallerthanaSCREEN!
More complex,
è less lines
The max length should be inversely proportional to the complexity. - Linux coding style guide
≈ 20 lines
... or shorter
19 VictorRentea.ro
a training by
Func%on Length Function Depth
20 VictorRentea.ro
a training by
Flat Func;ons
(linear code with no indentaIon)
21 VictorRentea.ro
a training by
Flat Functions Are Easy to Break into Pieces
22 VictorRentea.ro
a training by
Flat Functions Deeply Nested Func;ons
Most Changes
occur here
Fla2en Code
Huge Cycloma4c/Cogni4ve Complexity
A Sonar metric
23 VictorRentea.ro
a training by
foo bar
§if
- Anemic else {} è flip if🔁 è Guard Clause:
- Superficial if è Split in 2 funcIons è
§for
- è Split Loop è use FP (Stream)
§switch
- ... is alone in a funcIon, with one-line / case
§catch
- è Global ExcepIon Handler
Fla+ening Func0ons
if (param == null) return/throw;
f() {
if (cond) {
foo
} else {
bar
}
}
VictorRentea.ro
24
Monster Method God Class Many Parameters
> 20* lines
*Tweak these numbers for your team comfort
Stuff that grew too big
SRP violation
more complex è shorter
Mul@-line Lambda
-> { ...
Code Smells
è Extract Explanatory Method
Extract only if you can
find a good name
depth > 3*
VictorRentea.ro
25 - extract from a clean code presentation proudly presented to us by a colleague in a workshop
VictorRentea.ro
26
Monster Method God Class Many Parameters
> 200* lines ⛔ > 4* ⛔
*Tweak these numbers for your team comfort
Stuff that grew too big
SRP violation
more complex è shorter
Mul@-line Lambda
-> { ...
è Extract reusable
Parameter Object
Code Smells
è Extract Explanatory Method
è Break method (SRP)
Mixed Layers of AbstracTon
Extract only if you can
find a good name
è Compute one inside
depth > 3*
> 20* lines
VictorRentea.ro
27
OO Smells
VictorRentea.ro
28
Data Clumps
data pieces that stick together
Code Smells
VictorRentea.ro
29
Data Clumps
data pieces that sIck together
(String, String, Integer) è Address
Tuple4<String, Long, Long, LocalDate> è PricedProduct
(in a dynamic language): array, {} è class
Lightweight data structures
Java: @Data/@Value, record
Kotlin: data class
Scala: case class
C#: record class
TS: class, interface, type
Code Smells
aka "Missing AbstracIon"
30 VictorRentea.ro
a training by
Discover New Classes
Simplify Code
safer
Constraints
Spread Logic
OOP
Break Large En77es
Fewer Parameters
and more expressive
PracIce!🏋
VictorRentea.ro
31
Value Objects
è[Small] Immutable
- To change an a*ribute => produce a modified copy
èNo persistent idenFty (PK)
- Lack a "con:nuity of change", unlike En::es
- You cannot say "What part of '3' changed when I set it to '4'?"
èEquals uses all fields (and hashCode)
- Money {10, EUR} equals Money {10, EUR}
* Java Records are good way to implement a VO
VictorRentea.ro
32
!!...
int place = player.getPlace() + roll;
if (place !>= 12) {
place -= 12;
}
player.setPlace(place);
!!...
Data Classes
Data structures that contain only data, no behavior
Feature Envy
Logic operaTng heavily on state of another object
Code Smells
Prefer a Rich Model (DDD) over Anemic Structures:
- Logic inside
- Guarding domain constraints
- Null-safe geZers
OOP
Keep behavior next to state
...should go inside that object
player.advance(roll);
VictorRentea.ro
34
Map<Long, List<Long>> map
Map<Long, List<Long>> customerIdToOrderIds
void redeemCoupon(Long couponId, Long customerId, String phone)
what do these mean?
😨
Code Smells
redeemCoupon(dto.custId, request.cid, request.phone)
Caller:
Primi0ve Obsession
=code full of primitives without semantics
DeclaraTon:
35 VictorRentea.ro
a training by
void redeemCoupon(Long couponId, Long customerId, String phone)
Map<Long, List<Long>> map
redeemCoupon(CustomerId cust, CouponId cup, PhoneNumber p)
Micro-Types
Map<CustomerId, List<OrderId>> orders
class CustomerId {
private final Long id;
...get/hash/equals
}
@lombok.Value
class CouponId {
Long id;
}
You can fight the by creaIng
PrimiTve Obsession
record PhoneNumber(String value){
String getAreaCode() {..}
}
Tuple3<CustomerId, RegionId, List<OrderId>>
Type-safe semanTcs
➖ early decision
➖ surprising
➖ can eat memory
Host bits of logic instead of a UTl
👍 Consider for central IDs
that you aggregate by,
put in Map<X, or Tuples
or extra-complex logic
VictorRentea.ro
36
Functional Programming
VictorRentea.ro
37
Functional Programming
Code Smells
= funcQons are first-class ciQzens
I can directly pass behavior: f( -> ...)
instead of f(new Consumer<X>() { void accept(X x) {...} })
We can avoid mutaQng collecQons
newList = list.stream().filter( ->).map( ->).toList();
VictorRentea.ro
38
Code Smells
<T> Consumer<T> uncheck(ThrowingConsumer<T> f) {
return x -> {
try {
f.accept(x);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}; // what does this do ??!
}
.forEach(uncheck(fileWriter::write)); // caller
Higher-Order Func@ons are HARD
avoid it in non-pure funcIonal languages (like Java)
VictorRentea.ro
39
Functional Programming
FuncQons should be .........
Principles
Objects should be ...................
📽 More in my talk: Pure Func0ons and Immutable Objects
No Side Effects (changes)
Same input è Same output
(adj.)
(adj.)
= Programming without side effects
pure
immutable
VictorRentea.ro
40
VictorRentea.ro
41
Long-Lived Mutable Data
Large Immutable Objects
+ multi-threading = 💀
Immutable Objects
Smaller Immutable Objects
Code Smells
... passed in hard-core flows = 💀
➖ Memory churn (due to cloning)
➖ Harder to trace changes
➖ Heavy Builders
VictorRentea.ro
43
VictorRentea.ro
44
!// sum up all active orders
int sum = 0;
orders.stream() !// stream is cool 😎
.filter(order -> order.isActive())
.forEach(order -> {
sum += order.getPrice();
});
effectively final ( )
(lambdas cannot change local variables on stack)
!// AtomicInteger sum 😱
sum.incrementAndGet(price);
!// int[] sum = {0}; 🤨
sum[0] += price;
!// turn local into field 🤢
this.sum += price;
Hacks: Move accumulator on Heap
Impera@ve FP
In FP: avoid Side Effects!
Code Smells
In FP: Compute and Return ✅
int sum = orders.stream()
.filter(Order!::isActive)
.mapToInt(Order!::getPrice)
.sum();
VictorRentea.ro
45
Impera@ve FP
Code Smells
stream.forEach(e -> ...):void
optional.ifPresent(e -> ...):void
👆 Are code smells if used to accumulate data:
❌ .forEach(e -> map.put(e.id(), e)); è .collect(toMap());
❌ .forEach(e -> adder.increment(e)); è.sum();
❌ .ifPresent(e -> list.add(e)); è .flatMap(OpQonal::stream)
OK to use them for external side effects:
✅ .forEach(m -> mailSender.send(m))
✅ .ifPresent(e -> repo.save(e))
VictorRentea.ro
46
Code Smells
for
VictorRentea.ro
47
Code Smells
Loop
for 😮💨
Phew, I only use
while
VictorRentea.ro
48
Loop
Complex Loop
for (e : list) {
results.add(...)
total += ...
sideEffect(e);
}
Accumulator Loop
var results = new ArrayList();
for (e : list) {
results.add(...)
}
for (e : list) {total += ...}
var total = list.stream()..sum/reduce
for (e : list) sideEffect(e);
Split Loop
Refactoring
var results = list.stream()..collect
Violates SRP gathering data via a loop
Code Smells
🤔
list.forEach(this::sideEffect)
VictorRentea.ro
49
for (e : list) {
a(e);
b(e);
}
Split Loop
Refactoring
= List.of(1,2);
for (e : list) a(e);
for (e : list) b(e);
Thoughts? 🤔
😱 Performance Impact?
= Minimal in BE systems👇
measure it : h9ps://github.com/victorrentea/performance-jmh
⚠ Order of opera4ons changes
from: a(1) b(1) a(2) b(2)
into: a(1) a(2) b(1) b(2)
⚠ Mind the flow breakers:
return, throw, break, continue
VictorRentea.ro
50
List<Product> f() {
return orders.stream()
.filter(o -> o.getCreationDate().isAfter(now().minusYears(1)))
.flatMap(o -> o.getOrderLines().stream())
.collect(groupingBy(OrderLine!::getProduct,
summingInt(OrderLine!::getItemCount)))
.entrySet()
.stream()
.filter(e -> e.getValue() !>= 10)
.map(Entry!::getKey)
.filter(p -> !p.isDeleted())
.filter(p -> !productRepo.findByHiddenTrue().contains(p))
.collect(toList());
}
Code Smells
è extract explanatory
variables and methods
eg. aber every 3-4 operators
⚠ In Reac?ve chains, this is in fact
the recommended coding style
Excessive Chaining
🥇 single-expression funcIons
fun x(..) = ..
VictorRentea.ro
51
@Bean
public Function<Flux<LikeEvent>, Flux<LikedPosts!>> onLikeEvent() {
return flux -> flux
.doOnNext(event -> postLikes.put(event.postId(),event.likes()))
.doOnNext(event -> eventSink.tryEmitNext(event))
.map(LikeEvent!::postId)
.buffer(ofSeconds(1))
.flatMap(ids -> postRepo.findAllById(ids)
.map(Post!::title)
.collectList())
.map(LikedPosts!::new)
.onErrorContinue((x,e) ->log.error(STR."Ignore {x} for {e}"))
.doOnNext(message -> log.info("Sending: " + message));
}
☠ Reac4ve Programming ☠
⚠ In ReacTve chains, this is in fact
the recommended coding style
VictorRentea.ro
52
double average = 0;
for (Employee e : employees) {
average += e.getSalary();
}
average = average / employees.size();
1
2
3
4
5
6
Confused Variable
PRO: Don't reassign local variables
sum
sum
Variables should have a single meaning ✅
Code Smells
consider is ≠ 0
sum
The variable name
is lying at this line
double
here it means "sum" Split Variable: create a separate one
VictorRentea.ro
53
Dead Code
VictorRentea.ro
54
Code Smells
Dead Code
Not Referenced
Grayed out in IDE: param, variable, method
è Safe Delete using IDE = full-text search
⚠ sIll used by reflecIon, clients of your lib...
- Code only called from tests is NOT grayed out
Commented Code
è delete it 👍
è park it on a branch
è feature flag: if (bf) ...
Not Reachable
- Unused API endpoint è Monitor URLs
- Code branch impossible to reach
... you believe 😱😬
è Coverage/Profiler?
⚠ Monitor enough Ime (eg ≥ 13 months)
è If recent, ask author ASAP!!
6 month later: If it works, don't touch it!TM
- Shrink solu7on to minimum when it works
eg aker a SO rampage 🤠
if (<impossible>) {
lots of code
}
VictorRentea.ro
55
Ever wrote code an@cipa@ng
a future possible requirement,
or a broader use (eg a library)?
Code Smells
VictorRentea.ro
56
Overengineering
(SpeculaIve Generality)
è KISS Principle
Keep It Short & Simple
Ever wrote code an-cipa-ng
a future possible requirement,
or a broader use (eg a library)?
Code Smells
Simplicity is the
ul7mate sophis7ca7on
(Leonardo DaVinci)
Nothing is harder than
finding a simple solu?on
to a complex problem.
Yes!
- a bright developer
If that future didn't happen,
did you simplify that code?
😞
VictorRentea.ro
57
Java Language Weaknesses
OpTonal<> @Nullable
null
only throw runTme excepTons
Checked Excep@ons
ImmutableList(Guava)
CollecTons.unmodifiableList() List.of (Java 11) .toList() (Java 17)
Mutable Collec@ons
Code Smells Java got its name by people that had no idea if they were awake or asleep due to coffee abuse.
@Data (Lombok)
geZer, seZer, hash/equals, toString
Boilerplate Code
records (Java 17)
VictorRentea.ro
58
Code Smells
most common today (as of 2023)
Monster Method
God Class
Many Parameters
Heavy Lambda
Flags Data Classes
Data Clumps
PrimiFve Obsession
Feature Envy
Overengineering
Dead Code
ImperaFve FP
Complex Loop
Accumulators
Stream Wreck
Mutable Data
Confused Variable
VictorRentea.ro
59
The End
is this
VictorRentea.ro
60
Schedule right now in your team calendar
your first Ensemble Programming Session,
eg. next Fri, from 16:00 – 18:00
(first hour = office 1me = mandatory)
Ø on a ProducIon code snippet
Ø or a Coding Kata ✔, like:
eg hGps://github.com/victorrentea/kata-trivia-java
eg hGps://kata-log.rocks/refactoring
More about me è victorrentea.ro
The game to play:
• What could someone not like about this code? (idenIfy code smells)
• Ways to fix? (pracIce refactoring moves)
• Tradeoffs? (design principles)
• When NOT to fix? (team reality)
61 VictorRentea.ro
a training by
Refactoring Moves
Extract
InliNe
Method 🌟
Local Variable 🌟
Parameter; also: Change Method Signature
Constant
Interface
Superclass; also: Pull Up to super class
Introduce Parameter Object (eg. Interval)
Move Method / Convert to Instance... (in a param or dependency)
Quick Fix for 300+ inspec'ons (Alt-ENTER)
Rename 👑 ShiR-F6
x
IntelliJ Shortcut:
Win/Lin: Ctrl + Alt + <KEY>
Mac: ⌘ + ⌥ + <KEY>
VictorRentea.ro
Stay into
The Light
Join me: victorrentea.ro/community
sourcemaking.com/refactoring
Chapter 1-11 + 17 Chapter 2+3 + links For Java beginners Coding Katas
kata-log.rocks/refactoring
cleancoders.com
videos that inspire 💗 for code
refactoring.guru
Summary arDcle: link
Clean Code - Reading Guide
A Ime-efficient way to get up to speed with Clean Code and Refactoring
VictorRentea.ro
63
Clean Code, Two Decades Later
victor.rentea@gmail.com ♦ ♦ @victorrentea ♦ VictorRentea.ro
Passionate about Clean Code?
Join our community:

More Related Content

What's hot

Spring Data y Mongo DB en un proyecto Real
Spring Data y Mongo DB en un proyecto RealSpring Data y Mongo DB en un proyecto Real
Spring Data y Mongo DB en un proyecto RealDavid Gómez García
 
Clean pragmatic architecture @ devflix
Clean pragmatic architecture @ devflixClean pragmatic architecture @ devflix
Clean pragmatic architecture @ devflixVictor Rentea
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API07.pallav
 
Hexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootHexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootMikalai Alimenkou
 
Software Craftsmanship @Code Camp Festival 2022.pdf
Software Craftsmanship @Code Camp Festival 2022.pdfSoftware Craftsmanship @Code Camp Festival 2022.pdf
Software Craftsmanship @Code Camp Festival 2022.pdfVictor Rentea
 
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010Atlassian
 
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015CODE BLUE
 
All you need to know about JavaScript loading and execution in the browser - ...
All you need to know about JavaScript loading and execution in the browser - ...All you need to know about JavaScript loading and execution in the browser - ...
All you need to know about JavaScript loading and execution in the browser - ...Caelum
 
Building Fast and Scalable Persistence Layers with Spring Data JPA
Building Fast and Scalable Persistence Layers with Spring Data JPABuilding Fast and Scalable Persistence Layers with Spring Data JPA
Building Fast and Scalable Persistence Layers with Spring Data JPAVMware Tanzu
 
Secure Coding 101 - OWASP University of Ottawa Workshop
Secure Coding 101 - OWASP University of Ottawa WorkshopSecure Coding 101 - OWASP University of Ottawa Workshop
Secure Coding 101 - OWASP University of Ottawa WorkshopPaul Ionescu
 
Jenkins multi configuration (matrix)
Jenkins multi configuration (matrix)Jenkins multi configuration (matrix)
Jenkins multi configuration (matrix)Muhammad Zbeedat
 
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint [D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint NAVER D2
 
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization BlueHat Security Conference
 
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...Alex Cachia
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and DjangoMichael Pirnat
 
Inspecting iOS App Traffic with JavaScript - JSOxford - Jan 2018
Inspecting iOS App Traffic with JavaScript - JSOxford - Jan 2018Inspecting iOS App Traffic with JavaScript - JSOxford - Jan 2018
Inspecting iOS App Traffic with JavaScript - JSOxford - Jan 2018Andy Davies
 
SpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting RevisistedSpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting RevisistedWill Schroeder
 
What should a hacker know about WebDav?
What should a hacker know about WebDav?What should a hacker know about WebDav?
What should a hacker know about WebDav?Mikhail Egorov
 
Code Quality in Ruby and Java
Code Quality in Ruby and JavaCode Quality in Ruby and Java
Code Quality in Ruby and JavaSteve Hayes
 

What's hot (20)

Spring Data y Mongo DB en un proyecto Real
Spring Data y Mongo DB en un proyecto RealSpring Data y Mongo DB en un proyecto Real
Spring Data y Mongo DB en un proyecto Real
 
Clean pragmatic architecture @ devflix
Clean pragmatic architecture @ devflixClean pragmatic architecture @ devflix
Clean pragmatic architecture @ devflix
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
ClassLoader Leaks
ClassLoader LeaksClassLoader Leaks
ClassLoader Leaks
 
Hexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootHexagonal architecture with Spring Boot
Hexagonal architecture with Spring Boot
 
Software Craftsmanship @Code Camp Festival 2022.pdf
Software Craftsmanship @Code Camp Festival 2022.pdfSoftware Craftsmanship @Code Camp Festival 2022.pdf
Software Craftsmanship @Code Camp Festival 2022.pdf
 
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
Code Review for Teams Too Busy to Review Code - Atlassian Summit 2010
 
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
XSS Attacks Exploiting XSS Filter by Masato Kinugawa - CODE BLUE 2015
 
All you need to know about JavaScript loading and execution in the browser - ...
All you need to know about JavaScript loading and execution in the browser - ...All you need to know about JavaScript loading and execution in the browser - ...
All you need to know about JavaScript loading and execution in the browser - ...
 
Building Fast and Scalable Persistence Layers with Spring Data JPA
Building Fast and Scalable Persistence Layers with Spring Data JPABuilding Fast and Scalable Persistence Layers with Spring Data JPA
Building Fast and Scalable Persistence Layers with Spring Data JPA
 
Secure Coding 101 - OWASP University of Ottawa Workshop
Secure Coding 101 - OWASP University of Ottawa WorkshopSecure Coding 101 - OWASP University of Ottawa Workshop
Secure Coding 101 - OWASP University of Ottawa Workshop
 
Jenkins multi configuration (matrix)
Jenkins multi configuration (matrix)Jenkins multi configuration (matrix)
Jenkins multi configuration (matrix)
 
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint [D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint
[D2] java 애플리케이션 트러블 슈팅 사례 & pinpoint
 
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
BlueHat v17 || Dangerous Contents - Securing .Net Deserialization
 
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...
No Onions, No Tiers - An Introduction to Vertical Slice Architecture by Bill ...
 
Web Development with Python and Django
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
 
Inspecting iOS App Traffic with JavaScript - JSOxford - Jan 2018
Inspecting iOS App Traffic with JavaScript - JSOxford - Jan 2018Inspecting iOS App Traffic with JavaScript - JSOxford - Jan 2018
Inspecting iOS App Traffic with JavaScript - JSOxford - Jan 2018
 
SpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting RevisistedSpecterOps Webinar Week - Kerberoasting Revisisted
SpecterOps Webinar Week - Kerberoasting Revisisted
 
What should a hacker know about WebDav?
What should a hacker know about WebDav?What should a hacker know about WebDav?
What should a hacker know about WebDav?
 
Code Quality in Ruby and Java
Code Quality in Ruby and JavaCode Quality in Ruby and Java
Code Quality in Ruby and Java
 

Similar to Clean Code @Voxxed Days Cluj 2023 - opening Keynote

The Art of Clean code
The Art of Clean codeThe Art of Clean code
The Art of Clean codeVictor Rentea
 
Clean Code - The Next Chapter
Clean Code - The Next ChapterClean Code - The Next Chapter
Clean Code - The Next ChapterVictor Rentea
 
Richard wartell malware is hard. let's go shopping!!
Richard wartell   malware is hard.  let's go shopping!!Richard wartell   malware is hard.  let's go shopping!!
Richard wartell malware is hard. let's go shopping!!Shakacon
 
Consequences of using the Copy-Paste method in C++ programming and how to dea...
Consequences of using the Copy-Paste method in C++ programming and how to dea...Consequences of using the Copy-Paste method in C++ programming and how to dea...
Consequences of using the Copy-Paste method in C++ programming and how to dea...Andrey Karpov
 
Writing clean code in C# and .NET
Writing clean code in C# and .NETWriting clean code in C# and .NET
Writing clean code in C# and .NETDror Helper
 
Monitoring a program that monitors computer networks
Monitoring a program that monitors computer networksMonitoring a program that monitors computer networks
Monitoring a program that monitors computer networksAndrey Karpov
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DMithun Hunsur
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindAndreas Czakaj
 
Refactoring Games - 15 things to do after Extract Method
Refactoring Games - 15 things to do after Extract MethodRefactoring Games - 15 things to do after Extract Method
Refactoring Games - 15 things to do after Extract MethodVictor Rentea
 
How to be a smart contract engineer
How to be a smart contract engineerHow to be a smart contract engineer
How to be a smart contract engineerOded Noam
 
refactoring code by clean code rules
refactoring code by clean code rulesrefactoring code by clean code rules
refactoring code by clean code rulessaber tabatabaee
 
Clean architecture - Protecting the Domain
Clean architecture - Protecting the DomainClean architecture - Protecting the Domain
Clean architecture - Protecting the DomainVictor Rentea
 
Refactoring blockers and code smells @jNation 2021
Refactoring   blockers and code smells @jNation 2021Refactoring   blockers and code smells @jNation 2021
Refactoring blockers and code smells @jNation 2021Victor Rentea
 
How to avoid bugs using modern C++
How to avoid bugs using modern C++How to avoid bugs using modern C++
How to avoid bugs using modern C++PVS-Studio
 
2018 01-29 - brewbox - refactoring. sempre, senza pietà
2018 01-29 - brewbox - refactoring. sempre, senza pietà2018 01-29 - brewbox - refactoring. sempre, senza pietà
2018 01-29 - brewbox - refactoring. sempre, senza pietàRoberto Albertini
 

Similar to Clean Code @Voxxed Days Cluj 2023 - opening Keynote (20)

The Art of Clean code
The Art of Clean codeThe Art of Clean code
The Art of Clean code
 
Clean Code - The Next Chapter
Clean Code - The Next ChapterClean Code - The Next Chapter
Clean Code - The Next Chapter
 
Richard wartell malware is hard. let's go shopping!!
Richard wartell   malware is hard.  let's go shopping!!Richard wartell   malware is hard.  let's go shopping!!
Richard wartell malware is hard. let's go shopping!!
 
Tech talks#6: Code Refactoring
Tech talks#6: Code RefactoringTech talks#6: Code Refactoring
Tech talks#6: Code Refactoring
 
Consequences of using the Copy-Paste method in C++ programming and how to dea...
Consequences of using the Copy-Paste method in C++ programming and how to dea...Consequences of using the Copy-Paste method in C++ programming and how to dea...
Consequences of using the Copy-Paste method in C++ programming and how to dea...
 
Writing clean code in C# and .NET
Writing clean code in C# and .NETWriting clean code in C# and .NET
Writing clean code in C# and .NET
 
Wtf per lineofcode
Wtf per lineofcodeWtf per lineofcode
Wtf per lineofcode
 
Monitoring a program that monitors computer networks
Monitoring a program that monitors computer networksMonitoring a program that monitors computer networks
Monitoring a program that monitors computer networks
 
Clean Code 2
Clean Code 2Clean Code 2
Clean Code 2
 
Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 
Skiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in DSkiron - Experiments in CPU Design in D
Skiron - Experiments in CPU Design in D
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mind
 
Refactoring Games - 15 things to do after Extract Method
Refactoring Games - 15 things to do after Extract MethodRefactoring Games - 15 things to do after Extract Method
Refactoring Games - 15 things to do after Extract Method
 
How to be a smart contract engineer
How to be a smart contract engineerHow to be a smart contract engineer
How to be a smart contract engineer
 
refactoring code by clean code rules
refactoring code by clean code rulesrefactoring code by clean code rules
refactoring code by clean code rules
 
Clean code and code smells
Clean code and code smellsClean code and code smells
Clean code and code smells
 
Clean architecture - Protecting the Domain
Clean architecture - Protecting the DomainClean architecture - Protecting the Domain
Clean architecture - Protecting the Domain
 
Refactoring blockers and code smells @jNation 2021
Refactoring   blockers and code smells @jNation 2021Refactoring   blockers and code smells @jNation 2021
Refactoring blockers and code smells @jNation 2021
 
How to avoid bugs using modern C++
How to avoid bugs using modern C++How to avoid bugs using modern C++
How to avoid bugs using modern C++
 
2018 01-29 - brewbox - refactoring. sempre, senza pietà
2018 01-29 - brewbox - refactoring. sempre, senza pietà2018 01-29 - brewbox - refactoring. sempre, senza pietà
2018 01-29 - brewbox - refactoring. sempre, senza pietà
 

More from Victor Rentea

Distributed Consistency.pdf
Distributed Consistency.pdfDistributed Consistency.pdf
Distributed Consistency.pdfVictor Rentea
 
Testing Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdfTesting Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdfVictor Rentea
 
From Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptxFrom Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptxVictor Rentea
 
Profiling your Java Application
Profiling your Java ApplicationProfiling your Java Application
Profiling your Java ApplicationVictor Rentea
 
Unit testing - 9 design hints
Unit testing - 9 design hintsUnit testing - 9 design hints
Unit testing - 9 design hintsVictor Rentea
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipVictor Rentea
 
Hibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the MagicHibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the MagicVictor Rentea
 
Integration testing with spring @JAX Mainz
Integration testing with spring @JAX MainzIntegration testing with spring @JAX Mainz
Integration testing with spring @JAX MainzVictor Rentea
 
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021Victor Rentea
 
Integration testing with spring @snow one
Integration testing with spring @snow oneIntegration testing with spring @snow one
Integration testing with spring @snow oneVictor Rentea
 
Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Victor Rentea
 
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...Victor Rentea
 
Don't Be Mocked by your Mocks - Best Practices using Mocks
Don't Be Mocked by your Mocks - Best Practices using MocksDon't Be Mocked by your Mocks - Best Practices using Mocks
Don't Be Mocked by your Mocks - Best Practices using MocksVictor Rentea
 
Pure Functions and Immutable Objects
Pure Functions and Immutable ObjectsPure Functions and Immutable Objects
Pure Functions and Immutable ObjectsVictor Rentea
 
Definitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in JavaDefinitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in JavaVictor Rentea
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipVictor Rentea
 
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...Victor Rentea
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignVictor Rentea
 

More from Victor Rentea (20)

Distributed Consistency.pdf
Distributed Consistency.pdfDistributed Consistency.pdf
Distributed Consistency.pdf
 
Testing Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdfTesting Microservices @DevoxxBE 23.pdf
Testing Microservices @DevoxxBE 23.pdf
 
From Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptxFrom Web to Flux @DevoxxBE 2023.pptx
From Web to Flux @DevoxxBE 2023.pptx
 
Profiling your Java Application
Profiling your Java ApplicationProfiling your Java Application
Profiling your Java Application
 
OAuth in the Wild
OAuth in the WildOAuth in the Wild
OAuth in the Wild
 
Unit testing - 9 design hints
Unit testing - 9 design hintsUnit testing - 9 design hints
Unit testing - 9 design hints
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software Craftsmanship
 
Hibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the MagicHibernate and Spring - Unleash the Magic
Hibernate and Spring - Unleash the Magic
 
Integration testing with spring @JAX Mainz
Integration testing with spring @JAX MainzIntegration testing with spring @JAX Mainz
Integration testing with spring @JAX Mainz
 
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
The Proxy Fairy and the Magic of Spring @JAX Mainz 2021
 
Integration testing with spring @snow one
Integration testing with spring @snow oneIntegration testing with spring @snow one
Integration testing with spring @snow one
 
Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021
 
TDD Mantra
TDD MantraTDD Mantra
TDD Mantra
 
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
Definitive Guide to Working With Exceptions in Java - takj at Java Champions ...
 
Don't Be Mocked by your Mocks - Best Practices using Mocks
Don't Be Mocked by your Mocks - Best Practices using MocksDon't Be Mocked by your Mocks - Best Practices using Mocks
Don't Be Mocked by your Mocks - Best Practices using Mocks
 
Pure Functions and Immutable Objects
Pure Functions and Immutable ObjectsPure Functions and Immutable Objects
Pure Functions and Immutable Objects
 
Definitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in JavaDefinitive Guide to Working With Exceptions in Java
Definitive Guide to Working With Exceptions in Java
 
Extreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software CraftsmanshipExtreme Professionalism - Software Craftsmanship
Extreme Professionalism - Software Craftsmanship
 
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
Engaging Isolation - What I've Learned Delivering 250 Webinar Hours during CO...
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable Design
 

Recently uploaded

Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 

Recently uploaded (20)

Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 

Clean Code @Voxxed Days Cluj 2023 - opening Keynote

  • 1. VictorRentea.ro 1 Clean Code, Two Decades Later victor.rentea@gmail.com ♦ ♦ @victorrentea ♦ VictorRentea.ro
  • 2. victorrentea.ro/training-offer 👋 Hi, I'm Victor Rentea 🇷🇴 PhD(CS) Java Champion, 18 years of code, 10 years of teaching Consultant & Trainer at 120+ companies: ❤ Clean Code, Architecture, Unit Tes3ng 🛠 Spring, Hibernate, Reac3ve ⚡ Java Performance, Secure Coding EducaDve Conference Talks on YouTube Founder of European So<ware Cra<ers Community (6K members) 🔥 Free 1-hour webinars, a;er work 👉 victorrentea.ro/community Past events on youtube.com/vrentea Father of 👧👦, servant of a 🐈, weekend gardener 🌼 VictorRentea.ro
  • 3. 3 VictorRentea.ro a training by …does one thing well (SRP) …reads like a story ...was wri3en by someone who cared Reading a method body does not surprise you Any fool can write code that a computer understands, but few programmers know how to write Clean Code … Bjarne Stroustrup inventor of C++ ~ Grady Booch inventor of UML ~ Michael Feathers Working Effectively with Legacy Code Martin Fowler author of Refactoring ~ Ward Cunningham inventor of Wiki, eXtreme Programming COMMUNICATE, DON’T CODE code that a human can understand MOV AX, BX
  • 4. 4 VictorRentea.ro a training by International Unit of Measure for Clean Code ? wtf/min Acronyms: What a Terrible Failure, What The Feature
  • 6. VictorRentea.ro 6 Many Clean Code rules became Obvious üDon't copy-paste code (DRY principle) üMethod size < 1 screen üA boulean parameter can violate SRP üComments are not needed by expressive code üCode forma>ng (team stylesheet) üImmutability = ❤ Duh!!
  • 7. VictorRentea.ro 7 FIND 5 DIFFERENCES! This is code copy-pasted 2 years ago 😨 git blame! Author left the team 😞 Ask the business! They forgot 😩 Feature? (only here must cut it) Bug? (forgot to cut it here)
  • 8. VictorRentea.ro 8 Duplicated Code Is it a bug or a feature? DRY Don't Repeat Yourself becomes horrible when it changes Code Smells Today tools can detect duplicated code (IDE, Sonar...) git blame! Author left the team 😞 Ask the business! They forgot 😩
  • 9. 9 VictorRentea.ro a training by Where did you learn Clean Code from? • IDE inspec'ons + Sonar/Linters checking code before commit + on CI • Construc4ve Code Review by Mandatory PR reviewers • Pair Programming = faster feedback + human interac'on = 🫶 • Books: Clean Code, Refactoring2nd, or Online Catalog: refactoring.guru • Uncle Bob's Videos: CleanCoders.com (what got me addicted) • Refactoring Exercises (kata-log.rocks): imitate > explore > +constraints ( x 2 = 😎 )
  • 10. 10 VictorRentea.ro a training by #YOLO Developer # Don't test your code, just ask someone else to do it. # It works, so why refactor? It's a waste of time! YOLO! # I don’t always test my code, but when I do, I do it in production. YOLO! # Some fix on SO worked but I don't care why! YOLO git push --no-verify --force -u master YOLO You Only Live Once !!
  • 11. 11 VictorRentea.ro a training by If you don't care about Clean Code, welcome to Legacy Code
  • 12. 12 VictorRentea.ro a training by FEAR 833| } // end if (leasePlan = null) // TODO vrentea 2005-03-21 Temporary hack. Should be removed befor Prod if (x!=null && x.y!=null && x.y.z!=null) // When I wrote this only God and I understood it. Now, only God knows 12 // not sure if we need this, but to scared to delete godMethod(... , boolean param12) THE DEATH OF YOUR CREATIVITY
  • 13. 13 VictorRentea.ro a training by I will cover it with reliable tests I will NOT Ship SH*T I will not harm a colleague A task is NOT DONE unless it's CLEAN and TESTED
  • 14. VictorRentea.ro 14 Plan Context Basic Smells OO Smells FP Smells Mastering Code Smells is the first step towards Clean Code mastery
  • 15. VictorRentea.ro 15 “If it stinks, change it.” — Grandma Beck, discussing childrearing philosophy Code Smells Instinct tells you that this code will hurt you later
  • 16. VictorRentea.ro 16 Code Complexity is Always Growing Code Smells ß 5 lines of code J
  • 17. VictorRentea.ro 17 Monster Method God Class Many Parameters Stuff that grew too big SRP violation Code Smells
  • 18. 18 VictorRentea.ro a training by Functions Shall be SMALL SmallerthanaSCREEN! More complex, è less lines The max length should be inversely proportional to the complexity. - Linux coding style guide ≈ 20 lines ... or shorter
  • 19. 19 VictorRentea.ro a training by Func%on Length Function Depth
  • 20. 20 VictorRentea.ro a training by Flat Func;ons (linear code with no indentaIon)
  • 21. 21 VictorRentea.ro a training by Flat Functions Are Easy to Break into Pieces
  • 22. 22 VictorRentea.ro a training by Flat Functions Deeply Nested Func;ons Most Changes occur here Fla2en Code Huge Cycloma4c/Cogni4ve Complexity A Sonar metric
  • 23. 23 VictorRentea.ro a training by foo bar §if - Anemic else {} è flip if🔁 è Guard Clause: - Superficial if è Split in 2 funcIons è §for - è Split Loop è use FP (Stream) §switch - ... is alone in a funcIon, with one-line / case §catch - è Global ExcepIon Handler Fla+ening Func0ons if (param == null) return/throw; f() { if (cond) { foo } else { bar } }
  • 24. VictorRentea.ro 24 Monster Method God Class Many Parameters > 20* lines *Tweak these numbers for your team comfort Stuff that grew too big SRP violation more complex è shorter Mul@-line Lambda -> { ... Code Smells è Extract Explanatory Method Extract only if you can find a good name depth > 3*
  • 25. VictorRentea.ro 25 - extract from a clean code presentation proudly presented to us by a colleague in a workshop
  • 26. VictorRentea.ro 26 Monster Method God Class Many Parameters > 200* lines ⛔ > 4* ⛔ *Tweak these numbers for your team comfort Stuff that grew too big SRP violation more complex è shorter Mul@-line Lambda -> { ... è Extract reusable Parameter Object Code Smells è Extract Explanatory Method è Break method (SRP) Mixed Layers of AbstracTon Extract only if you can find a good name è Compute one inside depth > 3* > 20* lines
  • 28. VictorRentea.ro 28 Data Clumps data pieces that stick together Code Smells
  • 29. VictorRentea.ro 29 Data Clumps data pieces that sIck together (String, String, Integer) è Address Tuple4<String, Long, Long, LocalDate> è PricedProduct (in a dynamic language): array, {} è class Lightweight data structures Java: @Data/@Value, record Kotlin: data class Scala: case class C#: record class TS: class, interface, type Code Smells aka "Missing AbstracIon"
  • 30. 30 VictorRentea.ro a training by Discover New Classes Simplify Code safer Constraints Spread Logic OOP Break Large En77es Fewer Parameters and more expressive PracIce!🏋
  • 31. VictorRentea.ro 31 Value Objects è[Small] Immutable - To change an a*ribute => produce a modified copy èNo persistent idenFty (PK) - Lack a "con:nuity of change", unlike En::es - You cannot say "What part of '3' changed when I set it to '4'?" èEquals uses all fields (and hashCode) - Money {10, EUR} equals Money {10, EUR} * Java Records are good way to implement a VO
  • 32. VictorRentea.ro 32 !!... int place = player.getPlace() + roll; if (place !>= 12) { place -= 12; } player.setPlace(place); !!... Data Classes Data structures that contain only data, no behavior Feature Envy Logic operaTng heavily on state of another object Code Smells Prefer a Rich Model (DDD) over Anemic Structures: - Logic inside - Guarding domain constraints - Null-safe geZers OOP Keep behavior next to state ...should go inside that object player.advance(roll);
  • 33. VictorRentea.ro 34 Map<Long, List<Long>> map Map<Long, List<Long>> customerIdToOrderIds void redeemCoupon(Long couponId, Long customerId, String phone) what do these mean? 😨 Code Smells redeemCoupon(dto.custId, request.cid, request.phone) Caller: Primi0ve Obsession =code full of primitives without semantics DeclaraTon:
  • 34. 35 VictorRentea.ro a training by void redeemCoupon(Long couponId, Long customerId, String phone) Map<Long, List<Long>> map redeemCoupon(CustomerId cust, CouponId cup, PhoneNumber p) Micro-Types Map<CustomerId, List<OrderId>> orders class CustomerId { private final Long id; ...get/hash/equals } @lombok.Value class CouponId { Long id; } You can fight the by creaIng PrimiTve Obsession record PhoneNumber(String value){ String getAreaCode() {..} } Tuple3<CustomerId, RegionId, List<OrderId>> Type-safe semanTcs ➖ early decision ➖ surprising ➖ can eat memory Host bits of logic instead of a UTl 👍 Consider for central IDs that you aggregate by, put in Map<X, or Tuples or extra-complex logic
  • 36. VictorRentea.ro 37 Functional Programming Code Smells = funcQons are first-class ciQzens I can directly pass behavior: f( -> ...) instead of f(new Consumer<X>() { void accept(X x) {...} }) We can avoid mutaQng collecQons newList = list.stream().filter( ->).map( ->).toList();
  • 37. VictorRentea.ro 38 Code Smells <T> Consumer<T> uncheck(ThrowingConsumer<T> f) { return x -> { try { f.accept(x); } catch (Throwable e) { throw new RuntimeException(e); } }; // what does this do ??! } .forEach(uncheck(fileWriter::write)); // caller Higher-Order Func@ons are HARD avoid it in non-pure funcIonal languages (like Java)
  • 38. VictorRentea.ro 39 Functional Programming FuncQons should be ......... Principles Objects should be ................... 📽 More in my talk: Pure Func0ons and Immutable Objects No Side Effects (changes) Same input è Same output (adj.) (adj.) = Programming without side effects pure immutable
  • 40. VictorRentea.ro 41 Long-Lived Mutable Data Large Immutable Objects + multi-threading = 💀 Immutable Objects Smaller Immutable Objects Code Smells ... passed in hard-core flows = 💀 ➖ Memory churn (due to cloning) ➖ Harder to trace changes ➖ Heavy Builders
  • 42. VictorRentea.ro 44 !// sum up all active orders int sum = 0; orders.stream() !// stream is cool 😎 .filter(order -> order.isActive()) .forEach(order -> { sum += order.getPrice(); }); effectively final ( ) (lambdas cannot change local variables on stack) !// AtomicInteger sum 😱 sum.incrementAndGet(price); !// int[] sum = {0}; 🤨 sum[0] += price; !// turn local into field 🤢 this.sum += price; Hacks: Move accumulator on Heap Impera@ve FP In FP: avoid Side Effects! Code Smells In FP: Compute and Return ✅ int sum = orders.stream() .filter(Order!::isActive) .mapToInt(Order!::getPrice) .sum();
  • 43. VictorRentea.ro 45 Impera@ve FP Code Smells stream.forEach(e -> ...):void optional.ifPresent(e -> ...):void 👆 Are code smells if used to accumulate data: ❌ .forEach(e -> map.put(e.id(), e)); è .collect(toMap()); ❌ .forEach(e -> adder.increment(e)); è.sum(); ❌ .ifPresent(e -> list.add(e)); è .flatMap(OpQonal::stream) OK to use them for external side effects: ✅ .forEach(m -> mailSender.send(m)) ✅ .ifPresent(e -> repo.save(e))
  • 46. VictorRentea.ro 48 Loop Complex Loop for (e : list) { results.add(...) total += ... sideEffect(e); } Accumulator Loop var results = new ArrayList(); for (e : list) { results.add(...) } for (e : list) {total += ...} var total = list.stream()..sum/reduce for (e : list) sideEffect(e); Split Loop Refactoring var results = list.stream()..collect Violates SRP gathering data via a loop Code Smells 🤔 list.forEach(this::sideEffect)
  • 47. VictorRentea.ro 49 for (e : list) { a(e); b(e); } Split Loop Refactoring = List.of(1,2); for (e : list) a(e); for (e : list) b(e); Thoughts? 🤔 😱 Performance Impact? = Minimal in BE systems👇 measure it : h9ps://github.com/victorrentea/performance-jmh ⚠ Order of opera4ons changes from: a(1) b(1) a(2) b(2) into: a(1) a(2) b(1) b(2) ⚠ Mind the flow breakers: return, throw, break, continue
  • 48. VictorRentea.ro 50 List<Product> f() { return orders.stream() .filter(o -> o.getCreationDate().isAfter(now().minusYears(1))) .flatMap(o -> o.getOrderLines().stream()) .collect(groupingBy(OrderLine!::getProduct, summingInt(OrderLine!::getItemCount))) .entrySet() .stream() .filter(e -> e.getValue() !>= 10) .map(Entry!::getKey) .filter(p -> !p.isDeleted()) .filter(p -> !productRepo.findByHiddenTrue().contains(p)) .collect(toList()); } Code Smells è extract explanatory variables and methods eg. aber every 3-4 operators ⚠ In Reac?ve chains, this is in fact the recommended coding style Excessive Chaining 🥇 single-expression funcIons fun x(..) = ..
  • 49. VictorRentea.ro 51 @Bean public Function<Flux<LikeEvent>, Flux<LikedPosts!>> onLikeEvent() { return flux -> flux .doOnNext(event -> postLikes.put(event.postId(),event.likes())) .doOnNext(event -> eventSink.tryEmitNext(event)) .map(LikeEvent!::postId) .buffer(ofSeconds(1)) .flatMap(ids -> postRepo.findAllById(ids) .map(Post!::title) .collectList()) .map(LikedPosts!::new) .onErrorContinue((x,e) ->log.error(STR."Ignore {x} for {e}")) .doOnNext(message -> log.info("Sending: " + message)); } ☠ Reac4ve Programming ☠ ⚠ In ReacTve chains, this is in fact the recommended coding style
  • 50. VictorRentea.ro 52 double average = 0; for (Employee e : employees) { average += e.getSalary(); } average = average / employees.size(); 1 2 3 4 5 6 Confused Variable PRO: Don't reassign local variables sum sum Variables should have a single meaning ✅ Code Smells consider is ≠ 0 sum The variable name is lying at this line double here it means "sum" Split Variable: create a separate one
  • 52. VictorRentea.ro 54 Code Smells Dead Code Not Referenced Grayed out in IDE: param, variable, method è Safe Delete using IDE = full-text search ⚠ sIll used by reflecIon, clients of your lib... - Code only called from tests is NOT grayed out Commented Code è delete it 👍 è park it on a branch è feature flag: if (bf) ... Not Reachable - Unused API endpoint è Monitor URLs - Code branch impossible to reach ... you believe 😱😬 è Coverage/Profiler? ⚠ Monitor enough Ime (eg ≥ 13 months) è If recent, ask author ASAP!! 6 month later: If it works, don't touch it!TM - Shrink solu7on to minimum when it works eg aker a SO rampage 🤠 if (<impossible>) { lots of code }
  • 53. VictorRentea.ro 55 Ever wrote code an@cipa@ng a future possible requirement, or a broader use (eg a library)? Code Smells
  • 54. VictorRentea.ro 56 Overengineering (SpeculaIve Generality) è KISS Principle Keep It Short & Simple Ever wrote code an-cipa-ng a future possible requirement, or a broader use (eg a library)? Code Smells Simplicity is the ul7mate sophis7ca7on (Leonardo DaVinci) Nothing is harder than finding a simple solu?on to a complex problem. Yes! - a bright developer If that future didn't happen, did you simplify that code? 😞
  • 55. VictorRentea.ro 57 Java Language Weaknesses OpTonal<> @Nullable null only throw runTme excepTons Checked Excep@ons ImmutableList(Guava) CollecTons.unmodifiableList() List.of (Java 11) .toList() (Java 17) Mutable Collec@ons Code Smells Java got its name by people that had no idea if they were awake or asleep due to coffee abuse. @Data (Lombok) geZer, seZer, hash/equals, toString Boilerplate Code records (Java 17)
  • 56. VictorRentea.ro 58 Code Smells most common today (as of 2023) Monster Method God Class Many Parameters Heavy Lambda Flags Data Classes Data Clumps PrimiFve Obsession Feature Envy Overengineering Dead Code ImperaFve FP Complex Loop Accumulators Stream Wreck Mutable Data Confused Variable
  • 58. VictorRentea.ro 60 Schedule right now in your team calendar your first Ensemble Programming Session, eg. next Fri, from 16:00 – 18:00 (first hour = office 1me = mandatory) Ø on a ProducIon code snippet Ø or a Coding Kata ✔, like: eg hGps://github.com/victorrentea/kata-trivia-java eg hGps://kata-log.rocks/refactoring More about me è victorrentea.ro The game to play: • What could someone not like about this code? (idenIfy code smells) • Ways to fix? (pracIce refactoring moves) • Tradeoffs? (design principles) • When NOT to fix? (team reality)
  • 59. 61 VictorRentea.ro a training by Refactoring Moves Extract InliNe Method 🌟 Local Variable 🌟 Parameter; also: Change Method Signature Constant Interface Superclass; also: Pull Up to super class Introduce Parameter Object (eg. Interval) Move Method / Convert to Instance... (in a param or dependency) Quick Fix for 300+ inspec'ons (Alt-ENTER) Rename 👑 ShiR-F6 x IntelliJ Shortcut: Win/Lin: Ctrl + Alt + <KEY> Mac: ⌘ + ⌥ + <KEY>
  • 60. VictorRentea.ro Stay into The Light Join me: victorrentea.ro/community sourcemaking.com/refactoring Chapter 1-11 + 17 Chapter 2+3 + links For Java beginners Coding Katas kata-log.rocks/refactoring cleancoders.com videos that inspire 💗 for code refactoring.guru Summary arDcle: link Clean Code - Reading Guide A Ime-efficient way to get up to speed with Clean Code and Refactoring
  • 61. VictorRentea.ro 63 Clean Code, Two Decades Later victor.rentea@gmail.com ♦ ♦ @victorrentea ♦ VictorRentea.ro Passionate about Clean Code? Join our community: