Things I’ve Learnt Switching From JavaScript to C#!
Introduction:
This week’s blog post aims to brain-dump initial thoughts after switching from JavaScript to C#.
As always, before we get into this week’s blog post, please make sure to applaud, comment and share with your friends.
Happy Reading!
Concepts:
Interface as a Contract:
Back in uni, I actually really used to struggle with the idea of interfaces. “Why are we using this abstraction? Let’s just use the original class without an interface?”
Looking back now, it’s actually really obvious why (I guess this shows growth at least)!!
We use interfaces to avoid tight coupling and to ensure that the implementation of 1 class does not break another class.
All we need to do is inform 1 class what is expected of it, rather than going deep into the specific implementation.
Nowadays, I’d like to say I’m comfortable with interfaces. Of course this will improve over time but at least now, I’m clear on what they do and how they relate to the code that I write.
Design Patterns (Decoupling):
I’ll list a few here: Dependency Injection, Singleton, Repository Pattern.
I mentioned this in last week’s blog post but I could never really appreciate design patterns until making the shift to C#.
Just How Valuable Types Can Be (Even After Using TypeScript):
So when I first started with Python and JavaScript, there was little to no types in use. This kind of turned my programs into a ‘free for all’ where as the codebase got larger, it was more challenging to predict the expected value.
Nowadays I’ve moved onto a codebase which is absolutely huge and to be honest, the types have saved me. They make it far simpler to navigate the code base (I’ve already touched on interfaces) and they really do break down the system.
Conclusion:
I’m just getting started with C# and I’m already picking things up.
Yes there are challenges but it’s going to take time and all 3 concepts that I’ve mentioned will supplement my future development.
Final Things:
As always, thank you for taking the time to read this article!
All my links are here!