SlideShare a Scribd company logo
1 of 10
Download to read offline
Minimalism
A Practical Guide to Writing Less Code
kevlin@curbralan.com
Kevlin Henney
JAOO 2002 http://www.curbralan.com 2
Minimalism
• A movement in art, architecture, music and
interior design
• More generally, a tendency towards less
rather than more
Seeking the minimum, the lowest point on a curve
It isn't necessary for a work to have a lot of things to look at, to compare, to analyse
one by one, to contemplate. The thing as a whole, its quality as a whole, is what is
interesting. The main things are alone and are more intense, clear and powerful.
Donald Judd
JAOO 2002 http://www.curbralan.com 3
Less Code, More Software
• Creeping featurism and code verbosity do not
add to the used functionality of the software
Functionality is weakly correlated with the
number of lines of code written
• On the other hand, minimalism is not the
reduction of source code to line noise
Code should be sufficient and fit for purpose
The difference between a good and a poor architect is that the poor architect
succumbs to every temptation and the good one resists it.
Ludwig Wittgenstein
JAOO 2002 http://www.curbralan.com 4
Remove to Improve
• Yes, it's OK to delete code
Controlled and considered code implosion shows
that a project is maturing
• But remember, minimalism is not nihilism
Refactoring is a disciplined practice
The minimum could be defined as the perfection that an artefact achieves when it is
no longer possible to improve it by subtraction. This is the quality that an object
has when every component, every detail, and every junction has been reduced or
condensed to the essentials. It is the result of the omission of the inessentials.
John Pawson
JAOO 2002 http://www.curbralan.com 5
A Programmer's Dozen
Refactoring, Repairing and Regaining Control
programmer a person who writes computer programs.
dozen a group or set of twelve.
The New Oxford Dictionary of English
Asymmetric bounds are most convenient to program in a language like C in which
arrays start from zero: the exclusive upper bound of such an array is equal to the
number of elements! Thus when we define a C array with 12 elements, 0 is
inclusive lower bound and 12 the exclusive upper bound for the subscripts of the
array.
Andrew Koenig
A baker's dozen contains thirteen items as opposed to the familiar twelve. This
dates from the time when bakers were subject to heavy fines if they served under-
weight bread. To avoid this danger bakers provided a surplus number of loaves, the
thirteenth loaf in the dozen being called the vantage loaf.
Lock, Stock & Barrel
JAOO 2002 http://www.curbralan.com 6
Recommendation 0
Follow Form
• Suitable idioms in code should be followed to
improve communication
Ideolects reduce general comprehensibility
• But idioms should not be followed slavishly if
they make little sense or detract from quality
This principle, that of parallel construction, requires that expressions similar in
context and function be outwardly similar. The likeness of form enables the reader
to recognize more readily the likeness of content and function.
Strunk and White
JAOO 2002 http://www.curbralan.com 7
Recommendation 1
Don't Break Contracts
• Methods have a contract for their use
Assertions may or may not be enough to enforce
the contract fully
• Subclassing and implemented interfaces
should follow substitutability
Unsupported operations or operations that do a
little less or expect a little extra add complexity
Politicians are the same everywhere. They promise to build a bridge even when
there's no river.
Nikita Khrushchev
JAOO 2002 http://www.curbralan.com 8
Recommendation 2
Include Only What You Need
• A class typically defines an interface backed
by an implementation
Separate the usage type from the creation type
"I wish you wouldn't keep appearing and vanishing so suddenly: you make one
quite giddy!"
"All right," said the Cat; and this time it vanished quite slowly, beginning with the
end of the tail, and ending with the grin, which remained some time after the rest of
it had gone.
"Well! I've often seen a cat without a grin," thought Alice; "but a grin without a
cat! It's the most curious thing I ever saw in all my life!"
Lewis Carroll
JAOO 2002 http://www.curbralan.com 9
Recommendation 3
Express Independent Ideas Independently
• Normalise dependencies
Consolidate common argument lists and decouple
roles within interfaces
• Watch out for porous layers and noosely
coupled code
Weak wrapping and cyclic package dependencies
propagate dependencies unnecessarily
What do you get when you cross a mosquito with a rock climber?
Nothing, you can't cross a vector and a scalar.
JAOO 2002 http://www.curbralan.com 10
Recommendation 4
Parameterize from Above
• Global packages, Singletons and bundles of
constants should be rationalised or eliminated
They introduce coincidental coupling, so code is
less adaptable and harder to test
• Use arguments and interfaces to invert
dependencies
While moon sets
atop the trees,
leaves cling to rain.
Bashō
JAOO 2002 http://www.curbralan.com 11
Recommendation 5
Manage Resources Symmetrically
• Garbage collection is insufficient for any
resource other than memory
And even then, it can be less than perfect
• Resource management should be explicitly
balanced or fully encapsulated
Consider using block objects to wrap resource use
As the sunrise to the night,
As the north wind to the clouds.
Percy Bysshe Shelley
JAOO 2002 http://www.curbralan.com 12
Recommendation 6
Encapsulate
• Encapsulation is more than just data hiding
Self-containedness includes exception safety,
thread safety, ease of use, transparency, etc.
• Encapsulation reduces affordances
encapsulate enclose (something) in or as if in a capsule.
express the essential feature of (someone or something) succinctly.
enclose (a message or signal) in a set of codes which allow use by or transfer
through different computer systems or networks.
provide an interface for (a piece of software or hardware) to allow or
simplify access for the user.
The New Oxford Dictionary of English
JAOO 2002 http://www.curbralan.com 13
Recommendation 7
Flow Don't Jump
• Jumpy control flow should be used sparingly
It is easy to get addicted to break and early returns
— and continue and goto (where it exists)
throw is an exception
• Control flow that doesn't flow can be hard to
comprehend and refactor
Structured programming is not completely dead
Still glides the Stream, and shall for ever glide;
The Form remains, the Function never dies.
William Wordsworth
JAOO 2002 http://www.curbralan.com 14
Recommendation 8
Sharpen Fuzzy Logic
• Many verbose coding practices are justified
because they simplify debugging
This is solving the wrong problem
• Boolean algebra is not rocket science
Although you may use it for that purpose
This above all: to thine own self be true,
And it must follow, as the night the day,
Thou canst not then be false to any man.
William Shakespeare
JAOO 2002 http://www.curbralan.com 15
Recommendation 9
Hand Redundant Code its Notice
• Code may be less than the sum of its parts
Redundant code is code that has no genuine effect
• Redundant code acts as a speed bump to
understanding — remove it
Unreachable code, synchronising non-thread
affected code, unused code, etc.
Omit needless words.
Strunk and White
JAOO 2002 http://www.curbralan.com 16
Recommendation 10
Let the Code Make the Decisions
• There is no need to spell everything out in
minute detail
Control flow becomes a patchwork of special cases
• Code can also appear to do more than the sum
of its parts
Polymorphism, lookup tables, grouped actions on
collections, double dispatch, etc.
His had been an intellectual decision founded on his conviction that if a little
knowledge was a dangerous thing, a lot was lethal.
Tom Sharpe
JAOO 2002 http://www.curbralan.com 17
Recommendation 11
Consider Duplicate Code to be a Mistake
• A lot of programs suffer from a persistent case
of the common code
Duplicate code is long grass in which bugs thrive
• Visible duplication is a problem best solved
by refactoring the commonality
Into a class, a method or a block surrounded by
clearer logic
You cannot step twice into the same river.
Heraclitus
JAOO 2002 http://www.curbralan.com 18
Recommendation 12
Prefer Code to Comments
• Code that is not code needs a clear role
Most comments do not qualify
1. If a program is incorrect, it matters little what the documentation says.
2. If documentation does not agree with the code, it is not worth much.
3. Consequently, code must largely document itself. If it cannot, rewrite the code
rather than increase the supplementary documentation. Good code needs fewer
comments than bad code does.
4. Comments should provide additional information that is not readily obtainable
from the code itself. They should never parrot the code.
5. Mnemonic variable names and labels, and a layout that emphasizes logical
structure, help make a program self-documenting.
Kernighan and Plauger
JAOO 2002 http://www.curbralan.com 19
Summary
• Baroquecratic practices and just-in-case code
have a br(e)aking effect
The measure of code is in software behaviour
• Developmental requirements are as important
as functional and operational requirements
Attention to developmental requirements makes
other requirements easier to address
Remember that there is no code faster than no code.
Taligent's Guide to Designing Programs

More Related Content

Similar to A Practical Guide to Minimalist Code Design

All we like sheep: Cloning as an Engineering Tool
All we like sheep: Cloning as an Engineering ToolAll we like sheep: Cloning as an Engineering Tool
All we like sheep: Cloning as an Engineering Toolmigod
 
The Rest of the Best
The Rest of the BestThe Rest of the Best
The Rest of the BestKevlin Henney
 
Protecting JavaScript source code using obfuscation - OWASP Europe Tour 2013 ...
Protecting JavaScript source code using obfuscation - OWASP Europe Tour 2013 ...Protecting JavaScript source code using obfuscation - OWASP Europe Tour 2013 ...
Protecting JavaScript source code using obfuscation - OWASP Europe Tour 2013 ...AuditMark
 
Owaspeutour2013lisbon pedrofortunaprotectingjavascriptsourcecodeusingobfuscat...
Owaspeutour2013lisbon pedrofortunaprotectingjavascriptsourcecodeusingobfuscat...Owaspeutour2013lisbon pedrofortunaprotectingjavascriptsourcecodeusingobfuscat...
Owaspeutour2013lisbon pedrofortunaprotectingjavascriptsourcecodeusingobfuscat...Thiện Dương
 
Power Up Your Build at Underscore 2018-02
Power Up Your Build at Underscore 2018-02Power Up Your Build at Underscore 2018-02
Power Up Your Build at Underscore 2018-02Omer van Kloeten
 
Documentation for developers
Documentation for developersDocumentation for developers
Documentation for developersMichael Marotta
 
It's OK to make a new folder within Rails.
It's OK to make a new folder within Rails.It's OK to make a new folder within Rails.
It's OK to make a new folder within Rails.cschaafsma
 
Creating Stable Assignments
Creating Stable AssignmentsCreating Stable Assignments
Creating Stable AssignmentsKevlin Henney
 
How Functional Programming Made Me a Better Developer
How Functional Programming Made Me a Better DeveloperHow Functional Programming Made Me a Better Developer
How Functional Programming Made Me a Better DeveloperCameron Presley
 
Most valuable software design principles
Most valuable software design principlesMost valuable software design principles
Most valuable software design principlesJeroen Hildering
 
Disarmingly Forthright MSCS Advice
Disarmingly Forthright MSCS AdviceDisarmingly Forthright MSCS Advice
Disarmingly Forthright MSCS AdviceAndré Peric Tavares
 
10 tips to save you time and frustration while programming
10 tips to save you time and frustration while programming10 tips to save you time and frustration while programming
10 tips to save you time and frustration while programmingHugo Shi
 
Software Development Essential Skills
Software Development Essential SkillsSoftware Development Essential Skills
Software Development Essential SkillsJohn Choi
 
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"JSFestUA
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_pptagnes_crepet
 
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
Building DSLs: Marriage of High Essence and Groovy MetaprogrammingBuilding DSLs: Marriage of High Essence and Groovy Metaprogramming
Building DSLs: Marriage of High Essence and Groovy MetaprogrammingSkills Matter
 
How have we developed product without bugs
How have we developed product without bugsHow have we developed product without bugs
How have we developed product without bugsSigma Software
 

Similar to A Practical Guide to Minimalist Code Design (20)

All we like sheep: Cloning as an Engineering Tool
All we like sheep: Cloning as an Engineering ToolAll we like sheep: Cloning as an Engineering Tool
All we like sheep: Cloning as an Engineering Tool
 
RubyConf Uruguay 2011
RubyConf Uruguay 2011RubyConf Uruguay 2011
RubyConf Uruguay 2011
 
The Rest of the Best
The Rest of the BestThe Rest of the Best
The Rest of the Best
 
Protecting JavaScript source code using obfuscation - OWASP Europe Tour 2013 ...
Protecting JavaScript source code using obfuscation - OWASP Europe Tour 2013 ...Protecting JavaScript source code using obfuscation - OWASP Europe Tour 2013 ...
Protecting JavaScript source code using obfuscation - OWASP Europe Tour 2013 ...
 
Owaspeutour2013lisbon pedrofortunaprotectingjavascriptsourcecodeusingobfuscat...
Owaspeutour2013lisbon pedrofortunaprotectingjavascriptsourcecodeusingobfuscat...Owaspeutour2013lisbon pedrofortunaprotectingjavascriptsourcecodeusingobfuscat...
Owaspeutour2013lisbon pedrofortunaprotectingjavascriptsourcecodeusingobfuscat...
 
Power Up Your Build at Underscore 2018-02
Power Up Your Build at Underscore 2018-02Power Up Your Build at Underscore 2018-02
Power Up Your Build at Underscore 2018-02
 
Documentation for developers
Documentation for developersDocumentation for developers
Documentation for developers
 
It's OK to make a new folder within Rails.
It's OK to make a new folder within Rails.It's OK to make a new folder within Rails.
It's OK to make a new folder within Rails.
 
Creating Stable Assignments
Creating Stable AssignmentsCreating Stable Assignments
Creating Stable Assignments
 
How Functional Programming Made Me a Better Developer
How Functional Programming Made Me a Better DeveloperHow Functional Programming Made Me a Better Developer
How Functional Programming Made Me a Better Developer
 
Most valuable software design principles
Most valuable software design principlesMost valuable software design principles
Most valuable software design principles
 
Disarmingly Forthright MSCS Advice
Disarmingly Forthright MSCS AdviceDisarmingly Forthright MSCS Advice
Disarmingly Forthright MSCS Advice
 
10 tips to save you time and frustration while programming
10 tips to save you time and frustration while programming10 tips to save you time and frustration while programming
10 tips to save you time and frustration while programming
 
Software Development Essential Skills
Software Development Essential SkillsSoftware Development Essential Skills
Software Development Essential Skills
 
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
JS Fest 2019/Autumn. Alexandre Gomes. Embrace the "react fatigue"
 
Design [Autosaved]
Design [Autosaved]Design [Autosaved]
Design [Autosaved]
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
 
Os Goodger
Os GoodgerOs Goodger
Os Goodger
 
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
Building DSLs: Marriage of High Essence and Groovy MetaprogrammingBuilding DSLs: Marriage of High Essence and Groovy Metaprogramming
Building DSLs: Marriage of High Essence and Groovy Metaprogramming
 
How have we developed product without bugs
How have we developed product without bugsHow have we developed product without bugs
How have we developed product without bugs
 

More from mustafa sarac

Uluslararasilasma son
Uluslararasilasma sonUluslararasilasma son
Uluslararasilasma sonmustafa sarac
 
Real time machine learning proposers day v3
Real time machine learning proposers day v3Real time machine learning proposers day v3
Real time machine learning proposers day v3mustafa sarac
 
Latka december digital
Latka december digitalLatka december digital
Latka december digitalmustafa sarac
 
Axial RC SCX10 AE2 ESC user manual
Axial RC SCX10 AE2 ESC user manualAxial RC SCX10 AE2 ESC user manual
Axial RC SCX10 AE2 ESC user manualmustafa sarac
 
Array programming with Numpy
Array programming with NumpyArray programming with Numpy
Array programming with Numpymustafa sarac
 
Math for programmers
Math for programmersMath for programmers
Math for programmersmustafa sarac
 
TEGV 2020 Bireysel bagiscilarimiz
TEGV 2020 Bireysel bagiscilarimizTEGV 2020 Bireysel bagiscilarimiz
TEGV 2020 Bireysel bagiscilarimizmustafa sarac
 
How to make and manage a bee hotel?
How to make and manage a bee hotel?How to make and manage a bee hotel?
How to make and manage a bee hotel?mustafa sarac
 
Cahit arf makineler dusunebilir mi
Cahit arf makineler dusunebilir miCahit arf makineler dusunebilir mi
Cahit arf makineler dusunebilir mimustafa sarac
 
How did Software Got So Reliable Without Proof?
How did Software Got So Reliable Without Proof?How did Software Got So Reliable Without Proof?
How did Software Got So Reliable Without Proof?mustafa sarac
 
Staff Report on Algorithmic Trading in US Capital Markets
Staff Report on Algorithmic Trading in US Capital MarketsStaff Report on Algorithmic Trading in US Capital Markets
Staff Report on Algorithmic Trading in US Capital Marketsmustafa sarac
 
Yetiskinler icin okuma yazma egitimi
Yetiskinler icin okuma yazma egitimiYetiskinler icin okuma yazma egitimi
Yetiskinler icin okuma yazma egitimimustafa sarac
 
Consumer centric api design v0.4.0
Consumer centric api design v0.4.0Consumer centric api design v0.4.0
Consumer centric api design v0.4.0mustafa sarac
 
State of microservices 2020 by tsh
State of microservices 2020 by tshState of microservices 2020 by tsh
State of microservices 2020 by tshmustafa sarac
 
Uber pitch deck 2008
Uber pitch deck 2008Uber pitch deck 2008
Uber pitch deck 2008mustafa sarac
 
Wireless solar keyboard k760 quickstart guide
Wireless solar keyboard k760 quickstart guideWireless solar keyboard k760 quickstart guide
Wireless solar keyboard k760 quickstart guidemustafa sarac
 
State of Serverless Report 2020
State of Serverless Report 2020State of Serverless Report 2020
State of Serverless Report 2020mustafa sarac
 
Dont just roll the dice
Dont just roll the diceDont just roll the dice
Dont just roll the dicemustafa sarac
 

More from mustafa sarac (20)

Uluslararasilasma son
Uluslararasilasma sonUluslararasilasma son
Uluslararasilasma son
 
Real time machine learning proposers day v3
Real time machine learning proposers day v3Real time machine learning proposers day v3
Real time machine learning proposers day v3
 
Latka december digital
Latka december digitalLatka december digital
Latka december digital
 
Axial RC SCX10 AE2 ESC user manual
Axial RC SCX10 AE2 ESC user manualAxial RC SCX10 AE2 ESC user manual
Axial RC SCX10 AE2 ESC user manual
 
Array programming with Numpy
Array programming with NumpyArray programming with Numpy
Array programming with Numpy
 
Math for programmers
Math for programmersMath for programmers
Math for programmers
 
The book of Why
The book of WhyThe book of Why
The book of Why
 
BM sgk meslek kodu
BM sgk meslek koduBM sgk meslek kodu
BM sgk meslek kodu
 
TEGV 2020 Bireysel bagiscilarimiz
TEGV 2020 Bireysel bagiscilarimizTEGV 2020 Bireysel bagiscilarimiz
TEGV 2020 Bireysel bagiscilarimiz
 
How to make and manage a bee hotel?
How to make and manage a bee hotel?How to make and manage a bee hotel?
How to make and manage a bee hotel?
 
Cahit arf makineler dusunebilir mi
Cahit arf makineler dusunebilir miCahit arf makineler dusunebilir mi
Cahit arf makineler dusunebilir mi
 
How did Software Got So Reliable Without Proof?
How did Software Got So Reliable Without Proof?How did Software Got So Reliable Without Proof?
How did Software Got So Reliable Without Proof?
 
Staff Report on Algorithmic Trading in US Capital Markets
Staff Report on Algorithmic Trading in US Capital MarketsStaff Report on Algorithmic Trading in US Capital Markets
Staff Report on Algorithmic Trading in US Capital Markets
 
Yetiskinler icin okuma yazma egitimi
Yetiskinler icin okuma yazma egitimiYetiskinler icin okuma yazma egitimi
Yetiskinler icin okuma yazma egitimi
 
Consumer centric api design v0.4.0
Consumer centric api design v0.4.0Consumer centric api design v0.4.0
Consumer centric api design v0.4.0
 
State of microservices 2020 by tsh
State of microservices 2020 by tshState of microservices 2020 by tsh
State of microservices 2020 by tsh
 
Uber pitch deck 2008
Uber pitch deck 2008Uber pitch deck 2008
Uber pitch deck 2008
 
Wireless solar keyboard k760 quickstart guide
Wireless solar keyboard k760 quickstart guideWireless solar keyboard k760 quickstart guide
Wireless solar keyboard k760 quickstart guide
 
State of Serverless Report 2020
State of Serverless Report 2020State of Serverless Report 2020
State of Serverless Report 2020
 
Dont just roll the dice
Dont just roll the diceDont just roll the dice
Dont just roll the dice
 

Recently uploaded

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
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
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
 
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
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
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
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
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
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 

Recently uploaded (20)

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
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
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
 
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
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
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
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
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...
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 

A Practical Guide to Minimalist Code Design

  • 1. Minimalism A Practical Guide to Writing Less Code kevlin@curbralan.com Kevlin Henney JAOO 2002 http://www.curbralan.com 2 Minimalism • A movement in art, architecture, music and interior design • More generally, a tendency towards less rather than more Seeking the minimum, the lowest point on a curve It isn't necessary for a work to have a lot of things to look at, to compare, to analyse one by one, to contemplate. The thing as a whole, its quality as a whole, is what is interesting. The main things are alone and are more intense, clear and powerful. Donald Judd
  • 2. JAOO 2002 http://www.curbralan.com 3 Less Code, More Software • Creeping featurism and code verbosity do not add to the used functionality of the software Functionality is weakly correlated with the number of lines of code written • On the other hand, minimalism is not the reduction of source code to line noise Code should be sufficient and fit for purpose The difference between a good and a poor architect is that the poor architect succumbs to every temptation and the good one resists it. Ludwig Wittgenstein JAOO 2002 http://www.curbralan.com 4 Remove to Improve • Yes, it's OK to delete code Controlled and considered code implosion shows that a project is maturing • But remember, minimalism is not nihilism Refactoring is a disciplined practice The minimum could be defined as the perfection that an artefact achieves when it is no longer possible to improve it by subtraction. This is the quality that an object has when every component, every detail, and every junction has been reduced or condensed to the essentials. It is the result of the omission of the inessentials. John Pawson
  • 3. JAOO 2002 http://www.curbralan.com 5 A Programmer's Dozen Refactoring, Repairing and Regaining Control programmer a person who writes computer programs. dozen a group or set of twelve. The New Oxford Dictionary of English Asymmetric bounds are most convenient to program in a language like C in which arrays start from zero: the exclusive upper bound of such an array is equal to the number of elements! Thus when we define a C array with 12 elements, 0 is inclusive lower bound and 12 the exclusive upper bound for the subscripts of the array. Andrew Koenig A baker's dozen contains thirteen items as opposed to the familiar twelve. This dates from the time when bakers were subject to heavy fines if they served under- weight bread. To avoid this danger bakers provided a surplus number of loaves, the thirteenth loaf in the dozen being called the vantage loaf. Lock, Stock & Barrel JAOO 2002 http://www.curbralan.com 6 Recommendation 0 Follow Form • Suitable idioms in code should be followed to improve communication Ideolects reduce general comprehensibility • But idioms should not be followed slavishly if they make little sense or detract from quality This principle, that of parallel construction, requires that expressions similar in context and function be outwardly similar. The likeness of form enables the reader to recognize more readily the likeness of content and function. Strunk and White
  • 4. JAOO 2002 http://www.curbralan.com 7 Recommendation 1 Don't Break Contracts • Methods have a contract for their use Assertions may or may not be enough to enforce the contract fully • Subclassing and implemented interfaces should follow substitutability Unsupported operations or operations that do a little less or expect a little extra add complexity Politicians are the same everywhere. They promise to build a bridge even when there's no river. Nikita Khrushchev JAOO 2002 http://www.curbralan.com 8 Recommendation 2 Include Only What You Need • A class typically defines an interface backed by an implementation Separate the usage type from the creation type "I wish you wouldn't keep appearing and vanishing so suddenly: you make one quite giddy!" "All right," said the Cat; and this time it vanished quite slowly, beginning with the end of the tail, and ending with the grin, which remained some time after the rest of it had gone. "Well! I've often seen a cat without a grin," thought Alice; "but a grin without a cat! It's the most curious thing I ever saw in all my life!" Lewis Carroll
  • 5. JAOO 2002 http://www.curbralan.com 9 Recommendation 3 Express Independent Ideas Independently • Normalise dependencies Consolidate common argument lists and decouple roles within interfaces • Watch out for porous layers and noosely coupled code Weak wrapping and cyclic package dependencies propagate dependencies unnecessarily What do you get when you cross a mosquito with a rock climber? Nothing, you can't cross a vector and a scalar. JAOO 2002 http://www.curbralan.com 10 Recommendation 4 Parameterize from Above • Global packages, Singletons and bundles of constants should be rationalised or eliminated They introduce coincidental coupling, so code is less adaptable and harder to test • Use arguments and interfaces to invert dependencies While moon sets atop the trees, leaves cling to rain. Bashō
  • 6. JAOO 2002 http://www.curbralan.com 11 Recommendation 5 Manage Resources Symmetrically • Garbage collection is insufficient for any resource other than memory And even then, it can be less than perfect • Resource management should be explicitly balanced or fully encapsulated Consider using block objects to wrap resource use As the sunrise to the night, As the north wind to the clouds. Percy Bysshe Shelley JAOO 2002 http://www.curbralan.com 12 Recommendation 6 Encapsulate • Encapsulation is more than just data hiding Self-containedness includes exception safety, thread safety, ease of use, transparency, etc. • Encapsulation reduces affordances encapsulate enclose (something) in or as if in a capsule. express the essential feature of (someone or something) succinctly. enclose (a message or signal) in a set of codes which allow use by or transfer through different computer systems or networks. provide an interface for (a piece of software or hardware) to allow or simplify access for the user. The New Oxford Dictionary of English
  • 7. JAOO 2002 http://www.curbralan.com 13 Recommendation 7 Flow Don't Jump • Jumpy control flow should be used sparingly It is easy to get addicted to break and early returns — and continue and goto (where it exists) throw is an exception • Control flow that doesn't flow can be hard to comprehend and refactor Structured programming is not completely dead Still glides the Stream, and shall for ever glide; The Form remains, the Function never dies. William Wordsworth JAOO 2002 http://www.curbralan.com 14 Recommendation 8 Sharpen Fuzzy Logic • Many verbose coding practices are justified because they simplify debugging This is solving the wrong problem • Boolean algebra is not rocket science Although you may use it for that purpose This above all: to thine own self be true, And it must follow, as the night the day, Thou canst not then be false to any man. William Shakespeare
  • 8. JAOO 2002 http://www.curbralan.com 15 Recommendation 9 Hand Redundant Code its Notice • Code may be less than the sum of its parts Redundant code is code that has no genuine effect • Redundant code acts as a speed bump to understanding — remove it Unreachable code, synchronising non-thread affected code, unused code, etc. Omit needless words. Strunk and White JAOO 2002 http://www.curbralan.com 16 Recommendation 10 Let the Code Make the Decisions • There is no need to spell everything out in minute detail Control flow becomes a patchwork of special cases • Code can also appear to do more than the sum of its parts Polymorphism, lookup tables, grouped actions on collections, double dispatch, etc. His had been an intellectual decision founded on his conviction that if a little knowledge was a dangerous thing, a lot was lethal. Tom Sharpe
  • 9. JAOO 2002 http://www.curbralan.com 17 Recommendation 11 Consider Duplicate Code to be a Mistake • A lot of programs suffer from a persistent case of the common code Duplicate code is long grass in which bugs thrive • Visible duplication is a problem best solved by refactoring the commonality Into a class, a method or a block surrounded by clearer logic You cannot step twice into the same river. Heraclitus JAOO 2002 http://www.curbralan.com 18 Recommendation 12 Prefer Code to Comments • Code that is not code needs a clear role Most comments do not qualify 1. If a program is incorrect, it matters little what the documentation says. 2. If documentation does not agree with the code, it is not worth much. 3. Consequently, code must largely document itself. If it cannot, rewrite the code rather than increase the supplementary documentation. Good code needs fewer comments than bad code does. 4. Comments should provide additional information that is not readily obtainable from the code itself. They should never parrot the code. 5. Mnemonic variable names and labels, and a layout that emphasizes logical structure, help make a program self-documenting. Kernighan and Plauger
  • 10. JAOO 2002 http://www.curbralan.com 19 Summary • Baroquecratic practices and just-in-case code have a br(e)aking effect The measure of code is in software behaviour • Developmental requirements are as important as functional and operational requirements Attention to developmental requirements makes other requirements easier to address Remember that there is no code faster than no code. Taligent's Guide to Designing Programs