Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Elegant Objects and Cactoos
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Filipe Freire
December 21, 2017
Programming
420
0
Share
Elegant Objects and Cactoos
Overview of the EO paradigm and small overview of the Cactoos library for Porto Codes Meetup
Filipe Freire
December 21, 2017
More Decks by Filipe Freire
See All by Filipe Freire
Deep Testing
filipe
0
160
Finding Tranquility
filipe
0
140
Quality Foundations
filipe
0
170
Tacit CSS Framework
filipe
0
460
Quality from the start
filipe
0
190
Tacit
filipe
0
220
Waiting is boring
filipe
0
760
You don't need a DevOps to "be DevOps"
filipe
0
390
Other Decks in Programming
See All in Programming
継続的な負荷検証を目指して
pyama86
3
1.1k
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
430
Skillは並べた。動かなかった。契約で繋いだ。— 65個のSkillから、自走する開発サイクルへ
junholee
0
510
AgentCore Optimizationを始めよう!
licux
3
240
【ディップ|26年新卒研修資料】TDD実装演習
dip_tech
PRO
0
180
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
700
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
170
ハーネスエンジニアリングとは?
kinopeee
13
7k
Kingdom of the Machine
yui_knk
2
1.5k
WebAssembly を読み込むベストプラクティス 2026年春版 / Best Practices for Loading WebAssembly (Spring 2026)
petamoriken
5
1.1k
Building on Bluesky's AT Protocol with Ruby
mackuba
0
120
From Formal Specification to Property Based Test
ohbarye
0
2.5k
Featured
See All Featured
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
Unsuck your backbone
ammeep
672
58k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
140
The untapped power of vector embeddings
frankvandijk
2
1.7k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
200
A Modern Web Designer's Workflow
chriscoyier
698
190k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
460
Game over? The fight for quality and originality in the time of robots
wayneb77
1
170
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
Paper Plane
katiecoart
PRO
1
50k
Transcript
Elegant objects & Cactoos Filipe Freire 21 December 2017
Quick intro Learner, tester, developer, husband OSS contributor 2y work
as a “coding” tester 1y work as a developer Currently @ filfreire.com 2
Elegant Objects 3
It’s an OOP paradigm 4
Book Yegor Bugayenko @yegor256 www.yegor256.com 5
Book Yegor Bugayenko @yegor256 www.yegor256.com Set of recommendations: - Cleaner
code - Better classes - Visible architecture 6
Disclaimer: You can find out more at yegor256.com Youtube @yegor256
and on the EO books. 7
So, what are the recommendations? 8
Getters Setters Mutable objects Static methods Annotations Data Objects Type
Casting Etc. 9
Getters Setters Mutable objects Static methods Annotations Data Objects Type
Casting Etc. 10
Don’t treat objects as data structures bags of data.
Ever. 11
Maintainability > everything else 12
“Objects as living beings” Birth Working life Retirement 13
Some examples… 14
Birth 15
Code Free Constructors 16
17
“Object’s name != job title” 18
Object’s name != job title Meaning: Avoid the use of
“-ER” 19
Helper, Handler, Writer, Reader, Converter, Observer, Listener, Sorter, Encoder, Decoder,
… 20
Helper, Handler, Writer, Reader, Converter, Observer, Listener, Sorter, Encoder, Decoder,
… 21
An object isn’t: 1) A link between worlds 2) A
collection of procedures plus data 22
An object is: 1) Self-sufficient 2) Representative of encapsulated
data 23
A Finder of Prime Numbers vs A List of numbers
that returns only primes 24
Education & Work life 25
No Getters and Setters. Not even once. 26
No Getters and Setters ?! ?! 27
Again, don’t treat objects as bags of data. Ever.
28
Computer-style: 29
Human-style: 30
“An object works by contracts” 31
“An object works by contracts” Always use interfaces 32
Example “I want results for a Tennis match” Tennis_31Feb.xlsx TENNIS.txt
tennis_res.json Sources: … 33
Example “I want results for a Tennis match” Tennis_31Feb.xlsx TENNIS.txt
tennis_res.json Sources: … ExcelTennisMatch TextTennisMatch JsonTennisMatch 34
Example “I want results for a Tennis match” ExcelTennisMatch TextTennisMatch
JsonTennisMatch TennisMatch GameMatch implement extends 35
Excel, Text, Json, etc. Contract stays the same More Decoupling
and more Maintainability 36
“A good object should never change his encapsulated state.” 37
“A good object should never change his encapsulated state.” 38
Be immutable
This can change State is the same 39
Some benefits Thread Safety Avoiding Temporal Coupling Avoiding side effects
Avoiding identity mutability (more at http://yegor256.com/2014/06/09/objects-should-be-immutable.html) 40
Retirement 41
Don’t accept null arguments Don’t return null 42
- Hello, is it a software department? - Yes. -
Let me talk to your employee "Jeffrey" please. - Hold the line please... - Hello. - … 43
- Hello, is it a software department? - Yes. -
Let me talk to your employee "Jeffrey" please. - Hold the line please... - Hello. - Are you NULL? (more at http://www.yegor256.com/2014/05/13/why-null-is-bad.html) 44
There’s more to it, Let’s save it for another talk
45
https://github.com/yegor256/cactoos 46
Useful building blocks from Guava, Apache Commons, JDK + EO
paradigm 47
Meaning… No null No code in constructors No getters and
setters No mutable objects No static methods, not even private ones (among other stuff) 48
Example 1 49
Example 2 50
Example 3 51
Summing up 52
Maintainability 53
–W. Edwards Deming "Build quality into the product rather than
trying to test it in later." 54
Quality from the start Force strict control of code quality.
Ex: Static Analysis -> mandatory 55
Thank you. Questions? filfreire filrfreire filfreire.com 56