On my Twitch streams lately, I’ve been using the composable architecture to rebuild my app iHog. It’s been a great time, but it also had me thinking about what is an architecture and what is the purpose of one. So this video isn’t going to dive into the composable architecture but more so speak to what an architecture is and why you should more than likely be using one.
This video ISN'T going to cover into how to implement an architecture, but if you're interested in seeing the composable architecture in action hop over to my Twitch.
What is app architecture
First, lets get on the same page as to what an architecture even is in software development.
It’s actually quite similar to building architecture. It’s patters and techniques used to build and design an application. There are best practices and standards that can be found or have been talked about at length at conferences, on youtube channels, or even on blogs, and usually following a proven architecture will yield the best results, but you can choose from patterns and techniques that already exist or mix and match and make one that works for you and your app.
I advocate for choosing patterns that already exist because it’s then easier to explain the thought process and get feedback from another developer.
Different mobile app architectures
Some examples in iOS and mobile development include
MVVM - Model → View → ViewModel
- The Model represents the data and or info we are dealing with.
- The view displays the model’s information
- The ViewModel (one word) is where controls for interacting with the view live. Usually bindings are used to connect the UI elements from the View to controls in the ViewModel
MVC - Model → View → Controller
- Just like in MVVM, the model represents the data and information we are dealing with
- The View presents that data to the user
- The Controller manipulates the data and makes sure it can update the model
The Composable Architecture
Which I mentioned at the beginning is a redux unidirectional data flow architecture. Everything happens from the store and you emit actions to change the store’s state.
Sign up for 1 month free
There are definitely more, but these are the ones I see the most talk around and The Composable Architecture is quite new and getting a lot of buzz.
Why you should use one
Finally, why should you consider using an architecture and adhering to the patterns?
- It keeps code clean
Usually architectures support the separation of business and view logic and this allows code to be a bit cleaner and reusable
- Code is more readable
Following a structure allows code to be more readable since the code base should have a similar style.
- Gives structure to how to solve a problem
A decent architecture will give you a guide on how to solve the problem. It can help give you bumpers as to what to return or how you want to pass data around.
Let me know in the comments which architecture you like to follow!