Beyond the Code: Identifying and reducing complexity in software development
DmitriiIvanov5
82 views
43 slides
Mar 09, 2025
Slide 1 of 118
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
About This Presentation
What makes software complex? In this presentation, we’ll dive into the various forms of complexity that software teams face, offering insights into how to measure and manage them effectively. From bad architectural decisions and cognitive biases to misalignment and inconsistent practices, we’ll ...
What makes software complex? In this presentation, we’ll dive into the various forms of complexity that software teams face, offering insights into how to measure and manage them effectively. From bad architectural decisions and cognitive biases to misalignment and inconsistent practices, we’ll cover the hidden sources of cognitive load that can hinder productivity and create frustration. By examining how organizational structure and tooling contribute to it, we’ll provide attendees with a toolkit for identifying, avoiding, and reducing unnecessary complexity. Walk away with strategies to make your codebase cleaner and your team’s workflow more efficient.
Size: 9.88 MB
Language: en
Added: Mar 09, 2025
Slides: 43 pages
Slide Content
BEYOND THE CODE: IDENTIFYING AND
REDUCING COMPLEXITY
IN SOFTWARE DESIGN.
Dmitrii Ivanov,
Senior iOS developer @ING
AGENDA
Complexity
What is it? What brings it?
How to deal with it?
How to
measure it?
Complexity
What is it? What brings it?
How to deal with it?
How to
measure it?
WHAT IS COMPLEXITY?
Simplicity Complexity
Cognitive load
INFORMATION PROCESSING MODEL
Sensory
memory
Working
memory
Long-term
memory
Input Attention
Encoding
Retrieval
!
Unlimited
Up to 3 sec
Capacity:
~7 items
5-20 sec
Unlimited
Indefinitely
Capacity: Capacity:
COGNITIVE CAPACITY
Sensory
memory
Working
memory
Long-term
memory
Input Attention
Encoding
Retrieval
Unlimited
Up to 3 sec
Capacity:
~7 items
5-20 sec
Unlimited
Indefinitely
Capacity: Capacity:
OUR WORLD IS COMPLEX!
OUR WORLD IS COMPLEX!
COMPLEX SYSTEMS AROUND US
▸Biological organisms
▸Social constructs and institutes
▸Devises and constructions
▸Organisations
▸Processes
▸Software products
HUMAN-MADE SYSTEMS
ESSENTIAL (INHERITED) COMPLEXITY
HUMAN-MADE SYSTEMS
ADDED (ACCIDENTAL) COMPLEXITY
ADDED COMPLEXITY
ESSENTIAL COMPLEXITY
Inherent to the problem
Introduced by a solution
Sensory
memory
Working
memory
Long-term
memory
Input Attention
Encoding
Retrieval
Unlimited
Up to 3 sec
Capacity:
~7 items
5-20 sec
Unlimited
Indefinitely
Capacity: Capacity:
COMPLEXITY = COGNITIVE LOAD
IMPACT OF BIG COGNITIVE LOAD
▸Low maintainability
▸Steep learning curve
▸Bad scalability
▸Error-proneness
▸Slow decision-making
▸More communication
▸Worse developers' well-being
Complexity
What is it? What brings it?
How to deal with it?
How to
measure it?
Complexity
What is it? What brings it?
How to deal with it?
How to
measure it?
MEASURING COMPLEXITY
“You can't Manage what you can't Measure"
W. Edwards Deming
statistician and quality-control expert
or
Peter Drucker
books author, management consultant
MEASURING COMPLEXITY
1.Lines of Code (LOC)
2.Cyclomatic complexity
3.Halstead volume
4.Maximum Nesting Level
5.Number of Parameters
6.Maintainability Index
func doSomething(x: Int) -> Int {
let y = x + 10
return y
}
func doSomething(x: Int) -> Int {
let y = x + 10
if y > 0 {
return y
} else {
return 0
}
}
MI = MAX(0,(171 -
5.2 * ln(Halstead Volume) -
0.23 * (Cyclomatic Complexity) -
16.2 * ln(Lines of Code)) *
100 / 171)
MEASURING COMPLEXITY
7.Cohesion (how focused are the functions)
8.Coupling (amount of dependencies)
9.Depth of Inheritance Tree (DIT)
10.Response for a Class (RFC)
11.Number of Added Methods
12.Number of Overridden Methods
13.Number of Implemented Interfaces (NOII)
MEASURING COMPLEXITY
7.Cohesion (how focused are the functions)
8.Coupling (amount of dependencies)
9.Depth of Inheritance Tree (DIT)
10.Response for a Class (RFC)
11.Number of Added Methods
12.Number of Overridden Methods
13.Number of Implemented Interfaces (NOII)
1.Lines of Code (LOC)
2.Cyclomatic complexity
3.Halstead volume
4.Maximum Nesting Level
5.Number of Parameters
6.Maintainability Index
Complexity
What is it? What brings it?
How to deal with it?
How to
measure it?
Complexity
What is it? What brings it?
How to deal with it?
How to
measure it?
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
CYCLOMATIC COMPLEXITY
func doSomething(x: Int) -> Int {
let y = x + 10
return y
}
Easier
func doSomething(x: Int) -> Int {
let y = x + 10
if y > 0 {
return y
} else {
return 0
}
}
More difficult
NESTED DATA TYPES
EasierMore difficult
public struct AboutThisAppConfiguration {
public struct Entry {
public enum Content {
case modal(AboutLegalEntryCoordinator )
case confirmedDeepLink(ConfirmationAlertPresenter )
}
public let title: String
public let content: Content
public init(entries: [Entry]) {
self.entries = entries
}
}
public struct AboutThisAppConfiguration {
public let entries: [AboutThisAppConfigurationEntry ]
public init(entries: [Entry]) {
self.entries = entries
}
}
public struct AboutThisAppConfigurationEntry {
public let title: String
public let content: AboutThisAppConfigurationEntryContent
public init(title: String, icon: UIImage? = nil, content: Content,
trackingIdentifier: String, accessibilityIdentifier : String) {
self.title = title
self.content = content
}
}
public enum AboutThisAppConfigurationEntryContent {
case modal(AboutLegalEntryCoordinator )
case confirmedDeepLink(ConfirmationAlertPresenter )
}
NESTED `IF`
EasierMore difficult
if cardIds.count > 1 {
cardDismissHandler()
} else {
if insightsWidgetViewController != nil {
cardDismissHandler()
}
insightsWidgetCoordinatorDelegate ?.dismissWidget(at: insightsLocation)
}
if cardIds.count > 1 || insightsWidgetViewController != nil {
cardDismissHandler()
} else {
insightsWidgetCoordinatorDelegate ?.dismissWidget(at: insightsLocation)
}
if let cardId {
if let element = interaction. element(for: insightsLocation,
cardId: cardId) else {
return
}
} else {
tracker.trackElements(element,
page: analyticsPage(with: productName))
}
guard let cardId, let element = interaction.element(for: insightsLocation,
cardId: cardId) else {
return
}
tracker.trackElements(element, page: analyticsPage(with: productName))
LONG PARAMETER LIST
EasierMore difficult
public func trackFormStep(formId: String,
formStep: String,
formStatus: String,
transactionId: String?,
formOutcome: String?,
formType: String?) {
...
}
public func trackFormStep(content: FormStepTrackingContent ) {
...
}
public struct FormStepTrackingContent : Equatable, Sendable {
public let formId: String
public let formStep: String
public let formStatus: String
public let transactionId: String?
public let formOutcome: String?
public let formType: String?
}
SPECIFIC DECISIONS IN CODE
‣ High cyclomatic complexity
‣ High nesting level
‣ Long parameter list
‣ Complex conditions
‣ Nested if`s
‣ Code duplication
‣ Divergent change
‣ Shotgun surgery
‣ Feature Envy
‣ Data Clumps
…and many more
CODE SMELLS
‣ High cyclomatic complexity
‣ High nesting level
‣ Long parameter list
‣ Complex conditions
‣ Nested if`s
‣ Code duplication
‣ Divergent change
‣ Shotgun surgery
‣ Feature Envy
‣ Data Clumps
…and many more
REFACTORING
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
-Do you mostly need to keep parts
together in mind?
-Are the parts normally used together?
-Is it hard to understand one without
another
-Do they have shared state
(dependency, data model, backend)
-Do they have a common object of
manipulation
-Do they perform different operations?
-Do they perform on a different level
of abstraction?
-Do they have semantical separation
(general - special)?
TOGETHER SEPARATE(IF YES) (IF YES)
func open(url: URL) {
let processedURL = preprocessedURL(url: url)
guard var deepLink = urlHandler.knownExternalDeepLink(url: processedURL) else {
// show Alert
return
}
if let originAwareDeepLink = deepLink as? DeepLinkOriginAware {
originAwareDeepLink. shouldTriggerProfileSelector = configuration.shouldTriggerProfileSelector
}
openDeepLink(deepLink: deepLink)
}
URL DeepLink
openURL()
Components
Host Path Query
Query Parameter
Specific Deep Link
OBJECT HIERARCHY
-Do you mostly need to keep parts
together in mind?
-Are the parts normally used together?
-Is it hard to understand one without
another
-Do they have shared state
(dependency, data model, backend)
-Do they have a common object of
manipulation
-Do they perform different operations?
-Do they have a different level of
detailization?
-Do they have semantical separation
(general - special)?
TOGETHER SEPARATE(IF YES) (IF YES)
-Do you mostly need to keep parts
together in mind?
-Are the parts normally used together?
-Is it hard to understand one without
another
-Do they have shared state
(dependency, data model, backend)
-Do they have a common object of
manipulation
-Do they perform different operations?
-Do they have a different level of
detailization?
-Do they have semantical separation
(general - special)?
COHESION COUPLING
how closely related and focused responsibilities of an item are how tight are the connections between the independent items
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
PROBLEM-SOLUTION DISCREPANCY
▸Not optimal or typical
solution
▸Outdated solution (the
problem evolved)
▸Typical solution for
atypical problem
PROBLEM-SOLUTION DISCREPANCY
▸Inconsistency → Extra
cognitive load
▸Workarounds to align
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
OUR WORLD IS COMPLEX - SO WE MODEL IT
OUR WORLD IS COMPLEX - SO WE MODEL IT
“All models are wrong, but some are useful”
George Box
British statistician
CAR SIMULATOR
▸Car as a moving point
▸Car as a moving point (start/end, acceleration/deceleration)
▸Car as a 2D-model (2D-size)
▸Car as a 3D-model (3D-size)
▸Car as a (very complex) 3D-model (engine, brakes, tires,…)
PICKING PROPER ABSTRACTION LEVEL
Not enough
Details
Too much
Details
Your ideal
abstraction level
Not performing
correctly
Redundant
Added
Complexity
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
ARCHITECTURE
Presentation layer
Business layer
Data layer
ARCHITECTURE
Modularisation
Scalability
Testability
Dependency
injection Separation
of concerns
Single
responsibility
PRINCIPLES RELATED TO SIMPLICITY
▸KISS - Keep it simple, stupid
▸YAGNI - You ain't gonna need it
▸DRY - Don't repeat yourself
▸SRP - Single responsibility principle (part of SOLID)
▸The Unix Philosophy
▸Idea of microservices
AGILE WORK PROCESS
Requirements
Design
Implementation
Testing
Launch
ARCHITECTURAL MISALIGNMENT
AGILE ARCHITECTURE
Evolutionary architecture
Fluid architecture
Design for change
Plug-in architecture
Software should be designed to
evolve over time as business
priorities change, customer
demands shift, and new
technologies emerge
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
COGNITIVE BIASES
- mental shortcuts that trick our brain into thinking
things are true, even when they’re not
COGNITIVE BIASES IN SOFTWARE DEVELOPMENT
▸Complexity bias - discarding the simple solutions
▸Foreseeing the future (over engineering, premature optimisations)
▸Conformism (following trends, Cargo-cults)
▸Anchoring Bias - fixating on one solution, sometimes subconsciously)
▸Confirmation Bias - picking the information based on the existing beliefs
▸Sunk Cost Fallacy - sticking to a solution because of the previous investments
▸Pattern recognition
CONTEXT-SOLUTION MISALIGNMENT
“Developers are drawn to complexity like moths to a flame, often
with the same outcome”
Neal Ford
author, director @ThoughtWorks
DEVELOPERS LIKE COMPLEXITY
DEVELOPERS LIKE COMPLEXITY
▸Simple solutions are boring
GOD SYNDROME
DEVELOPERS LIKE COMPLEXITY
▸Simple solutions are boring
▸God syndrome
▸Social reinforcement of complexity
REINVENTING THE WHEEL
DEVELOPERS LIKE COMPLEXITY
▸Simple solutions are boring
▸God syndrome
▸Social reinforcement of complexity
▸Love to reinventing the wheel
▸CV-driven development
(OVERCOMING) HUMAN NATURE
▸Self-reflect, realise, admit
▸Create safe space for discussion and learning.
▸Discuss your solutions more often
▸Be open to critique and contra-arguments
▸Utilise Decision-Support Systems
▸Rely more on data than on opinions and assumptions
▸Complexity bias: utilise Occam’s Razor, use iterative approach
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
TESLER'S LAW
“Every application or every feature has an inherent amount of
complexity that cannot be removed or hidden. Instead, it must be
dealt with, either in product development or in user interaction"
Larry Tesler (mid-1980s)
computer scientist,
Ex Xerox PARC, Apple, Amazon, Yahoo!
TESLER'S LAW
Complexity
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
What brings it?
How to deal with it?
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Complexity
What brings it?
How to deal with it?
AI-GENERATED CODE - SITUATION
~35%-55% increase in speed of
writing code
Code written with AI-assistance
~10%~30% of our time we spend
on writing code
AI FOR CODE QUALITY
▸Static Code Analysis
▸Dynamic Code Analysis
▸Natural Language Processing (NLP)
▸Suggestions when writing code, or on
the code review
Complexity
What brings it?
How to deal with it?
Specific decisions in codeLogic/code distribution
Problem-solution discrepancyWrong abstraction level
Architectural approach Human nature
Product evolution AI-generated code
Inconsistencies
Bad interfaces
Organisation Dependencies
Technical debt Assumptions
Essentialism Prioritisation
MORE SOURCES OF COMPLEXITY
…AND WAYS TO DEAL WITH IT
DecompositionArtificial restrictions
Explicitness
Decreasing the scope
Learning
Simplicity-first mindset
INCEPTION
IF NOT MANAGED
COMPLEXITY MAY TURN OUR PROJECTS
INTO CHAOS