Author: Hayden Smith 2021
Why?
What?
Complexity that is inherent to the problem.
For example, if the user or client requires the program to do 30 different things, then those 30 things are essential
Complexity that is not inherent to the problem.
For example, generating or parsing data in specific formats.
Fundamentally can't be removed, but can be managed with good software design.
Can be somewhat mitigated by engineering decisions; e.g. smart use of libraries, standards, etc.
Hard to remove entirely.
Can we look at some code examples to analyse?
def foo():
if A():
B()
else:
C()
D()
A
B
C
D
def foo():
if A():
B()
else:
if C():
D()
E()
A
B
C
E
D
def foo():
while A():
B()
C()
A
B
C
def day_to_year(days):
year = 1970
while days > 365:
if is_leap_year(year):
if days > 366:
days -= 366
year += 1
else:
days -= 365
year += 1
return year
def day_to_year(days):
year = 1970
while days > 0:
if is_leap_year(year):
days -= 366
else:
days -= 365
year += 1
return year - 1