- Developer's Commute
- Posts
- Basic Software Principles for every programmer - Developer Commute
Basic Software Principles for every programmer - Developer Commute
Today we will explore more about Basic Software Development Principles, some interesting tweets, articles, memes
Good Morning, It’s your captain speaking. Welcome aboard the Developer’s Commute. Today we will explore more about Basic Software Development Principles, some interesting tweets, articles, memes and in the end, Coding Motivation to keep you moving We hope that you enjoy this ride with us and you have a pleasant journey ahead.
Code Philosophy
Gif by Smolverse on Giphy
Understanding the Basic Software Development Principles
One quality of a noob developer. He starts writing code without any plan in mind. One quality of a senior developer. Always have a plan before writing any code.
What kind of plan am I talking about?
No, it is not the plan to bring world peace or find exoplanets.
It's about developing production-grade apps that are maintainable, sustainable and testable. So how can we make a good production-level app with best practices?
By following simple Software principles like KISS, DRY and SOLID.
In this newsletter, I will be talking about the SOLID principle and how can we apply it in Android development. I will be breaking down these principles over time and hopefully, you can learn from them and plan your code accordingly.
Let's start with the basics of SOLID.
SOLID has a few parts:
S → Single Responsibility
O → Open/Close
L → Liskov Substitution
I → Interface Segregation
D → Dependency Inversion
Let's start with Dependency Inversion. Dependency Inversion has certain rules that help us design better software.
→ High-level modules should not depend on low-level modules both should depend on abstractions.
→ Abstractions should not depend on details. Details should depend upon abstractions.
These two lines sound like some high-level programming stuff but it is not. Instead, you might be already using it in your code without realizing it.
High-level modules are those modules that observe the business logic to perform actions. In contrast, low-level modules are those modules that contain logic for the high-level modules. For example, Jetpack Compose UI observes the ViewModel to perform certain actions. In this example, the Compose screen forms the low-level module whereas ViewModel forms the High-level module.
According to Dependency Inversion, the High-level modules should be dependent on low-level modules. It means that viewmodel (high-level) should not be dependent on the jetpack screen (low-level). Instead, both should depend on abstractions like using interfaces.
Let's explore the second line, It suggests that abstractions should not depend on details. For example, an interface should not depend on a repository. Instead, details must be dependent on abstractions.
Let me give you one more example.
Suppose we want to store token data received from an API call. We can do it in two ways:
→ Using Shared Preferences
→ Using Data Store
Suppose we are storing using shared preferences. The function used for storing is being called inside of the repository. So we can only change the function by changing the logic inside of the repository. This practice can impact the repository code.
What if we can change the storage method by changing one word?
We can inject an interface of the shared preferences class inside the repository’s constructor. And take the token data from the repository and store it using a shared preferences class. Now in future, if we want to change the storage method, we can change the interface in the constructor. To change the storage method.
APIrepo(val sharedprefencesInterface){ ------------> val datastoreInterface
-----
-----
Taking the token data from the repository
}
Class Shared Preferences(){
---- storing token data
}
Class Datastore(){
---- storing token data
}
This is the basis of Dependency Inversion.
We will explore more parts of the SOLID principle in upcoming newsletters and see its implementation in code.
This is for today I hope enjoyed this newsletter. If you enjoyed it please let me know and if I have written something wrong please forgive me.
Thank you for reading
Regards,
Developer Commute’s Captain
Free Ebook
Developer Meme
Tweets That You Might Love
Tweets That You Will Find Interesting
API based Auth using Retrofit
Here is an interesting tweet for you →
Android Developer aye?
Do you know how to perform Authentication?
Not with Firebase instead with API using Retrofit
Here is everything:
(1/13)
— Hitesh Kohli | Android Developer (@Hitesh__kohli)
2:38 PM • Dec 11, 2023
Collection of Important threads →
Android Developer aye?
If you want to learn more about Android Development
Then these threads are important
Here are a few :
(1/8)
— Hitesh Kohli | Android Developer (@Hitesh__kohli)
6:32 AM • Dec 9, 2023
Microservices Explained
Here is something interesting for you→
What does a typical microservices architecture look like?
Load Balancer
- Distributes incoming client requests across API gateways for high availabilityCDN (Content Delivery Network)
- Caches static content in distributed edge servers for high performanceAPI Gateway
- Load… twitter.com/i/web/status/1…— Sahn Lam (@sahnlam)
6:14 AM • Dec 12, 2023
ArticlesThat You Might Love
Gif by scaler_official on Giphy
Articles That You Will Find Interesting
Clean Architecture is a Mental Dysfunction
Here is an interesting article that you might want to check out →
Become a 10x Software Engineer with Bayesian Thinking
Here is an interesting article for you →
Apps I Use And Why You Should Too.
Here is an interesting article for you →