<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Santosh Vaza</title>
    <description>The latest articles on DEV Community by Santosh Vaza (@svaza).</description>
    <link>https://dev.to/svaza</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F315666%2F339ee1aa-a0ae-4c93-a304-5b34df0b7a25.jpg</url>
      <title>DEV Community: Santosh Vaza</title>
      <link>https://dev.to/svaza</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/svaza"/>
    <language>en</language>
    <item>
      <title>State management made simple - with Angular use case</title>
      <dc:creator>Santosh Vaza</dc:creator>
      <pubDate>Sun, 21 Jun 2020 08:03:09 +0000</pubDate>
      <link>https://dev.to/svaza/state-management-made-simple-with-angular-use-case-3jmh</link>
      <guid>https://dev.to/svaza/state-management-made-simple-with-angular-use-case-3jmh</guid>
      <description>&lt;p&gt;Managing state in an application can sometime become a complex problem, especially when there is a requirement to perform an action when data changes overtime. An action can be as simple as updating a UI component when it happens.&lt;/p&gt;

&lt;h3&gt;
  
  
  What basic functionalities do we expect from a state management lib ?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;centrally managing the state&lt;/li&gt;
&lt;li&gt;get notified whenever data changes&lt;/li&gt;
&lt;li&gt;no memory leaks and performance problems&lt;/li&gt;
&lt;li&gt;manage state over different channels (memory, sessionStorage, localStorage)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/svaza/datastore#readme"&gt;DataStore&lt;/a&gt; library does that all. Right now only MemoryStore is supported, however this should fulfill all the needs of a webapp today. The readme for the library is self explanatory, so I will not post it here.&lt;/p&gt;

&lt;p&gt;Library is a pure javascript library, so it can be used in any javascript platform or web frameworks like react, angular, vuejs.&lt;/p&gt;

&lt;p&gt;It currently has a &lt;a href="https://github.com/svaza/datastore/tree/master/examples/angular#readme"&gt;full blown example&lt;/a&gt; use case in angular that you would like to check out.&lt;/p&gt;

&lt;p&gt;Initially when i developed it a year back, i was required to replicate it in all my projects by copying the source all over. Few days back i just thought of creating an npm package and make it available to community as well. This is where we all can collaborate and share ideas about improving it.&lt;/p&gt;

&lt;p&gt;In case if you have any questions, pls do reach out to me.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>react</category>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Whether NodeJS is right platform for your WebAPIs ?</title>
      <dc:creator>Santosh Vaza</dc:creator>
      <pubDate>Wed, 08 Apr 2020 19:04:10 +0000</pubDate>
      <link>https://dev.to/svaza/whether-nodejs-is-right-platform-for-your-webapis-4p8i</link>
      <guid>https://dev.to/svaza/whether-nodejs-is-right-platform-for-your-webapis-4p8i</guid>
      <description>&lt;p&gt;Javascript is the language for NodeJS platform which is native to all front-end developers, Hence it enables many developers to write server side code without going through additional OR with minimal learning curve. Many developers who have just entered the software development world (A warm welcome to them :) ) find it easy to learn and code in javascript. However NodeJS is not the last bar in server side development.&lt;/p&gt;

&lt;p&gt;I personally like the simplicity of NodeJS, I am a big fan of it's package management system and managing project dependencies. These simplicity comes with a cost. Its not bad but it can be, if one is not aware of below important NodeJS concepts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sJ0UTSdm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4wmkaexr2ojsxedxszv3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sJ0UTSdm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4wmkaexr2ojsxedxszv3.png" alt="Javascript runtime"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Single Threaded
&lt;/h2&gt;

&lt;p&gt;The javascript code whether in browser/nodejs executes on one single main thread called as Event loop. So it means that while the javascript code is in execution (For example : A long running while loop) no other parts of your application will be able to run at that time, Not even callbacks like event handlers or ajax callbacks etc. Every such callbacks ariving that time will be queued to internal Message Queue and will be processed one after another based on their arrival. If the main thread is idle and a message arrives in a message queue (basically a notification to execute a callback), &lt;a href="https://nodejs.dev/the-v8-javascript-engine"&gt;v8&lt;/a&gt; will execute it on main thread with right context. This is how a callback function remembers the enclosing lexical scope..... closures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Non Blocking asynchronous I/O
&lt;/h2&gt;

&lt;p&gt;A callback function is provided while instructing NodeJS to perform I/O operation (Reading/Writing a file, Socket operations). The actual I/O operation performs on the background thread called as worker pool, while it happens, V8 further continues to execute your remaining part of function. If there is no javascript code to further execute and I/O is still in process then we say that main thread blocked.&lt;br&gt;
While a thread is blocked working on behalf of one client, it cannot handle requests from any other clients.&lt;/p&gt;

&lt;h2&gt;
  
  
  CONCLUSION
&lt;/h2&gt;

&lt;p&gt;So this means that in a NodeJS web server scenario your web application runs on a single thread and if a request takes time to execute then this will result in very poor performance because it will make other requests to wait until current request execution is finished. It becomes very important that you shouldn't do too much work for any client in any single callback or task. Every request should be completed very fast. This is the reason why NodeJs can scale well, but it also means that you are responsible for ensuring fair scheduling.&lt;/p&gt;

&lt;p&gt;If the code that is written on NodeJS platform is going to take more time or CPU then one should think, Whether NodeJS is right platform for your WebAPIs? &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>beginners</category>
      <category>microservices</category>
    </item>
    <item>
      <title>Should your product be using Microservices architecture ?</title>
      <dc:creator>Santosh Vaza</dc:creator>
      <pubDate>Tue, 11 Feb 2020 15:08:02 +0000</pubDate>
      <link>https://dev.to/svaza/should-your-project-be-using-microservices-architecture-552m</link>
      <guid>https://dev.to/svaza/should-your-project-be-using-microservices-architecture-552m</guid>
      <description>&lt;h1&gt;
  
  
  Microservices...Complexity
&lt;/h1&gt;

&lt;p&gt;This has been thought many times by Leads/Architects when they begin to think of the product's architecture long before dev folks begin to write code. This could be one of the important decision to make because a simple product could become overly complex OR complex product disguised as simple in beginning could become pain for team(s) to catch up with growing requirements and BUG fixes.&lt;/p&gt;

&lt;p&gt;Microservices architecture is indeed a complex thing to manage given the amount of thought process put into planning/designing those tiny/thin services, setting up CI/CD pipeline, separate git repositories.. etc. However if done carefully its pretty much manageable.&lt;/p&gt;

&lt;p&gt;It is a distributed architecture and every distributed architecture brings with these concerns&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Security, SSO, Authorization&lt;/li&gt;
&lt;li&gt;Logging&lt;/li&gt;
&lt;li&gt;Service endpoint abstraction - Amount of information sent back to client&lt;/li&gt;
&lt;li&gt;Availability, SLA for each service&lt;/li&gt;
&lt;li&gt;Performance &lt;/li&gt;
&lt;li&gt;Transaction Management - Really you want to look into 2 Phase commit, Its pretty old actually and does not suit well when there are different kinds of DBs used ?&lt;/li&gt;
&lt;li&gt;API Orchestration - Synchronous or Asynchronous communication, Event based&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is not just developing/setting up those tiny/thin services which do not share databases. It's a lot more than that. Many folks underestimate the &lt;a href="https://martinfowler.com/articles/microservices.html#CharacteristicsOfAMicroserviceArchitecture"&gt;characteristics of Microservices&lt;/a&gt; and begin to plan projects with half knowledge which burns everyone hands later on. One of the most important prerequisite before starting to think of using Microservices is -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;u&gt;DDD (Domain driven design)&lt;/u&gt;&lt;br&gt;
Its a set of practices and methodology that enables a team to break complex product into more manageable logical pieces which would be much close to real world. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When your project is close to real world you do not need to use those additional neurons in your brain to map the discussions to your software after a conversation with BA. That's because your software world is the real world so you and your devs save some time/energy there.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;u&gt;Microservices patterns&lt;/u&gt;&lt;br&gt;
Many concerns which are straight forward to manage in a monolithic (a single solution based project, sharing databases, old protocols/formats) might not be easy thing to chew when stuff gets distributed across tiers. Microservices patterns helps to solve such concerns.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Chris Richardson does his best to explain these patterns and concerns they solve in this website &lt;a href="http://microservices.io"&gt;Microservices and Patterns&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Microservices requires to develop a thought process inorder to take right and efficient decisions which can be done if you are well aware of DDD and Microservices patterns.&lt;br&gt;
Explaining everything about Microservices is beyond the scope of this blog and deserves a book of its own. However i have tried best to show the complexity behind microservices which are easily manageable if you know that you are doing right.&lt;/p&gt;

&lt;h1&gt;
  
  
  Should you be using microservices ?
&lt;/h1&gt;

&lt;p&gt;Amazon, Facebook, Netflix, Google.... and many more companies have started to go service oriented more than a decade ago. So if they do why not us ? &lt;/p&gt;

&lt;p&gt;Well.. thats a pretty vague comment to say "YES" unless its backed by a good analysis and research. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;An important thing to remember is that things can be changed in future, Your app or services should be moldable, So it depends on how coupled your components/services are, how much abstract your interfaces are ?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These are few items which you should think in depth at the time of this research and decision making&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Domain&lt;/li&gt;
&lt;li&gt;Depth of the product/project&lt;/li&gt;
&lt;li&gt;Integration with other inhouse/3rd party products and services&lt;/li&gt;
&lt;li&gt;Complexity of the project, number of teams or people involved&lt;/li&gt;
&lt;li&gt;Release methodology, Versioning, SDLC, CI/CD&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's go above points one by one&lt;/p&gt;

&lt;p&gt;(1). &lt;u&gt;Domain&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Having a good knowledge of your domain OR subdomain (a part of the organisation's larger domain) will help you to forecast how future requirements will change existing features and design of the app, You can ask right questions to BA and stakeholders if you know your domain well. Because no one from stakeholders cares about what future requirements/client demands will at present, when they come OR requirement changes its just as simple as to hand over these changelist to engg team and expect it to be completed within the given deadline. If a careful thought is not given over this, then it would create a mess over the time and eventually lead to &lt;a href="https://en.wikipedia.org/wiki/Big_ball_of_mud"&gt;Big ball of Mud&lt;/a&gt;.&lt;br&gt;
If you know your domain, you can create your app or service more modular from design point of view in very beginning it self. Even if requirement changes the impact wont be much because there wont be any hardcode dependencies. &lt;/p&gt;

&lt;p&gt;If you remember that we discussed DDD as an important prerequisite, You should be able to answer one of the most important question in microservices&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How many number of Bounded Contexts should a subdomain have?&lt;br&gt;
Viz. Does this new feature belong to a new service OR it can be setup in one of my existing services ?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;(2). &lt;u&gt;Depth of the product&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;All points discussed as part of #1 applies here as well as it is. &lt;br&gt;
Your product would be a subdomain or a piece of subdomain.. viz a BoundedContext. One benefit of knowing your product is that you can actively participate during feature planning and create effective features/stories. You can effectively scope your feature/stories with right DoD items and make your Scrum Master and PO happy ;)&lt;/p&gt;

&lt;p&gt;(3). &lt;u&gt;Integration with other inhouse/3rd party products and services&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;You can create effective outbound ports and adapters Viz.. interfaces (refer Hexagonal Architecture). You can structure your project well if you know your consumers well and which architectural design you would like to follow for your project.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This would require you to think and create an effective API endpoint and responses by applying appropriate &lt;a href="https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm"&gt;REST principles&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You will need to think of concerns we discussed before.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(4). &lt;u&gt;Complexity of the project, number of teams or people involved&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Well you cannot attribute a project to be complex only if it makes use of some unique or fancy algorithm but a large project can be overly complex too. Initially it might not seem so, disguised like a simple service if you do not think of above points then it can grow overly complex. &lt;br&gt;
If you know the parts of your products which are complex and need more CPU cycles, they can be extracted to cloud functions (Serverless arhcitecture), OR you can have a dedicated Server for such processing.&lt;br&gt;
Large project means more people and there is a good chance of people stepping onto others feet. Collaboration becomes more difficult if these people spans different teams and teams spanning different locations. &lt;br&gt;
The smaller the project better its manageable, however boundaries should be defined very well&lt;/p&gt;

&lt;p&gt;(5). &lt;u&gt;Release methodology, Versioning, SDLC, CI/CD&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;If your project is to be released frequently, you do not want to request QAs test those part of your project which does not have any logical relation to feature developed.. It might seem so from outside, But from inside they might have some dependency on a class which have been refactored in this release, So every feature which depends on that class needs to be sanity tested. &lt;/p&gt;

&lt;p&gt;The point is over the time few of such classes become concrete dependencies and this bond only grows strong over the time. Even if such pieces are extracted out and versioned you cannot use different versions for different modules in same solution/project. Long point short... You cannot perform incremental refactoring (Means that pointing only essential modules which are relative to this release to use newer version of refactored class and letting others to keep on using old one, If they were separate services they can keep on using older version of that lib)&lt;br&gt;
So you might think of not having all modules as part of same solution...... one day. With Large projects it increases the build/deploy time and it only increases. A small change in Module X will trigger build and deployment of your entire service and folks testing Module Y will not be happy with that commit.&lt;/p&gt;

&lt;p&gt;So after deeply thinking of these 5 points above, you might now be well aware of whether your new product needs microservice architecture ?&lt;/p&gt;

&lt;p&gt;If not right now then you can predict it would, sometime in future because you know your domain/subdomain very well.. and i appreciate that :). The important point to note right now is that you keep on developing your solution more modular and keep your interfaces abstract both internal and external, So that refactoring in future becomes easier.&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>api</category>
      <category>serverless</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
