Clean Code
Robert C. Martin
Oct 18, 2019
Iris Software, Inc.
Confidential 1 When IT matters, we deliver.
Confidential
Why Concurrency
Question: What is Concurrency ?
Answer:
Concurrency is the ability to run several programs or several parts of a program in parallel.
Concurrency is a decoupling strategy. It helps us to decouple what gets done from when it gets done.
“In single-threaded applications what and when are so strongly coupled”
Question: What are the benefits of Decoupling ?
Answer:
Decoupling what from when can dramatically improve both the throughput and structures of an
application.
From a structural point of view the application looks like many little collaborating computers rather
than one big main loop.
This can make the system easier to understand and offers some powerful ways to separate concerns.
for example, the standard “Servlet” model of Web applications.
Confidential 2 When IT matters, we deliver.
Myths and Misconceptions
Question: What are Myths and Misconceptions ?
Answer:
Concurrency always improves performance.
Design does not change when writing concurrent programs. (The decoupling of what from
when usually has a huge effect on the structure of the system).
Understanding concurrency issues is not important when working with a container such as
a Web or EJB container.
Confidential 3 When IT matters, we deliver.
Concurrency Defence Principles
Single Responsibility Principle
Limit the Scope of Data
Use Copies of Data
Threads Should Be as Independent as Possible
Know Your Library
Use the provided thread-safe collections.
Use the executor framework for executing unrelated tasks.
Use nonblocking solutions when possible.
Confidential 4 When IT matters, we deliver.
Problem Statements
Producer-Consumer
Readers-Writers
Dining Philosophers
Confidential 5 When IT matters, we deliver.
Learn these basic algorithms and understand their solutions
Beware Dependencies Between Synchronized Methods
Confidential 6 When IT matters, we deliver.
Thank You!
Confidential 7 When IT matters, we deliver.