<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sahil Hemnani on Medium]]></title>
        <description><![CDATA[Stories by Sahil Hemnani on Medium]]></description>
        <link>https://medium.com/@hemnanisahil777?source=rss-448ef54a39c2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pU4dQJbfw7VIGuG6qLdsjA.jpeg</url>
            <title>Stories by Sahil Hemnani on Medium</title>
            <link>https://medium.com/@hemnanisahil777?source=rss-448ef54a39c2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 08:28:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hemnanisahil777/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Blockchain-the decentralized way]]></title>
            <link>https://hemnanisahil777.medium.com/blockchain-the-decentralized-way-a216041e346c?source=rss-448ef54a39c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a216041e346c</guid>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Sahil Hemnani]]></dc:creator>
            <pubDate>Wed, 19 Jan 2022 21:09:55 GMT</pubDate>
            <atom:updated>2022-01-19T21:09:55.083Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7LOxdNdSJyxwwi4OT3F5uA.jpeg" /></figure><h3>What is Blockchain</h3><p>A blockchain is a distributed database that is shared among the nodes of a computer network. As a database, a blockchain stores information electronically in digital format. Blockchains are best known for their crucial role in maintaining a secure and decentralized record of transactions. To oversimplify this we can say that it is a chain of blocks in which every block contains some details or records of a transaction, which is immutable and can never be deleted.</p><h3>What’s Different?</h3><p>To understand this we need to look over the general client-server architecture and the drawbacks/limitations of the architecture, and how blockchain solves the issues.</p><p>So let’s first understand the client-server model- it describes <strong>how a server provides resources and services to one or more clients</strong>. Or in simple words, two clients(devices) can only communicate, share or transfer data via a central server. Examples of servers include web servers, mail servers, and file servers. Each of these servers provides resources to client devices, such as desktop computers, laptops, tablets, and smartphones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/0*E4vkO6q6JYoqE1zH" /></figure><p>For example: If <strong>person A</strong> wants to send some funds to <strong>person B </strong>then the fund transfer will be via the central authority for example the bank server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*qzjvwztGEfPn67QM" /></figure><p>so there are a few issues with this architecture like</p><ol><li><strong>3rd party dependence: </strong>both person A and person B are dependent on the other 3rd party for their transaction to be completed. If there are any issues with the bank, both will have to face trouble and the process of the fund transfer can be delayed.</li><li><strong>Centralization: </strong>There is a central authority that is transferring the funds from one person to another, moreover both will be so dependent on the central authority that they have to anyhow trust the process and proceed. The process of transfer is also defined by the bank and cannot be modified according to the needs of persons- but is that required? can’t we directly transfer funds from A to B?</li><li><strong>Security concern: </strong>when person A has to transfer funds to person B then, A has to send his/her details to the central authority and also B will have to give his/her details to the central authority. These details might include the things which you may not want to share but have to share to proceed, also some of your details will be then sent to advertisement companies and will be used by them for marketing purposes (without your concern). So this is a big security breach.</li><li><strong>Costs: </strong>While A will be transferring the funds to B, there will a cost of transfer attached to the transfer. If the transfer is international then the cost will be enormous, and sometimes non-affordable. There are some other costs also related to this system like GST, maintenance charges etc which are sometimes hard to bear.</li><li><strong>Trust: </strong>While transferring the funds- we need to understand that only the funds have been transferred from the acc. of A to acc. of B but the fund is actually with the central authority only. So if in any case or the worst case, the central authority goes bankrupt- both A and B have to bear its consequences.</li><li><strong>Mutability: </strong>While transferring funds from A to B, the central authority creates a record of the transaction in a database or on a mutable object, this is a reason to worry because the record can be tamper or be modified for some reason or by mistake. Isn’t there a way in which we can make the record mutable?</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/0*hNcjqO5l33bNIZKc" /></figure><blockquote>Here is when blockchain comes to the rescue.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*v9fIxAZ0Vn87MFao" /></figure><p><em>There’s a new term introduced here- </em><strong><em>SMART CONTRACT!<br></em></strong><em>A smart contract</em><strong><em> </em></strong><em>is a piece of code deployed on a blockchain that contains details about the transaction and what needs to be done post-transaction. It simply removes the use of central authority and makes the blockchain decentralized. smart contracts are immutable and can not be deleted, modified by anyone in the world once it has been registered on the blockchain.<br>Think of a smart contract as a piece of government bond which is between two parties but digital and immutable at all costs.<br></em><strong><em>Note: </em></strong><em>unlike bonds, no one owns smart contracts but the blockchain stores them and they can never be deleted or modified. So if any transaction happens it is always noted there on the blockchain.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/0*wBX5vYU-1NMo2Kps" /></figure><p>Now let’s understand how blockchain helps achieve decentralization and resolves all the major 6 issues:<br><strong>3rd party dependence: </strong>both person A and person B are dependent on the other 3rd party for their transaction to be completed. If there are any issues with the bank, both will have to face trouble and the process of the fund transfer can be delayed.</p><ol><li><strong>3rd party dependence:</strong> now both person A and person B are independent on the other 3rd party for their transaction to be completed. We can see how smart contracts have resolved the issue.</li><li><strong>Centralization: </strong>As we can see the transfer from A to B just requires a piece of code(smart contract) and no one owns that, so we have achieved de-centralization. We are not dependent on any 3rd party application or central authority for the transaction to complete.</li><li><strong>Security concern: </strong>Blockchain is a secured way of computing, everything works on a hashing and can not be decrypted. When A sends funds to B it does not directly use his key to sign the smart contract, but it makes a hash from his key, amount to be transferred, nonce, contract-id and sends it to B so that only the smart contract can decrypt the hash and ensures security. If it seems a bit tricky or overwhelming at first- then You are on the right way.</li><li><strong>Costs: </strong>As there is no 3rd party involved in the process, A and B only need to pay the fees to deploy the smart contract on the blockchain which is very less if we compare to the central authority fees in a central system. Also, the international transfer does not carry any additional charges here as everything is digital.</li><li><strong>Trust: </strong>There is no mediator between A and B from which the funds will flow so trust is not an issue here. Also, there are validators on each blockchain to verify and validate the transaction. If the transfer is incomplete due to some error or flaw in the system, the contract is reversed and the funds are safe with both A ad B.</li><li><strong>Mutability: </strong>As we know smart contracts at any cost, can not be changed, modified or deleted so they are immutable. Once a block(transaction) has entered in the blockchain, it can not be removed hence achieving 100 per cent immutability.</li></ol><p>This is how blockchain helps to make the system more secured, cost-efficient and decentralized at the same time.<br>This is the reason why there is a need to shift to a new environment of development- that is <strong>The Blockchain Way.</strong></p><p><strong>DISCLAIMER</strong>: <em>This article is intended for educational purposes, author of this writer is not responsible for any illegal action imparted by the readers.</em></p><p>Thank you! for more such content let’s connect on LinkedIn.</p><p><a href="https://www.linkedin.com/in/sahil-hemnani-8084b41a6/">Sahil Hemnani - Software Engineer Intern - BMC Software | LinkedIn</a></p><p>Also, read my articles on Programming is Science, not Maths, Docker and Responsive architecture.</p><ul><li><a href="https://hemnanisahil777.medium.com/programming-is-science-not-maths-514bd43e290b">Programming is Science not Maths</a></li><li><a href="https://hemnanisahil777.medium.com/docker-everything-you-wanna-know-cadd3477f84f">Docker- Everything you wanna know.</a></li><li><a href="https://hemnanisahil777.medium.com/responsive-architecture-flutter-54c0b0806262">Responsive Architecture Flutter</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a216041e346c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Programming is Science not Maths]]></title>
            <link>https://hemnanisahil777.medium.com/programming-is-science-not-maths-514bd43e290b?source=rss-448ef54a39c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/514bd43e290b</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[structured-programming]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[science]]></category>
            <dc:creator><![CDATA[Sahil Hemnani]]></dc:creator>
            <pubDate>Tue, 10 Aug 2021 21:14:15 GMT</pubDate>
            <atom:updated>2021-08-10T21:14:15.134Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article is dedicated to the memories and discoveries of the great mathematicians and programmer Edsger Wybe Dijkstra.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n23TBieb9_-ZL5W0" /><figcaption>E.W. Dijkstra</figcaption></figure><p>When we talk about programming in general- the first thought comes to our mind is of maths. For a long time we have been told that programming is deeply related to mathematics by our teachers, mentors and colleagues, but have you ever thought why programming is maths and not science?<br>In this article I am going to throw some light on few points which will at last prove that programming is science and not maths.</p><p>But there are few prerequisites that will help you in understanding the concept in a better way such as- programming paradigms, Mathematical induction, and some basic maths.</p><blockquote><strong>What are we going to discuss</strong></blockquote><ul><li>Starting with the very beginning of programming, who was Dijkstra?</li><li>His discoveries and Idea of proving programming as math.</li><li>What is structured programming and why does it make sense in context of our topic of concern ?</li><li>What are the differences between science and math and how programming is science and not math?</li><li>How are tests related to scientific proofs- and how can we achieve that ?</li><li>Conclusion</li></ul><blockquote><strong>Starting with the very beginning of programming, who was Dijkstra?</strong></blockquote><p>Back when Alan Turning wrote the very first line of code till now when we are writing complex programs to perform complex tasks- programming has been the exact same.</p><p>It is <strong><em>sequence, selection and iteration</em>.</strong> Yes the programming languages have evolved, our processor speed has evolved, hardware has evolved a lot but the software is still the same- the programming is still the same.</p><p>You can write any complex program with those three (<em>sequence, selection and iteration</em>). So if programming has not evolved much it is relevant to look at the discoveries in the early stage and past to make our roots strong and to know how the things actually work at the level zero.</p><p>Edsger Wybe Dijkstra was born in Rotterdam in 1930. He survived the bombing in World War II, along with the German occupation of the Netherlands, and in 1948 graduated from high school with the highest marks possible in maths, physics, chemistry and biology. In March 1952, at the age of 21, Dijkstra took a job with the Mathematical Center of Amsterdam as the Netherlands’ very first programmer.</p><p>In 1955, having been a programmer for 3 years, and while still a student, Dijkstra concluded that the intellectual challenge of programming was greater than the intellectual challenges in theoretical physics. As a result of this he took programming as a long term career.</p><p>It was this environment that Dijkstra made his great discoveries.</p><blockquote><strong>His discoveries and Idea of proving programming as maths.</strong></blockquote><p>The problem that Dijkstra recognized, early on, was that programming is hard, and the programmers don’t do it very well. Program of any complexity contains too many details for a human brain to manage without help. Overlooking just one small detail results in a program that may seem to work but fail in surprising ways.</p><p>Dijkstra’s Solution was to apply the mathematical disciplines of <em>proof</em>. His vision was the construction of an Euclidean hierarchy of postulates theorem corollaries, and lemmas. Dijkstra thought that programming could use that hierarchy the way mathematician’s do. In other words programmers would use proven structures and tie them together with code that they would then prove correct themselves.</p><p>So Dijkstra realized that he would have to demonstrate the technique for writing basic rules of simple algorithms.</p><p>This he found to be quite challenging, but by that time Bohm and Jacopini, who proved that all programs can be constructed from just three structures sequence, selection and iteration were largely accepted. The discovery was remarkable: the very control structure that made a module provable were the same minimum set of control structures from which all programs can be built. Thus structured programming was born.</p><p>So he thought to prove the basic building unit of any program by proofs.</p><h4>How he proved <strong>sequence</strong></h4><p>Dijkstra showed that sequential statements could be proved correct through simple enumeration. The technique mathematically traced the input of the sequence to the output of the sequence; this approach was no different from any normal mathematical proof.</p><h4>How he proved <strong>selection</strong></h4><p>Dijkstra tackled selection through reapplication of enumeration. Each path through the selection was enumerated. If both paths eventually produce appropriate mathematical results then the proof was solid.</p><h4>How he proved <strong>Iteration</strong></h4><p>Iteration was a bit different. To prove an iteration correct, Dijkstra had to use <em>induction</em>. He proved the case for 1 by enumeration. Then he proved the case that if N was assumed correct, N+1 was correct, again by enumeration. He also proved the starting and ending criteria of the iteration by enumeration.</p><p>Such proofs were laborious and complex — but they were proofs. With their development, the idea that Euclidean hierarchy of theorems could be constructed seemed reachable.</p><p><strong><em>But what happened next ? </em></strong><em>Why did no one use these proofs to prove their own programs? Do you prove your own program after writing it? Obviously NO.</em></p><p>Answer is simple- It is complex for a programmer to every time prove that the program which he/she has written is correct.</p><p>So the proofs never came. The Euclidean hierarchy of theorems was never built. And programmers at large never saw the benefits of working through the complex process of writing proofs. In the end Dijkstra’s dream faded and died.</p><p>So how do we prove our programs are correct- <strong><em>THE SCIENTIFIC STRATEGY</em></strong></p><blockquote><strong>What is Structured programming and why does it make sense in context of our topic of concern ?</strong></blockquote><p><em>Structured programming imposes discipline on direct transfer of control.</em></p><p>It was discovered by Dijkstra when he said not to use <strong><em>goto</em></strong><em> </em>statements as they make it tough to prove the program mathematically.</p><p>Structured programming forces us to recursively decompose a program into a set of small provable functions.</p><p>Read that again- Provable Functions (makes sense)</p><p>Now we will actually see how we can prove small functions and how it is science.</p><blockquote><strong>What are the differences between science and maths and how programming is science and not maths?</strong></blockquote><p>Science is fundamentally Different from mathematics, in that scientific theories and laws can not be proven correct. I I cannot prove to you that Newton’s second law of motion, F= ma, or law of gravity, F= Gm1m2/r2, are correct. I can demonstrate these laws to you, and I can make measurements that show them correct to many decimal places, but I cannot prove them in the sense of mathematical proofs. No matter how many experiments I conduct or how much empirical evidence I gather, there is always the chance that some experiment will show that those Laws of Motion and gravity are incorrect.</p><p>That is the nature of scientific theories and laws: they are <em>falsifiable</em> but not provable.</p><blockquote>Science does not work by proving statements true, but rather by proving statements false. those statements that we cannot true false, after much effort, we deem to be true enough for our purposes.</blockquote><p>Of course, Not all statements are provable. The statement “This is a lie” is neither true nor false. It is one of the simplest examples of a statement that is not provable.</p><p>Ultimately, we can say that mathematics is the discipline of proving provable statements true. Science, in contrast, is the discipline of proving provable statements false.</p><p>So we can prove our programs correct by passing all the tests which we wrote to make our program fail. That means if the tests can not prove our program false, we have to accept that it is true and acceptable for our purpose.</p><p>So writing tests proves our code and program, and hence makes programming science not maths.</p><blockquote><strong>How are tests related to scientific proofs- and how can we achieve that ?</strong></blockquote><p>Dijkstra once said, “Testing shows the presence, not the absence, of bugs” In other words, A program can be proven incorrect by a test, but it cannot be proven correct. All that test can do, after sufficient testing effort, is allow us to deem a program to be correct enough for our purposes.</p><p>The implications of this fact are stunning. software development is not a mathematical Endeavour, even though it seems to manipulate mathematical constructs. Rather, software is like science. we show correctness by failing to prove in correctness, despite our best efforts.</p><p>Also structured programming forces us to recursively decompose a program into a set of small probable functions. We Can then use tests to try to prove the small probable function incorrect . If such tests fail to prove incorrectness, then we deem the function to be correct enough for our purpose.</p><blockquote><strong>Conclusion</strong></blockquote><p>We conclude that programming is deeply related with science and not with maths.</p><p>We also concluded that programming does not work by proving the program true, but rather by proving the program false, those programs that we cannot prove false, after much effort, we deem to be true enough for our purposes.</p><p>Also we can say that by the use of structured programming we can recursively decompose a program into a set of small provable functions, We Can then use tests to try to prove the small probable function incorrect . If such tests fail to prove incorrectness, then we deem the function to be correct enough for our purpose.</p><p>Thank you! for more such content lets connect on LinkedIn.</p><p><a href="https://www.linkedin.com/in/sahil-hemnani-8084b41a6/">Sahil Hemnani - Software Engineer Intern - BMC Software | LinkedIn</a></p><p>Also read my articles on Docker and Responsive architecture.</p><ul><li><a href="https://hemnanisahil777.medium.com/docker-everything-you-wanna-know-cadd3477f84f">Docker- Everything you wanna know.</a></li><li><a href="https://hemnanisahil777.medium.com/responsive-architecture-flutter-54c0b0806262">Responsive Architecture Flutter</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=514bd43e290b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker- Everything you wanna know.]]></title>
            <link>https://hemnanisahil777.medium.com/docker-everything-you-wanna-know-cadd3477f84f?source=rss-448ef54a39c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/cadd3477f84f</guid>
            <category><![CDATA[hypervisors]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[questions]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Sahil Hemnani]]></dc:creator>
            <pubDate>Fri, 25 Jun 2021 07:49:24 GMT</pubDate>
            <atom:updated>2021-06-25T07:49:24.815Z</atom:updated>
            <content:encoded><![CDATA[<h4>PART 1- Basics of Docker and all questions related to it.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*unFD35K2mmbG5jLt4CS2Zw.jpeg" /></figure><p>If you’re a programmer or involved in operation team for production level application delivery, there is a high chance you’ve at least heard about “Docker” as an open source platform for building, deploying, and managing containerized applications, but this definition seems overwhelming. In this article you’ll learn Docker from scratch and after completing you will be able to use docker in your own application delivery process.</p><p>Now a days tech giants like google, Microsoft, Amazon are also showing there interest in Docker and are showing great support to expand the technology, so it’s better to get equipped by the knowledge about it.</p><p>In this article you will learn all about docker in detail, but before that let, me start by telling you what are we going to learn in brief, so if you are looking for a particular question or concept you can directly jump there.</p><blockquote><strong>Overview of the article</strong></blockquote><ol><li>What’s the need of docker?</li><li>What problem it solves?</li><li>What is docker?</li><li>What are containers?</li><li>What are images?</li><li>What is difference between Image and Container?</li><li>What is difference between VMs and Containers?</li><li>Why not hypervisor and why to prefer docker over it?</li><li>Docker Architecture</li><li>Docker Installation</li><li>Dockerizing your application (Dockerfile)</li><li>Development workflow of the application using docker.</li><li>Basic docker commands</li><li>What is docker hub?</li><li>Docker as Life savior in some cases.</li><li>Future plans and what’s next.</li></ol><blockquote><strong>What’s the need of docker?</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xBr7BDps_rMJcW5bTlopTQ.png" /></figure><p>Consider the following conversation between a developer and a tester working on a full stack project:</p><p><strong>Developer:</strong> <em>Hi, our application is up and running and it’s ready to test. Code has been pushed.</em></p><p><strong>Tester: </strong>Great, I’ll test it.</p><p>(after 2 hours)</p><p><strong>Tester: </strong><em>Seems like the application has some issue or few dependencies are missing, I’m trying to run the application but it shows the error XYZ.</em></p><p><strong>Developer: </strong><em>It’s running perfect here, maybe you’ve missed some dependency installation (I don’t see any XYZ error at my end)</em></p><p><strong>Tester:</strong> <em>I’ll check.</em></p><p><em>(tester tried to find the issue- took 4 hours)</em></p><p><strong>Tester: </strong><em>No it’s not running, it says XYZ error while starting.</em></p><p><strong>Developer: </strong>but it works fine on my machine.</p><p>and the blame game continues…</p><p>In the above conversation who do you think is wrong, the answer is “no one”- actually the process of shipping the application is wrong- “the way that both are sharing the codebase of the application is wrong”, shipping application this way can cause following issues:</p><ol><li>There might be some dependencies which were not mentioned by the developer while sending the application, or some dependency version mismatch might occur.</li><li>There might be some OS level features which were not included in the project and can be reason of the error XYZ.</li><li>There might be some dependencies which were already installed by the developer while working on some other application and has forgot to mention in the project.</li></ol><p>The different environments all require both software and hardware management. We have to ensure that both the installed software and configured hardware in each is the same. We also need to configure aspects such as network access, data storage, and security per environment in a consistent and easily reproducible manner.</p><p>Due to the these reasons there is a debate between the teams(actually no one’s fault) and here is when docker comes into play and solves the issue.</p><blockquote><strong>What problem it solves?</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*SHgZgMqDkJhz7PFJ.jpg" /></figure><p><strong><em>“It works on my machine” </em></strong>is the problem which docker solves by giving us the concept of “share everything which your project requires to run” including application code, dependencies, OS level features(optional), documents, configurations, processes, networking and anything related to the project, so it is easy for the other person to use your code without errors in installing and managing the dependencies. If you ship(send/share) your application this way there are few benefits mentioned below:</p><ol><li>It works on all machines as everything has been shared.</li><li>The other person do not need to care about all the set up and installation process to start the application.</li><li>It reduces the friction between teams by making the SDLC easy and less error prone.</li><li>Saves time and resources- as the person only needs to install the container which contains all the things of the application.</li></ol><p>In the next section let us actually understand what is docker in technical terms.</p><blockquote><strong>What is docker?</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cyc854X1SKyw6Qa3.png" /></figure><p><strong>Docker</strong> is an open platform for developing, shipping, and running applications. <strong>Docker</strong> is designed to facilitate and simplify application development. It is a set of platform-as-a-service products that create isolated virtualized environments for building, deploying, and testing applications. it enables you to pack all the things which are needed for your application to build and run including application code, dependencies, OS level features(optional), documents, configurations files, processes, networking and anything related to the project in a container and ship(share) it directly to anyone else, so that they can directly run your project without concerning about your project configuration and setup. This reduces the over head of setting up the environment and also reduces friction between the two individuals or teams so that they can focus on there jobs rather than solving the errors related to setup and configuration of the project.</p><p><em>but how does docker pack everything in a CONATINER, what is a container ?</em></p><blockquote><strong>What are containers?</strong></blockquote><p><strong>Containers</strong> are software that wrap up all the parts of a code and all its dependencies into a single deployable unit that can be used on different systems and servers. A <strong>container</strong> is a virtualized run-time environment where users can isolate applications from the underlying system. These containers are compact, portable units in which you can start up an application quickly and easily. This containers can be shared to other teams by making an image so that that the other team can directly make an instance and start working on it without worrying about the installation and setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t8A8ZCQX8kz25XLSkzI3pQ.png" /></figure><p>This images are smart enough to set them up on any OS which has docker installed on it and works smoothly. The installation of all the dependencies and pre-requisites for the project and modules is handled by the containers itself.</p><p><em>but how do we share the containers? what are images ?</em></p><blockquote><strong>What are images?</strong></blockquote><p>An image is a portable package that contains software. It’s this image that, when run, becomes our container. The container is the in-memory instance of an image.</p><p>An image is immutable. Once you’ve built an image, the image can’t be changed. The only way to change an image is to create a new image. This feature is our guarantee that the image we use in production is the same image used in development and QA.</p><p>A <strong>Docker image</strong> is an immutable (unchangeable) file that contains the source code, libraries, dependencies, tools, and other files needed for an application to run.</p><p>Due to their <strong>read-only</strong> quality, these images are sometimes referred to as snapshots. They represent an application and its virtual environment at a specific point in time. This consistency is one of the great features of Docker. It allows developers to test and experiment software in stable, uniform conditions.</p><p>Since images are, in a way, just <strong>templates</strong>, you cannot start or run them. What you can do is use that template as a base to build a container. A <strong>container is, ultimately, just a running image</strong>. Once you create a container, it adds a writable layer on top of the immutable image, meaning you can now modify it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/0*OqMfiylQgezMG8R-.png" /></figure><p>You can create an unlimited number of Docker images from one <strong>image base</strong>. Each time you change the initial state of an image and save the existing state, you create a new template with an additional layer on top of it.</p><p>Docker images can, therefore, consist of a <strong>series of layers</strong>, each differing but also originating from the previous one. Image layers represent read-only files to which a container layer is added once you use it to start up a virtual environment.</p><p>What we need to understand from this is, we just share the image of our container- not the container.</p><blockquote><strong>What is difference between Image and Container?</strong></blockquote><p>When discussing the difference between images and containers, it isn’t fair to contrast them as opposing entities. Both elements are closely <strong>related and are part of a system</strong> defined by the Docker platform.</p><p>If you have read the previous two sections that define docker containers and docker images, you may already have some understanding as to how the two establish a relationship.</p><p><strong><em>Images can exist without containers, whereas a container needs to run an image to exist.</em></strong> Therefore, containers are dependent on images and use them to construct a run-time environment and run an application.</p><p>The two concepts exist as essential components (or rather phases) in the process of running a Docker container. Having a running container is the final “phase” of that process, indicating it is dependent on previous steps and components. That is why docker images essentially govern and shape containers.</p><blockquote><strong>What is difference between VMs and Containers?</strong></blockquote><p>Before looking at the difference between VMs and Containers let us understand what is hypervisor.</p><p>A <strong>hypervisor</strong>, also known as a virtual machine monitor or VMM, is software that creates and runs virtual machines (VMs). A hypervisor allows one host computer to support multiple guest VMs by virtually sharing its resources, such as memory and processing.</p><p>Containers and hypervisors are both involved in making applications faster and more efficient, but they achieve this in different ways.</p><h4>VMs:</h4><ul><li>Allow an operating system to run independently from the underlying hardware through the use of virtual machines.</li><li>Share virtual computing, storage and memory resources.</li><li>Can run multiple operating systems on top of one server (bare-metal hypervisor) or installed on top of one standard operating system and isolated from it (hosted hypervisor).</li><li><strong>Efficiency: </strong>VM are less efficient as they have to manage full blown guest operating system. VM’s have to access host resource through a hypervisor.</li><li><strong>Portability: </strong>VMs aren’t that easily ported with the same settings from one operating system to another.</li><li><strong>Scalability: </strong>VMs aren’t very easily scalable as they are heavy in nature.</li><li><strong>Deployment: </strong>VMs can be deployed by using the PowerShell or by using the VMM or using cloud services such as AWS or azure.</li></ul><h4>Containers:</h4><ul><li>Allow applications to run independently of an operating system.</li><li>Can run on any operating system — all they need is a container engine to run.</li><li>Are extremely portable since in a container, an application has everything it needs to run.</li><li><strong>Efficiency: </strong>Container are way more efficient as they only utilize the most necessary parts of the Operating system. They act like any other software on the host system</li><li><strong>Portability: </strong>Containers are self- contained environments that can easily be used on different Operating systems.</li><li><strong>Scalability: </strong>Containers are very easy to scale, they can be easily added and removed based on requirements due to their light weight.</li><li><strong>Deployment: </strong>Containers can be deployed easily using the Docker CLI or making use of Cloud services provided by AWS or azure.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/0*Jc9dRN3ILsg1SWLm.png" /></figure><blockquote><strong>Why not hypervisor and why to prefer docker over it?</strong></blockquote><p>Hypervisor was a solution which came before docker and was successful till docker came in picture because of the following reasons:</p><ul><li>Hypervisors are <strong>heavyweight </strong>as they have OS installed on the Host OS on the other side, containers are <strong>lightweight </strong>as they only have what the application needs.</li><li>Hypervisors have a limited performance as they are built on the Host OS but docker can have a native performance and can be very flexible.</li><li>Hypervisor require a <strong>high memory storage</strong> as it installs the whole OS on the host OS but containers require <strong>less storage</strong> as they only install the software.</li><li>The start time of the Hypervisors in minutes but the start time of containers in in milliseconds, so they are fast.</li></ul><p>There is one feature where Hypervisor wins over Docker is Security- hypervisor are fully isolated hence have a <strong>high level security</strong> but docker have the <strong>process-level isolation possibly less secure.</strong></p><p>There are still few companies which use hypervisors or docker keeping in mind there own preferences!</p><blockquote><strong>Docker Architecture</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*cwVMGBA4NX_NKL6hXX93yA.png" /><figcaption>source- <a href="https://docs.docker.com/">docker.com</a></figcaption></figure><p>it’s okay if at first this image looks overwhelming to you- let us try to understand this in bits and pieces and at final join everything and I’m sure that will make sense.</p><h4>The Docker daemon</h4><p>The Docker daemon (dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons to manage Docker services.</p><p>In easy words daemon is a middle man between the client and the registry which manages all the services, listens to the calls the client makes and responds to it.</p><h4>The Docker client</h4><p>The Docker client (docker) is the primary way that many Docker users interact with Docker. When you use commands such as <strong><em>docker run</em></strong>, the client sends these commands to <strong><em>dockerd</em></strong>, which carries them out. The <strong><em>docker </em></strong>command uses the Docker API. The Docker client can communicate with more than one daemon.</p><h4>Docker registries</h4><p>A Docker <em>registry</em> stores Docker images. Docker Hub <em>(more on that later)</em> is a public registry that anyone can use, and Docker is configured to look for images on Docker Hub by default. You can even run your own private registry.</p><p>When you use the <strong><em>docker pull</em></strong> or <strong><em>docker run </em></strong>commands, the required images are pulled from your configured registry. When you use the <strong><em>docker push </em></strong>command, your image is pushed to your configured registry.</p><p>Docker uses a client-server architecture. The Docker <em>client</em> talks to the Docker <em>daemon</em>, which does the heavy lifting of building, running, and distributing your Docker containers. The Docker client and daemon <em>can</em> run on the same system, or you can connect a Docker client to a remote Docker daemon. The Docker client and daemon communicate using a REST API, over UNIX sockets or a network interface.</p><p>from now we’ll talk about more technical and implementation concepts related to docker- installation, workflow and etc.</p><blockquote><strong>Docker Installation on Windows, MacOS, Linux</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*x-9EvEbRLD7S2U9BdkqZCA.png" /></figure><p>installation process is very well explained in the docker documentation, so why reinvent the wheel.</p><ul><li>steps of installation on LINUX: <a href="https://docs.docker.com/engine/install/"><strong><em>linux installation</em></strong></a></li><li>steps of installation on WINDWOS: <a href="https://docs.docker.com/docker-for-windows/install/"><strong><em>windows installation</em></strong></a></li><li>steps of installation on MACOS: <a href="https://docs.docker.com/docker-for-mac/install/"><strong><em>macOS installation</em></strong></a></li></ul><blockquote><strong>Dockerizing your application (Dockerfile)</strong></blockquote><p>Dockerizing your application simply means- adding a Dockerfile to your application and thus enabling it to build and run inside a isolated container.</p><p>A Dockerfile(with no extension) is basically a file containing the instructions of building a container of the application. The Instructions in the docker file are responsible how the container will get build. The Dockerfile is added to the root directory of the project, so that it can have the access of the complete project.</p><p>Below is the example of a Dockerfile:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8zV06Wx9f180Z6W-F3BGDg.png" /><figcaption>Dockerfile</figcaption></figure><ul><li><strong><em>FROM</em></strong>: the command is used to set up the pulling stream of the container, or it is used to make the application aware- from where it is going to extend or extract the file which will the application needs. Moreover the docker container is smart enough to know from where it has to pull. By default the pulling registry is set to <a href="https://hub.docker.com/">docker.hub</a> but we can also set up our own private registry for pulling in the base image and this service of setting up the private registry are provided by any of the cloud services such as AWS, AZURE or GCP.</li></ul><p>syntax: <strong><em>FROM </em></strong><em>_name_of_base_image_</em></p><ul><li><strong><em>COPY: </em></strong>the command is used to copy the files from the pulled image to the root directory of our project. We can copy all the files from the pulled image to the root directory by mentioning (.) or we can copy only required files in the root by mentioning the absolute paths (node/xyz/pqr.js).</li></ul><p>syntax: <strong><em>COPY </em></strong><em>_what_to_copy_ _where_to_copy_</em></p><ul><li><strong><em>WORKDIR: </em></strong>the command is used to set up the current working directory as the root of the project- so if someone starts our container, they will be directed to this directory which we set up. The advantage of using this command is to reduce the load on the other person, so that they know from where to build and run the project.</li></ul><p>syntax: <strong><em>WORKDIR</em></strong> _dirctory_path_</p><ul><li><strong>CMD: </strong><em>cmd stands for the command or a instruction to the container to run this command when someone runs the container. So this is the command used to start the project inside of our container.</em></li></ul><p>syntax: <strong><em>CMD</em></strong> _command_</p><p>so now if you are familiar with the basic commands of Dockerfile- let’s recall what is our Dockerfile doing:</p><ol><li>it takes the base image which is <em>node:alpine </em>from docker.hub (default repo.)</li><li>copies all the files from the pull image to the <em>/app </em>directory in our project.</li><li>sets up the working directory to <em>/app</em> in our project.</li><li>finally tells the command which should be executed- <em>node app.js</em></li></ol><blockquote><strong>Development workflow of the application using docker.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AeROLMqY81_dj1qgiB7LAA.png" /></figure><p>The basic workflow of docker is inspired by the workflow of VCS.</p><p>The developer writes the code on his local machine- then he containerize the application by the help of a docker file- then he pushes the image of the container on any repository from where other folks can take that image and test it or continue to work on it.</p><p>The other person who wants to run the application- pulls the image from the same repository and builds a container from the image which starts the application on their own local machine flawlessly.</p><p>We can see how the problem which was raised by the tester and the developer in the earlier section has been now resolved and now:</p><blockquote>“IT WORKS ON EVERY MACHINE”</blockquote><blockquote><strong>Basic docker commands</strong></blockquote><p>When starting with docker there are few basic commands which are used on regular basis like- building a image, pull it from remote registry, listing the image running on the machine and many more…</p><p>Below are the listed commands which are bare minimum and explained easily to the extent that you can start using them.</p><p>How to build a image? How to run an docker container? How to list images? How to remove a image? How to pull the docker image?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*9cBb550of1-qknU1Wjr6fA.png" /></figure><blockquote><strong>What is docker hub?</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/0*WXlEPU8NrwzPAPg-.png" /></figure><p>Docker Hub is a Software as a Service (SaaS) Docker container registry. Docker registries are repositories that we use to store and distribute the container images we create. Docker Hub is the default public registry Docker uses for image management. <a href="https://hub.docker.com/">Docker Hub</a> is a service provided by Docker for finding and sharing container images with your team. It is the world’s largest repository of container images with an array of content sources including container community developers, open source projects and independent software vendors (ISV) building and distributing their code in containers.</p><p>Keep in mind that you can create and use a private Docker registry or use one of the many cloud provider options available. For example, you can use Azure Container Registry to store Docker containers to use in several Azure container-enabled services.</p><blockquote><strong>Docker as Life savior in some cases.</strong></blockquote><p>This is a purely personal experience which I‘m going to share with you, when docker came out as a life savior for me. While starting a project I came across a issue to connect database to our server side backend that was again “It works on my machine”- but everyone in our team were having there own environment setup. Few guys were using macOS few were using windows so the major problem was to set up the correct deployment and sharing system to share the software as a complete package between us all.</p><p>Few problems which we faced at the beginning were</p><ol><li>The local database which we were using for testing on personal devices became inconsistent as we tested on an on.</li><li>Tracking a bug was nearly impossible due to different data on different machines.</li><li>The internal dependencies which windows person used was useless in macOS and vice versa- so merge conflicts started.</li><li>Dependencies went out of date on few machine due to system settings(already setup)</li></ol><p>After smashing our heads hard on the wall we decided to move to a isolated system where we kept our software, deployed a database locally in the container and docker did everything else.</p><p>We managed to reduce the merge conflicts, time for testing and debugging bugs, the system finally looked on place.</p><blockquote>Thanks to Docker!</blockquote><blockquote><strong>Future plans and what’s next.</strong></blockquote><p>While you will be reading this article- I’ll be writing the part 2 of the same and few topics/question which will be addressed in the article will be:</p><ol><li>Pushing and pulling a image on docker hub or private repositories.</li><li>What is docker compose?</li><li>Making a docker compose file and related commands.</li><li>What is Kubernetes?</li><li>How to used and deploy Docker- a real life example.</li><li>Details of Docker- Managing containers efficiently.</li><li>Private repositories with examples.</li><li>Lot more about kubernetes.</li></ol><p>If any other questions or concepts you would like to read in the next article (part2) please mention that in the comments or contact me. All the suggestions are always welcomed. I hope you like it- thanks for your time :)</p><ul><li><a href="https://www.linkedin.com/in/sahil-hemnani-8084b41a6/">Sahil Hemnani - Software Engineer Intern - BMC Software | LinkedIn</a></li><li><a href="https://github.com/SahilHemnani777">SahilHemnani777 - Overview</a></li><li><a href="https://twitter.com/sahil_hemnani">JavaScript is not available.</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cadd3477f84f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Responsive Architecture Flutter]]></title>
            <link>https://hemnanisahil777.medium.com/responsive-architecture-flutter-54c0b0806262?source=rss-448ef54a39c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/54c0b0806262</guid>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[responsive-web-design]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Sahil Hemnani]]></dc:creator>
            <pubDate>Fri, 04 Jun 2021 07:05:52 GMT</pubDate>
            <atom:updated>2021-06-04T07:05:52.805Z</atom:updated>
            <content:encoded><![CDATA[<p>This article resolves issues with responsive design for your cross-platform application and make it easy to frame your application’s widgets according to screen size, orientation, device type- you are on the right place!</p><p>After facing the same problem(while learning flutter) I tried many different things out such as MediaQuery and some other packages form <a href="https://pub.dev/">pub.dev</a> but none was the effective solution for production level application so “Responsive Architecture” was born for me- thanks to <a href="https://www.filledstacks.com/">filledstacks.com</a> for this awesome architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q2yTku4x-zgfMVxT" /></figure><p><strong>Building a widget as per screen size:</strong></p><p>This widget will take in a Widget for each screen type. If one is not defined it will return the Mobile layout since we’re starting there. This will give us a nice an easily readable top level widget. This widget will take in a Widget for each screen type. If one is not defined it will return the Mobile layout since we’re starting there. This will give us a nice an easily readable top level widget.</p><pre>class ScreenTypeLayout extends StatelessWidget {<br>  // Mobile will be returned by default<br>  final Widget mobile;<br>  final Widget tablet;<br>  final Widget desktop;<br><br>  const ScreenTypeLayout(<br>      {Key key, @required this.mobile, this.tablet, this.desktop})<br>      : super(key: key);<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return ResponsiveBuilder(builder: (context, sizingInformation) {<br>      // If sizing indicates Tablet and we have a tablet widget then return<br>      if (sizingInformation.deviceScreenType == DeviceScreenType.Tablet) {<br>        if (tablet != null) {<br>          return tablet;<br>        }<br>      }<br><br>      // If sizing indicates desktop and we have a desktop widget then return<br>      if (sizingInformation.deviceScreenType == DeviceScreenType.Desktop) {<br>        if (desktop != null) {<br>          return desktop;<br>        }<br>      }<br><br>      // Return mobile layout if nothing else is supplied<br>      return mobile;<br>    });<br>  }</pre><pre>}</pre><p><strong>Building the widget as per the orientation:</strong></p><p>The portrait widget is required and will be the default if no landscape widget is supplied. If I were to put this in a package I would make both required and add an assert that says “If you don’t supply both there’s not point in using this widget”.</p><pre>class OrientationLayout extends StatelessWidget {<br>  final Widget landscape;<br>  final Widget portrait;<br>  OrientationLayout({<br>    Key key,<br>    this.landscape,<br>    @required this.portrait,<br>  }) : super(key: key);<br><br>  @override<br>  Widget build(BuildContext context) {<br>    var orientation = MediaQuery.of(context).orientation;<br>    if (orientation == Orientation.landscape) {<br>      return landscape ?? portrait;<br>    }<br><br>    return portrait;<br>  }</pre><pre>}</pre><p><strong>Examples where this architecture is uses:</strong></p><ul><li>Customizable App Drawer (<a href="https://github.com/SahilHemnani777/responsive_architecture">source code</a>)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bpi7C18P_yw-OyF9" /></figure><ul><li>Todo List Application (<a href="https://github.com/SahilHemnani777/todo_list_provider">source code</a>)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XqYZSYVJXc6GNi7_" /></figure><p>A single codebase handles all the cases shown in above two examples.</p><p>for any query contact me: <a href="https://www.linkedin.com/in/sahil-hemnani-8084b41a6/">LinkedIn</a> or mail at hemnanisahil777@gmail.com</p><p><strong>hope it helps, thank you!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54c0b0806262" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>