Shubham Seth
[Code]Sharing is Caring
So WHY are we talking about this?
If you are working on a piece of code that has potential to be scaled or used across multiple projects/frameworks/domains/paltforms , then you should be able to write it in a way that it can be shared everywhere and you should also be aware of tools , that helps you achieve code sharing across multiple things.
Modularization is important: The code should be divided into loosely coupled modules that perform there task well and can be re-used everywhere where it is needed without and dependencies on the project ( loosely coupled ).
-->
If you have been working in large projects you know that after a point of time the code gets repetitive and we just need same boilerplate kind of code everywhere , so in these scenarios , if your code is not divided in re-usable independent components then it will really be a tough job to share the code across the project easily.
So the idea is to identify during the development , that if this piece of code and be used somewhere else in future or not , if there is even a slightest chance that, work that your doing can be helpful to someone later in some other part or in some other way , you need to make sure to write it as an individual component that takes some inputs and produces some output , and then use that component where ever you want . This way the code can be re-used at multiple places in future too.
The more stronger the coupling is among the code the harder it is for that project to scale without creating circular dependencies. Hence break the work in smaller units to make a scalable larger feature.
-->
Now to understand this scenario let's take an example. Say you are working on a project that runs on Angular framework and you have got a requirement to make an extensive and custom Form Builder for your application. So you put all your efforts in and churn many hours and make a component that works as a Form Builder and works very well, but you have made it using Angular and for Angular. Now if another team is working on a project in React and there also got a requirement to make Form Builder, now you all know that it is already made, but you can't just use that directly in React as it is strictly coupled with your Angular architecture... So in this case you could have used something like web components that makes your job easier to use code across the frameworks. If you write your reusable code in web components then you are not locked in by any framework to use that code in, in future if you decide to migrate your entire project in another framework you won't have to write entire thing again in new framework if most of the things were plug and play using something like Web Components.
So again, anyplace where you think code can be reused, should be decoupled from its surroundings and written independently as a plug and play utility tool, which expands its use case to places you cannot think of while developing.
-->
Time to level up the game !! Now this is a path which is not travelled enough yet, but soon enough there will be enough chatter around it as we move into cross-platform development. The path I am talking about here is to share the code between a web application , a mobile application and a desktop application.
There is a well known way of doing this in some frameworks like React, where we can easily share code between React and React Native. Similarly same can be achieved in Angular and Ionic. But what if we want to achieve this in Angular and React Native or React and native IOS/Android app ? There is no straight away way for that , but there are some tools like Style Dictionary that help to share styles across platforms.