## Why Software Architecture Should Matter
_“Have you ever been in a situation where you’ve felt nervous about adding new code to an existing codebase in the fear that you’ll break something else in a completely different part of the code somewhere?”_ Khalil Stemmler - https://solidbook.io/
---
### Why do we rewrite pieces of our software?
- Inexperience
<!-- You don't want to spend the time to understand someone else's code.
Maybe not familiar with a concept.
-->
- Fun
<!-- We software developers enjoy rewriting things -->
- Better solution available
<!-- New library or technology that solves the problem in a better way -->
- Technical Debt
---
### Technical Debt
Code that negatively and repeatedly impacts the speed and quality of delivery
<!-- People think of it differently
Code I didn't write?
Code I wrote before I knew what I was doing?
Old libraries?
Unused features?
-->
---

<!-- As time passes, our ability to add new features decreases -->
---

<!-- Takes a long time to extend/mantain the system.
Developers might argue that the company won't be able to
retain them and demand a refactor.
-->
---

<!-- Everything is beautiful. Delivering features faster again and then the speed of delivery is reduced again.
-->
---
#### Recurring technical debt or Technical debt on a subscription model
---
#### Second System Effect
The tendency of replacing successful systems with bloated and over-engineered systems due to inflated expectations and overconfidence.
---
### Is that our Destiny? Are we in an infinite loop of rewriting code?

---
### Status Quo
- devs **not** being taught essential software design and architecture skills
- most companies practice **agile**
- agile = often **changing** and refactoring code
- to refactor code we need **tests**
- to write tests we need **testable code**
- devs can't write testable code
---
### Common Developer Path 👨💻
- Understanding technology and what it can do
<!-- University, Bootcamp or Self-Educated -->
- Learning and using tech to build things
<!-- Able to produce something meaningful and make things work even if it requires some brute force -->
<!-- Many developers can end here and stop their carreer progression. Just because you can write code, it doesn't mean you can write mantainable and high quality code -->
- Learning how to solve business challenges consistently while mantaining productivity
<!-- This is specially important when working in growing teams.
When working in smaller teams, even if things get a little messy,
you're still able to understand most of the code and move fast.
Communication is also easier and you'll have less code/features.
-->
---
`The real cost 💰 of software is not the initial development, but maintainance over time 🔧`
---
Maybe the question shouldn't be why we rewrite software, but rather:
**How can we make our systems more resilient to changes that are inevitable?**
## **Good architecture!**
🤪Wow, you're a genius! 🙄
<!-- Architecture has become a dirty word
Sounds elite
No clear definition
Feels detached from daily problems
-->
---
#### What is Software Architecture?
_"Software architecture is the structure of a system, the **elements** it contains, and the **relationship** between those elements"_
---
_"the shared understanding that the expert developers have of the system design"_
<!-- Email exchange between Martin Fowler and Ralph Johnson https://martinfowler.com/architecture/ -->
---
_"the decisions you wish you could get right early in a project"_
---
_"Architecture is about the important stuff. Whatever that is"_
<!-- It means that the heart of thinking architecturally about software is to decide what is important, (i.e. what is architectural), and then expend energy on keeping those architectural elements in good condition. -->
---
### Why does archictecture matter?
- ### Basis for Communication
It's a plan of the system that facilitates communication between stakeholders (dev, design, customer, management)
###### **User**: is it reliable and available?
###### **Manager**: can it be implemented on schedule and on budget?
###### **CTO**: can teams work independently?
<!-- Quality Attributes or Non-Funcional Requirements
-- Availability, Security, Configurability, Usability, Reliability
-->
#### Quality Attributes
###### Define the success of the architecture and quality of the system

<!-- Usability:
- control how many actions to perform action
- average time to perform actions
-->

<!-- Maintainability - how well does the system support changes?
- might have excessive dependencies between areas of your app
- Layered/Hexagonal/microservices to control the dependencies
- Important to split teams
-->

<!-- -->

---
- ### Architecture enables constraints
It dictates the actions we are allowed to take when developing our system
**Constraints = Safety and Speed**
<!-- Helps us move faster!
Same way as Functional programming constrains us with immutability and avoids race conditions
-->
---
- ### Poor Architecture contributes to the growth of cruft
cruft = elements of the software that impede the ability of developers to understand the software
<!-- Software that contains a lof of cruft is much harder to modify. More bugs and features are slower to develop -->

###### https://martinfowler.com/architecture/
---
Have you ever heard the following?
_"We need to put less effort on quality so we can build more features for our next release"_
Not really.
###### High internal quality leads to faster delivery of new features, because there is less cruft to get in the way.
<!-- Quality can be subjective to the project. It relates to the Quality Attributes.
-- E.g. Modular design, few defects, extensible, pleasant user interface, etc.
-->

###### https://martinfowler.com/architecture/
<!-- While it is true that we can sacrifice quality for faster delivery in the short term, before the build up of cruft has an impact, people underestimate how quickly the cruft leads to an overall slower delivery. -->
<!-- Competitive advantage -->
---
### Architectural Styles
How to organize our code to meet the quality attributes
<!-- How components, modules, layers, etc interact with each other -->
Architectural styles can be implemented in various ways using different languages, frameworks and technologies
---
#### Monolithic app
###### Such as our editor or participant view
---
#### Layered
###### A layered architecture also constraints the dependencies between the layers. A layer can only depend on the layer immediately below it.
```
Presentation Layer
⬇️
Business Logic Layer
⬇️
Persistence Layer
```
---
#### Microservices
###### Instead of developing one large application, you structure the application as a set of services
###### [Developing Microservices](https://www.youtube.com/watch?v=kyNL7yCvQQc&t)
---
**You can use several architectural styles**
###### For example, you could have microservices where each service is implemented following the hexagonal architecture style. This is possible because architectural styles might belong in different dimensions.
---
To be continued...
---
### Summary
###### -> Mantaining a software is much more expensive than building it from scratch
###### -> Architecture is a way of defining constraints that allow us to gain speed and safety
###### -> Architecture helps with communication and vision
###### -> A good architecture enables faster delivery