SlideShare a Scribd company logo
Design without types
Alex Bolboacă,  @alexboly,  alex.bolboaca@mozaicworks.com
May 2019
Introduction(s)
Why This Talk?
Experiment in minimalism: optional types
Deep questions
Conclusion
Introduction(s)
Slides
Slides published:
https://www.slideshare.net/alexboly/design-without-types
I’m Alex
I’m helping customers
Digital Transformation (mostly for banks recently)
I’m writing a book (publish date in June)
The topic I love the most is software design
“Alex Boly on Design” youtube playlist http://bit.ly/alex-on-design
Why This Talk?
Personal History
Beginner enthusiast (10 - 21 years old):
• BASIC (ZX80 Clone)
• Turbo Pascal
• C
• C++
Stance on types: what are types?
Personal History
Early professional (21 - 30 years old)
• C++
• Java
• C#
Stance on types: probably great.
Personal History
OMG, this book is mindblowing!
Personal History
Software Crafter (30 - 40 years old)
• C++
• python
• groovy
Stance on types: Get out of my comfort zone!
Personal History
Raising the Bar
Personal History
Code Designer (40 - now)
• what can I use to solve problems as quickly as possible?
Stance on types: optional types have distinct advantages
Code Designer
Minimalism
Minimalism in Code - Reasoning
• Custom code is expensive: to build, to test, to change, to refine until it
works, to run, to maintain
• The more lines of code, the higher the probability to have bugs
• Less code => smaller cognitive pressure
Experiment in minimalism: optional
types
Rules
• Type not specified unless it’s important
• No casting
• No thinking about the types used, only about their capabilities
What I’ve expected
• bugs
• weird problems
• need to write more tests
• code that’s more difficult to understand
What I’ve got from optional types
• cleaner & smaller code
• easier to change
• fewer tests than I expected
• fewer bugs than I expected
NB: Some things were enabled by the language (groovy + grails), others are
strongly related to the idea of optional types
Project
• eventrix.co
• web platform for conference organizers
• groovy on grails (JVM language)
Not perfect!
• too much custom code - learned the hard way
Cleaner and smaller code
// Typical Java version
User user = new User(); // Duplication: 3 * User + ';'!!!
var user = new User(); // Optional type: 2 * User + ';'
// Groovy version
def user = new User() // 2 * User
// GORM
def user = User.get(userId)
Cleaner and smaller code
// Functional programming
// C++ lambda
auto increment = [](int value){ return first + 1;};
// C++ lambda with optional type
auto increment = [](auto value){ return first + 1;};
Cleaner and smaller code
// Functional programming
// C++ lambda
auto increment = [](int value){ return first + 1;};
// C++ lambda with optional type
auto increment = [](auto value){ return first + 1;};
// Simplest Groovy lambda
def increment = {it + 1} // optional type
// also some magic: what is 'it'?
Cleaner and smaller code
// C++ get list of names of users
auto names = transform(
users.begin(), users.end(),
[](auto user){ return user.getName(); }
);
Cleaner and smaller code
// C++ get list of names of users
auto names = transform(
users.begin(), users.end(),
[](auto user){ return user.getName(); }
);
// groovy get list of names of users
def names = users*.name
Cleaner and smaller code
// Do the same, assuming User class has firstName and lastName
// C++
auto names = transform(users.begin(), users.end(),
[](auto user){
return user.getFirstName()
+ ” ”
+ users.getLastName();
}
);
Cleaner and smaller code
// Do the same, assuming User class has firstName and lastName
// C++
auto names = transform(users.begin(), users.end(),
[](auto user){
return user.getFirstName()
+ ” ”
+ users.getLastName();
}
);
// groovy
def names = users.collect{it.firstName + ” ” + it.lastName}
A taste of optional types
• Tests using Spock
• Query
• Controller
• Command
Deep questions
Q1: Is the cognitive cost of abstractions worth it?
Salvador Dali - The melting watch
Q2: Is strong typing a form of strong coupling?
Strong Coupling = “when I change X I also need to change Y”.
Example
class UserDbService {
boolean confirmEmail(int userId) {
def user = User.get(userId)
user.emailConfirmed = true
user.save()
}
...
}
class User{
int userId;
...
}
Example
What should be the type of userId?
• int
• long
• GUID
• UserID
Strong Coupling
What if I change the type from int to UserID?
(e.g. my company buys another company and we need to merge the systems)
• change User
• change UserDbService
• and change everywhere where int userId is used
Optional Type => looser coupling
class UserDbService {
boolean confirmEmail(userId) {
def user = User.get(userId)
user.emailConfirmed = true
user.save()
}
...
}
class User{
int userId;
...
}
Q3: How Important Are Names?
// a design pattern we use for
// transactional classes that
// interact with database
class UserDbService {
def confirmEmail(userId) {
def user = User.get(userId)
user.emailConfirmed = true
user.save()
}
...
}
Q4: How Important Are Contracts?
TEST_CASE(”X wins”){
Board board = {
{'X', 'X', 'X'},
{' ', 'O', ' '},
{' ', ' ', 'O'}
};
CHECK(xWins(board));
}
Let’s see the code!
Contract: Coordinates have two values
Contracts?
With minimal types, you need to be very aware of the contracts
Beyond Types: Design Entities
We use clear, well defined design entities:
• Model: class defining the entity structure and mapping to database
Beyond Types: Design Entities
We use clear, well defined design entities:
• Model: class defining the entity structure and mapping to database
• Query: class that encapsulates database queries
Beyond Types: Design Entities
We use clear, well defined design entities:
• Model: class defining the entity structure and mapping to database
• Query: class that encapsulates database queries
• DbCommand: class that saves data to the database
Beyond Types: Design Entities
We use clear, well defined design entities:
• Model: class defining the entity structure and mapping to database
• Query: class that encapsulates database queries
• DbCommand: class that saves data to the database
• DbService: class that is called by Command or BusinessService to
make multiple operations in the database, usually with the help of
DbCommands
Beyond Types: Design Entities
We use clear, well defined design entities:
• Model: class defining the entity structure and mapping to database
• Query: class that encapsulates database queries
• DbCommand: class that saves data to the database
• DbService: class that is called by Command or BusinessService to
make multiple operations in the database, usually with the help of
DbCommands
• BusinessService: class that is called by Command to facilitate a
business process
Beyond Types: Design Entities
We use clear, well defined design entities:
• Model: class defining the entity structure and mapping to database
• Query: class that encapsulates database queries
• DbCommand: class that saves data to the database
• DbService: class that is called by Command or BusinessService to
make multiple operations in the database, usually with the help of
DbCommands
• BusinessService: class that is called by Command to facilitate a
business process
• Command: class that is called by Controller to validate specific HTTP
requests and delegate to the right Services the execution.
Conclusion
Minimalism exerts a positive pressure on design
We still need to understand the code. Without types, how do we understand
it?
• smaller code
Minimalism exerts a positive pressure on design
We still need to understand the code. Without types, how do we understand
it?
• smaller code
• better names
Minimalism exerts a positive pressure on design
We still need to understand the code. Without types, how do we understand
it?
• smaller code
• better names
• clear responsibilities
Minimalism exerts a positive pressure on design
We still need to understand the code. Without types, how do we understand
it?
• smaller code
• better names
• clear responsibilities
• clear contracts
Minimalism exerts a positive pressure on design
We still need to understand the code. Without types, how do we understand
it?
• smaller code
• better names
• clear responsibilities
• clear contracts
• clear tests
Always Optional Types? NO
Clear problem domain, clear solution, not expecting change, used by
specialists => strong types, validation at compile time
Expecting change, evolving problem and solution domain => minimalism,
changeable code, fewer constraints
Let’s think differently!
“I want the compiler to do as much checking for me as possible”
Let’s think differently!
“I want the compiler to do as much checking for me as possible”
vs.
“I want to write the code that makes sense, and the compiler / interpreter to
figure it out”
Thank you!
Come talk to me later and get nice stickers!
Q&A
Q&A

More Related Content

What's hot

Java script ppt
Java script pptJava script ppt
JavaScript - Chapter 3 - Introduction
 JavaScript - Chapter 3 - Introduction JavaScript - Chapter 3 - Introduction
JavaScript - Chapter 3 - Introduction
WebStackAcademy
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascriptKumar
 
TypeScript
TypeScriptTypeScript
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010
ssoroka
 
Web development basics (Part-2)
Web development basics (Part-2)Web development basics (Part-2)
Web development basics (Part-2)
Rajat Pratap Singh
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
Malin Weiss
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
Aniruddha Chakrabarti
 
SOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSergey Karpushin
 
Web development basics (Part-7)
Web development basics (Part-7)Web development basics (Part-7)
Web development basics (Part-7)
Rajat Pratap Singh
 
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Codemotion
 
OOP's Part 1
OOP's Part 1OOP's Part 1
OOP's Part 1
Saravanakumar R
 
Concurrency for dummies
Concurrency for dummiesConcurrency for dummies
Concurrency for dummiesAzrul MADISA
 
TypeScript Best Practices
TypeScript Best PracticesTypeScript Best Practices
TypeScript Best Practices
felixbillon
 
Learning typescript
Learning typescriptLearning typescript
Learning typescript
Alexandre Marreiros
 
Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
Marcus Denker
 
Web development basics (Part-6)
Web development basics (Part-6)Web development basics (Part-6)
Web development basics (Part-6)
Rajat Pratap Singh
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!
Alessandro Giorgetti
 

What's hot (19)

Java script ppt
Java script pptJava script ppt
Java script ppt
 
JavaScript - Chapter 3 - Introduction
 JavaScript - Chapter 3 - Introduction JavaScript - Chapter 3 - Introduction
JavaScript - Chapter 3 - Introduction
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascript
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010Meta Programming in Ruby - Code Camp 2010
Meta Programming in Ruby - Code Camp 2010
 
Web development basics (Part-2)
Web development basics (Part-2)Web development basics (Part-2)
Web development basics (Part-2)
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 
SOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principlesSOLID, DRY, SLAP design principles
SOLID, DRY, SLAP design principles
 
Web development basics (Part-7)
Web development basics (Part-7)Web development basics (Part-7)
Web development basics (Part-7)
 
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
Beyond JavaScript Frameworks: Writing Reliable Web Apps With Elm - Erik Wende...
 
OOP's Part 1
OOP's Part 1OOP's Part 1
OOP's Part 1
 
Concurrency for dummies
Concurrency for dummiesConcurrency for dummies
Concurrency for dummies
 
TypeScript Best Practices
TypeScript Best PracticesTypeScript Best Practices
TypeScript Best Practices
 
Learning typescript
Learning typescriptLearning typescript
Learning typescript
 
Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
 
Web development basics (Part-6)
Web development basics (Part-6)Web development basics (Part-6)
Web development basics (Part-6)
 
Introducing TypeScript
Introducing TypeScriptIntroducing TypeScript
Introducing TypeScript
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!
 

Similar to Design Without Types

Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Fwdays
 
CPP13 - Object Orientation
CPP13 - Object OrientationCPP13 - Object Orientation
CPP13 - Object Orientation
Michael Heron
 
Gradle 101
Gradle 101Gradle 101
Gradle 101
Kurt Mbanje
 
CBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBoxCBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBox
Ortus Solutions, Corp
 
Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?
devObjective
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
Derek Jacoby
 
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
Dror Helper
 
Intro to javascript (6:27)
Intro to javascript (6:27)Intro to javascript (6:27)
Intro to javascript (6:27)
David Coulter
 
ASP.NET Session 3
ASP.NET Session 3ASP.NET Session 3
ASP.NET Session 3Sisir Ghosh
 
Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIDirk Ginader
 
Wordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean CodingWordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean Codinginspector_fegter
 
Jumpstart Django
Jumpstart DjangoJumpstart Django
Jumpstart Django
ryates
 
Getting started with titanium
Getting started with titaniumGetting started with titanium
Getting started with titanium
Naga Harish M
 
Getting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumGetting started with Appcelerator Titanium
Getting started with Appcelerator Titanium
Techday7
 
CPP02 - The Structure of a Program
CPP02 - The Structure of a ProgramCPP02 - The Structure of a Program
CPP02 - The Structure of a Program
Michael Heron
 
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift ApplicationsHack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
eightbit
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Ortus Solutions, Corp
 
Type script
Type scriptType script
Type script
Zunair Shoes
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Uma Ghotikar
 

Similar to Design Without Types (20)

Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
 
CPP13 - Object Orientation
CPP13 - Object OrientationCPP13 - Object Orientation
CPP13 - Object Orientation
 
Gradle 101
Gradle 101Gradle 101
Gradle 101
 
CBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBoxCBDW2014 - Behavior Driven Development with TestBox
CBDW2014 - Behavior Driven Development with TestBox
 
Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
 
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
 
Intro to javascript (6:27)
Intro to javascript (6:27)Intro to javascript (6:27)
Intro to javascript (6:27)
 
SDWest2005Goetsch
SDWest2005GoetschSDWest2005Goetsch
SDWest2005Goetsch
 
ASP.NET Session 3
ASP.NET Session 3ASP.NET Session 3
ASP.NET Session 3
 
Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp III
 
Wordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean CodingWordcamp St. Louis - Clean Coding
Wordcamp St. Louis - Clean Coding
 
Jumpstart Django
Jumpstart DjangoJumpstart Django
Jumpstart Django
 
Getting started with titanium
Getting started with titaniumGetting started with titanium
Getting started with titanium
 
Getting started with Appcelerator Titanium
Getting started with Appcelerator TitaniumGetting started with Appcelerator Titanium
Getting started with Appcelerator Titanium
 
CPP02 - The Structure of a Program
CPP02 - The Structure of a ProgramCPP02 - The Structure of a Program
CPP02 - The Structure of a Program
 
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift ApplicationsHack in the Box GSEC 2016 - Reverse Engineering Swift Applications
Hack in the Box GSEC 2016 - Reverse Engineering Swift Applications
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Into...
 
Type script
Type scriptType script
Type script
 
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
Introduction to Unit Testing, BDD and Mocking using TestBox & MockBox at Adob...
 

More from Alexandru Bolboaca

Refactor legacy code through pure functions
Refactor legacy code through pure functionsRefactor legacy code through pure functions
Refactor legacy code through pure functions
Alexandru Bolboaca
 
Thinking in Functions
Thinking in FunctionsThinking in Functions
Thinking in Functions
Alexandru Bolboaca
 
Raising the Bar
Raising the BarRaising the Bar
Raising the Bar
Alexandru Bolboaca
 
The Journey to Master Code Design
The Journey to Master Code DesignThe Journey to Master Code Design
The Journey to Master Code Design
Alexandru Bolboaca
 
What is good software design? And why it matters?
What is good software design? And why it matters?What is good software design? And why it matters?
What is good software design? And why it matters?
Alexandru Bolboaca
 
Functional programming in C++
Functional programming in C++Functional programming in C++
Functional programming in C++
Alexandru Bolboaca
 
Agile Technical Leadership
Agile Technical LeadershipAgile Technical Leadership
Agile Technical Leadership
Alexandru Bolboaca
 
TDD As If You Meant It
TDD As If You Meant ItTDD As If You Meant It
TDD As If You Meant It
Alexandru Bolboaca
 
Usable Software Design
Usable Software DesignUsable Software Design
Usable Software Design
Alexandru Bolboaca
 
Hidden loops
Hidden loopsHidden loops
Hidden loops
Alexandru Bolboaca
 
Removing structural duplication
Removing structural duplicationRemoving structural duplication
Removing structural duplication
Alexandru Bolboaca
 
Continuous delivery
Continuous deliveryContinuous delivery
Continuous delivery
Alexandru Bolboaca
 
Why You Should Start Using Docker
Why You Should Start Using DockerWhy You Should Start Using Docker
Why You Should Start Using Docker
Alexandru Bolboaca
 
Pyramid of-developer-skills
Pyramid of-developer-skillsPyramid of-developer-skills
Pyramid of-developer-skills
Alexandru Bolboaca
 
Applied craftsmanship
Applied craftsmanshipApplied craftsmanship
Applied craftsmanship
Alexandru Bolboaca
 
Pyramid of-developer-skills
Pyramid of-developer-skillsPyramid of-developer-skills
Pyramid of-developer-skills
Alexandru Bolboaca
 
Stay focused
Stay focusedStay focused
Stay focused
Alexandru Bolboaca
 
Kanban intro
Kanban introKanban intro
Kanban intro
Alexandru Bolboaca
 
Unit testing-patterns
Unit testing-patternsUnit testing-patterns
Unit testing-patterns
Alexandru Bolboaca
 
Incremental design, simply explained
Incremental design, simply explainedIncremental design, simply explained
Incremental design, simply explained
Alexandru Bolboaca
 

More from Alexandru Bolboaca (20)

Refactor legacy code through pure functions
Refactor legacy code through pure functionsRefactor legacy code through pure functions
Refactor legacy code through pure functions
 
Thinking in Functions
Thinking in FunctionsThinking in Functions
Thinking in Functions
 
Raising the Bar
Raising the BarRaising the Bar
Raising the Bar
 
The Journey to Master Code Design
The Journey to Master Code DesignThe Journey to Master Code Design
The Journey to Master Code Design
 
What is good software design? And why it matters?
What is good software design? And why it matters?What is good software design? And why it matters?
What is good software design? And why it matters?
 
Functional programming in C++
Functional programming in C++Functional programming in C++
Functional programming in C++
 
Agile Technical Leadership
Agile Technical LeadershipAgile Technical Leadership
Agile Technical Leadership
 
TDD As If You Meant It
TDD As If You Meant ItTDD As If You Meant It
TDD As If You Meant It
 
Usable Software Design
Usable Software DesignUsable Software Design
Usable Software Design
 
Hidden loops
Hidden loopsHidden loops
Hidden loops
 
Removing structural duplication
Removing structural duplicationRemoving structural duplication
Removing structural duplication
 
Continuous delivery
Continuous deliveryContinuous delivery
Continuous delivery
 
Why You Should Start Using Docker
Why You Should Start Using DockerWhy You Should Start Using Docker
Why You Should Start Using Docker
 
Pyramid of-developer-skills
Pyramid of-developer-skillsPyramid of-developer-skills
Pyramid of-developer-skills
 
Applied craftsmanship
Applied craftsmanshipApplied craftsmanship
Applied craftsmanship
 
Pyramid of-developer-skills
Pyramid of-developer-skillsPyramid of-developer-skills
Pyramid of-developer-skills
 
Stay focused
Stay focusedStay focused
Stay focused
 
Kanban intro
Kanban introKanban intro
Kanban intro
 
Unit testing-patterns
Unit testing-patternsUnit testing-patterns
Unit testing-patterns
 
Incremental design, simply explained
Incremental design, simply explainedIncremental design, simply explained
Incremental design, simply explained
 

Recently uploaded

Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
vrstrong314
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 

Recently uploaded (20)

Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 

Design Without Types

  • 1. Design without types Alex Bolboacă,  @alexboly,  alex.bolboaca@mozaicworks.com May 2019
  • 2. Introduction(s) Why This Talk? Experiment in minimalism: optional types Deep questions Conclusion
  • 6. I’m helping customers Digital Transformation (mostly for banks recently)
  • 7. I’m writing a book (publish date in June)
  • 8. The topic I love the most is software design “Alex Boly on Design” youtube playlist http://bit.ly/alex-on-design
  • 10. Personal History Beginner enthusiast (10 - 21 years old): • BASIC (ZX80 Clone) • Turbo Pascal • C • C++ Stance on types: what are types?
  • 11. Personal History Early professional (21 - 30 years old) • C++ • Java • C# Stance on types: probably great.
  • 12. Personal History OMG, this book is mindblowing!
  • 13. Personal History Software Crafter (30 - 40 years old) • C++ • python • groovy Stance on types: Get out of my comfort zone!
  • 15. Personal History Code Designer (40 - now) • what can I use to solve problems as quickly as possible? Stance on types: optional types have distinct advantages
  • 17. Minimalism in Code - Reasoning • Custom code is expensive: to build, to test, to change, to refine until it works, to run, to maintain • The more lines of code, the higher the probability to have bugs • Less code => smaller cognitive pressure
  • 18. Experiment in minimalism: optional types
  • 19. Rules • Type not specified unless it’s important • No casting • No thinking about the types used, only about their capabilities
  • 20. What I’ve expected • bugs • weird problems • need to write more tests • code that’s more difficult to understand
  • 21. What I’ve got from optional types • cleaner & smaller code • easier to change • fewer tests than I expected • fewer bugs than I expected NB: Some things were enabled by the language (groovy + grails), others are strongly related to the idea of optional types
  • 22. Project • eventrix.co • web platform for conference organizers • groovy on grails (JVM language) Not perfect! • too much custom code - learned the hard way
  • 23. Cleaner and smaller code // Typical Java version User user = new User(); // Duplication: 3 * User + ';'!!! var user = new User(); // Optional type: 2 * User + ';' // Groovy version def user = new User() // 2 * User // GORM def user = User.get(userId)
  • 24. Cleaner and smaller code // Functional programming // C++ lambda auto increment = [](int value){ return first + 1;}; // C++ lambda with optional type auto increment = [](auto value){ return first + 1;};
  • 25. Cleaner and smaller code // Functional programming // C++ lambda auto increment = [](int value){ return first + 1;}; // C++ lambda with optional type auto increment = [](auto value){ return first + 1;}; // Simplest Groovy lambda def increment = {it + 1} // optional type // also some magic: what is 'it'?
  • 26. Cleaner and smaller code // C++ get list of names of users auto names = transform( users.begin(), users.end(), [](auto user){ return user.getName(); } );
  • 27. Cleaner and smaller code // C++ get list of names of users auto names = transform( users.begin(), users.end(), [](auto user){ return user.getName(); } ); // groovy get list of names of users def names = users*.name
  • 28. Cleaner and smaller code // Do the same, assuming User class has firstName and lastName // C++ auto names = transform(users.begin(), users.end(), [](auto user){ return user.getFirstName() + ” ” + users.getLastName(); } );
  • 29. Cleaner and smaller code // Do the same, assuming User class has firstName and lastName // C++ auto names = transform(users.begin(), users.end(), [](auto user){ return user.getFirstName() + ” ” + users.getLastName(); } ); // groovy def names = users.collect{it.firstName + ” ” + it.lastName}
  • 30. A taste of optional types • Tests using Spock • Query • Controller • Command
  • 32. Q1: Is the cognitive cost of abstractions worth it? Salvador Dali - The melting watch
  • 33. Q2: Is strong typing a form of strong coupling? Strong Coupling = “when I change X I also need to change Y”.
  • 34. Example class UserDbService { boolean confirmEmail(int userId) { def user = User.get(userId) user.emailConfirmed = true user.save() } ... } class User{ int userId; ... }
  • 35. Example What should be the type of userId? • int • long • GUID • UserID
  • 36. Strong Coupling What if I change the type from int to UserID? (e.g. my company buys another company and we need to merge the systems) • change User • change UserDbService • and change everywhere where int userId is used
  • 37. Optional Type => looser coupling class UserDbService { boolean confirmEmail(userId) { def user = User.get(userId) user.emailConfirmed = true user.save() } ... } class User{ int userId; ... }
  • 38. Q3: How Important Are Names? // a design pattern we use for // transactional classes that // interact with database class UserDbService { def confirmEmail(userId) { def user = User.get(userId) user.emailConfirmed = true user.save() } ... }
  • 39. Q4: How Important Are Contracts? TEST_CASE(”X wins”){ Board board = { {'X', 'X', 'X'}, {' ', 'O', ' '}, {' ', ' ', 'O'} }; CHECK(xWins(board)); }
  • 40. Let’s see the code! Contract: Coordinates have two values
  • 41. Contracts? With minimal types, you need to be very aware of the contracts
  • 42. Beyond Types: Design Entities We use clear, well defined design entities: • Model: class defining the entity structure and mapping to database
  • 43. Beyond Types: Design Entities We use clear, well defined design entities: • Model: class defining the entity structure and mapping to database • Query: class that encapsulates database queries
  • 44. Beyond Types: Design Entities We use clear, well defined design entities: • Model: class defining the entity structure and mapping to database • Query: class that encapsulates database queries • DbCommand: class that saves data to the database
  • 45. Beyond Types: Design Entities We use clear, well defined design entities: • Model: class defining the entity structure and mapping to database • Query: class that encapsulates database queries • DbCommand: class that saves data to the database • DbService: class that is called by Command or BusinessService to make multiple operations in the database, usually with the help of DbCommands
  • 46. Beyond Types: Design Entities We use clear, well defined design entities: • Model: class defining the entity structure and mapping to database • Query: class that encapsulates database queries • DbCommand: class that saves data to the database • DbService: class that is called by Command or BusinessService to make multiple operations in the database, usually with the help of DbCommands • BusinessService: class that is called by Command to facilitate a business process
  • 47. Beyond Types: Design Entities We use clear, well defined design entities: • Model: class defining the entity structure and mapping to database • Query: class that encapsulates database queries • DbCommand: class that saves data to the database • DbService: class that is called by Command or BusinessService to make multiple operations in the database, usually with the help of DbCommands • BusinessService: class that is called by Command to facilitate a business process • Command: class that is called by Controller to validate specific HTTP requests and delegate to the right Services the execution.
  • 49. Minimalism exerts a positive pressure on design We still need to understand the code. Without types, how do we understand it? • smaller code
  • 50. Minimalism exerts a positive pressure on design We still need to understand the code. Without types, how do we understand it? • smaller code • better names
  • 51. Minimalism exerts a positive pressure on design We still need to understand the code. Without types, how do we understand it? • smaller code • better names • clear responsibilities
  • 52. Minimalism exerts a positive pressure on design We still need to understand the code. Without types, how do we understand it? • smaller code • better names • clear responsibilities • clear contracts
  • 53. Minimalism exerts a positive pressure on design We still need to understand the code. Without types, how do we understand it? • smaller code • better names • clear responsibilities • clear contracts • clear tests
  • 54. Always Optional Types? NO Clear problem domain, clear solution, not expecting change, used by specialists => strong types, validation at compile time Expecting change, evolving problem and solution domain => minimalism, changeable code, fewer constraints
  • 55. Let’s think differently! “I want the compiler to do as much checking for me as possible”
  • 56. Let’s think differently! “I want the compiler to do as much checking for me as possible” vs. “I want to write the code that makes sense, and the compiler / interpreter to figure it out”
  • 57. Thank you! Come talk to me later and get nice stickers!