<?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 Bogdan Kulbida on Medium]]></title>
        <description><![CDATA[Stories by Bogdan Kulbida on Medium]]></description>
        <link>https://medium.com/@konstankino?source=rss-1ca758931754------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8kvlToCScvlg8gzBXdldig.jpeg</url>
            <title>Stories by Bogdan Kulbida on Medium</title>
            <link>https://medium.com/@konstankino?source=rss-1ca758931754------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 00:16:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@konstankino/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[SAMBER, a Full-Stack developer’s dream come true]]></title>
            <link>https://medium.com/@konstankino/samber-a-full-stack-developers-dream-come-true-9e1a94d51b89?source=rss-1ca758931754------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e1a94d51b89</guid>
            <category><![CDATA[fullstack-development]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Bogdan Kulbida]]></dc:creator>
            <pubDate>Thu, 25 Jun 2020 05:25:28 GMT</pubDate>
            <atom:updated>2020-06-25T05:25:28.907Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m5etbo9zku2YSHETHmQmXQ.png" /></figure><p>SAMBER is a product of careful analysis for the past ten years of my professional experience working on many start-up projects, MVPs, and supporting existing applications applying best practices and projected into the post-COVID19 period.</p><p>With lots of love and passion for specific tools and frameworks that prove their practical applicability to many technical problems at hand, I would like to reveal off my dream that came true. A toolchain that helps you reduce development efforts and spendings up to five times, and makes development fun again.</p><p>(When I say “Serverless”, I’m talking about Amazon Web Services Lambda and Fargate.)</p><h3>The architecture selection problem</h3><p>When you start developing your project, based on your specific needs and experience, you probably consider two to four architectures, such as:</p><ol><li>Three-Tier Architecture</li><li>Monolith (or Sharded) Architecture</li><li>Lambdas Architecture (based on Events and streaming data, using Apache Beam and Kafka, or similar)</li><li>Streaming Architecture (bounded and unbounded data, using Enterprise Event Buses, again, based on Events, using streaming and batch data, using Apache Beam and Kafka, or similar)</li><li>Or maybe something else?</li></ol><p>I find architectures (3) and (4) are extremely hard to implement properly and then support. However, Lambda-based and Streaming-based architectures teach us some very valuable design patterns, but at the cost of architectural complexity.</p><p>Architecture types (1) and (2) are generic and relatively simple, which are widely in use these days because of implementation simplicity and support. For example, back in 2017 Slack was using Sharded Architectures, which served them well for at least a few years. The problem with Sharded Architectures is that you have copies of your whole application on many servers. So now you have multiplied your over provisioned server capacity issue. Also, with this approach you cannot easily scale horizontally.</p><p>Three-Tier Architectures became very popular with libraries like React.js or Vue.js, and this allowed you to decouple your presentation and application layers. Which feels halfway there because now you need to manually define your application domains and decide where your presentation ends and application layer begins.</p><p>Because React.js is not a framework, each team has their own variation implementing front-end “correctly”. For example, here are some issues with React.js (and Vue.js) as I personally see them:</p><ol><li>Lack of solid conventions that you can rely on</li><li>What testing framework will you use and why? How will you mock and stub your external services?</li><li>If you hire a designer, he has to know JSX markup to be able to contribute productively. Can a designer learn and know JSX? Sure, but should he?</li><li>You heavily rely on third-party libraries, such as React Router, Redux, Thunk, you name it.</li><li>How will you build and deploy your application? Higher Order Components, stateful or stateless ones? Why?</li><li>How will you scale your application in terms of developer force, and split your front-end application into parts, so that each team works on their own internal app within your application?</li><li>What API will you use? REST, SOAP or maybe both?</li><li>Where does your presentation layer end and application layer starts?</li></ol><p>React.js and Vue.js are great libraries for the purpose they were created, but they are not frameworks. We appreciate frameworks for having guard-rails which nudge developers to make better implementation decisions. For example, some front-end frameworks have routing libraries that are encoded into the DNA of the framework. In React.js or Vue.js there are a few routing libraries that you can use, and what it buys you is simply a confusion in further development. Another question is what data abstraction layer will you use in React.js or Vue.js and why? Out of the box, neither React.js or Vue.js have any.</p><p>Another problem that you most likely are facing is over-provisioning your services capacity. Even with AWS AutoScaling features, you will be over-provisioning your service. Here Serverless comes to the rescue.</p><p>Software and [Dev]Ops engineers want to deliver features that allows to assure business agility, and be less overwhelmed with operations like:</p><ol><li>Scaling manually application capacity and over-provisioning it.</li><li>Developing deployment scripts and monitoring tools.</li><li>Making sure that servers and batch routines are scaled with the right capacity.</li><li>Making sure all application metrics are collected in one secure place.</li><li>Provisioning and administering databases.</li><li>Troubleshooting production workloads.</li></ol><p>Those are just a few issues that Development and Operation teams have to deal with regularly.</p><p>I like the Django framework’s philosophy. One example is an explicit Form abstraction layer for your Model and a View. Form presentation and application layers are encoded deeply into the Django frameworks. This powerful pattern gives you a lot of flexibility and functionality that is a part of the framework. For example, you can form Domain objects using multiple Models that are functionally coupled using a single Form object.</p><h3>How I conquered this mountain</h3><p>After careful analysis of the four architectures, I tried to come up with an approach that would work well for my customers. I needed a fast and reliable toolchain, fast and reliable glue for frameworks. I wanted it to scale well, cost minimum in development and support (literally cents per month for “idling”), and be able to scale to thousands of users without any modifications to the architecture and design. I want to have a Serverless, Full-Stack framework. Also, development should be fast and exciting.</p><p>I would like to delegate all heavy lifting operations to the cloud provider, as most start-ups cannot afford to hire [Dev]Ops teams. AWS offers Managed Services which help to simplify and ease your work when you put your DevOps hat or when you have a dedicated team of [Dev]Ops engineers. AWS has all the building blocks, such as dashboards to consume application telemetry data. You can build your own dashboards with specific metrics as well.</p><p>And I think I was able to achieve that with SAMBER. I can clearly see all the benefits (and potential roadblocks) of using SAMBER, and I am super excited about that!</p><h3>SAM + Ember.js</h3><p>SAM stands for Serverless Application Model. Yes, it is the SAM framework from Amazon Web Services, a backend to work with Stream and Batch data (or unbound and bound data respectively). More specifically, SAM works with AWS Lambda for Stream data and AWS Fargate for Batch data (for example, heavy processing, such as video encoding, ETL, data import/export, etc.) <a href="https://aws.amazon.com/serverless/sam/">https://aws.amazon.com/serverless/sam/</a> and <a href="https://aws.amazon.com/fargate/">https://aws.amazon.com/fargate/</a></p><p>MBER for Ember — JavaScript framework for creating ambitious web applications. <a href="https://emberjs.com/">https://emberjs.com/</a> and <a href="https://ember-cli.com/">https://ember-cli.com/</a></p><p>In my opinion, Ember fills out most of the gaps with modern front-end development that React.js exposes. That is my own opinion based on experience working with React.js on many large projects and supporting those projects afterwards.</p><h3>Meet SAMBER, a full-stack framework built for the cloud</h3><p>As you can see, SAMBER takes a full-stack approach in building completely Serverless web applications and web services. It uses Ember.js and its opinionated ecosystem with thousands of plugins and Command Like Tooling on front-end, and AWS Severless Application Model framework on the backend and its powerful Command Line Interface backed by AWS Services. It is fully integrated with AWS to make development sweet and fast. It utilizes powerful Amazon Web Services, giving you the ability to quickly build very complex systems relying on simple conventions and Managed Services. It allows you to develop new apps within hours and bring new features into your application. All of that enables us to experiment and evolve quickly.</p><p>Here is a basic overview of the data flow diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/0*HHs8azzuedzaBbID" /></figure><h4>1. SAMBER front-end</h4><p>Ember.js has a powerful data management layer (Ember Data). This layer allows us to efficiently talk to the backend, adding additional functional features, and making development straightforward. When Ember.js updates data in your application it does it in batches to the backend, and asks for new data only when it is needed. You have guard-rails helping you to granularly control data access patterns. That allows us to avoid sporadic requests to your backend and save a lot of time and money triggering Lambda functions for no reason.</p><p>When some people complain about data retrieval speed, due to a huge payload from the backend, I feel that a good direction is not there. Of course, you can split the payload into chunks to make it “cheaper” for sporadic requests within their application to ask for stale data again and again. But that does not solve the underlying problem, which is probably due to lack of a good front-end framework or convoluted application domains.</p><p>You need better control and discipline when you ask for the data from the backend service. For example, in React.js it is very easy to ask for data, since you essentially can ask for it in your JSX template. Do you remember writing SQL statements in your PHP code? I do, I did that back in 2004. For that reason, writing “Good React” is very hard. In fact, it does not become easier as you add more features to your application. Even when done right, application complexity grows quadratically.</p><p>Ember has a powerful application data management module called Ember Data and Routing module at the heart of the framework. Ember Data is an abstraction layer between your Domain Models and your views, which “knows” when your data changes and asks the server to update it. Ember Data allows abstracting your access patterns to your backend. It only fetches the data from the server when the data changes.</p><p>Ember has strong conventions in place that allow you to keep your application simpler, since there is a clear place where to put your new feature files, etc. Complexity grows linearly with your features. Ember’s powerful Routing system is baked into the framework, so you don’t have to install and rely on third-party libraries for basic functions, such as routing or application state management. And since we have strong conventions in place, we can auto generate a lot of code that “knows” how to talk to the backend efficiently.</p><h4>2. SAMBER backend</h4><p>With SAMBER you utilize containers for batch data processing. Since there is no limit in time execution for AWS Fargate, containers can process your data as long as needed. You can also deploy containers with EC2 placement to avoid cold-start delays and prolonged resource provisioning.</p><p>You can use AWS Elastic Container Service and Serverless approach for heavy batch processing. As you probably know, Elastic Container Service is a Managed Service from AWS. You can forget about idling servers and over-provision waste, spending less on architecture and product support, and be able to scale to your application demand. By using Serverless and other Managed Services, you can build very efficient backend solutions and be on top of the most recent service that AWS has to offer or will release in the future. It is as simple as building your container, pushing and wiring it in your Lambda function.</p><p>The backend to front-end data flow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xXcON4QNH7GgccRK" /></figure><h4>3. Event sourcing</h4><p>I really like this article “CRUD, only when you can afford it” by Maarten Mullender on Microsoft WebLog. <a href="https://docs.microsoft.com/en-us/archive/blogs/maarten_mullender/crud-only-when-you-can-afford-it-revisited">https://docs.microsoft.com/en-us/archive/blogs/maarten_mullender/crud-only-when-you-can-afford-it-revisited</a> It points out how CRUD works well for smaller applications, but it eventually becomes expensive in terms of further development. SAMBER uses AWS Simple Queue Service for event sourcing. When users update something in the application, SAMBER posts an event to SQS and the Lambda function responds to the message. It may trigger Fargate for heavy duty batch processing, and respond with a quick response. Because of Ember Data “smart” mechanics, it will not ask repeatedly for new data for no reason.</p><h4>4. Scaling front-end</h4><p>You can deploy your front-end application to Amazon Simple Storage Service and optionally serve it via Amazon CloudFront distribution. Or you can use any other Content Delivery Network of your choice. No manual front-end scaling is needed.</p><p>SAMBER builds on Ember’s powerful notion of Engines. An Engine can be considered as a portion of your application and has specific functionality. A good example is the “Messages” functionality in Facebook, a standalone application that does not alter other functionality. More about Ember Engines here: <a href="https://ember-engines.com/">https://ember-engines.com/</a> Using Ember Engines you can delegate portions of your front-end to a different team if you want.</p><h4>5. Scaling backend</h4><p>SAMBERs backend is based on AWS API Gateway, Lambdas, Fargate and Elastic Container Service, all Amazon Managed Services with high throughput and a lot of flexibility.</p><h4>6. Local development</h4><p>For backend development, you may use local DynamoDB or any other NoSQL or SQL-Flavored databases as your Docker containers. You can use Mirage.js to mock your backend data.</p><p>As to front-end UI/UX, Ember.js strives to eliminate logic in your views. It is very much like using Django framework filters in the views. Django people will understand this better. All that conforms to a better modularity, code reuse and complete separation of concerns, as Martin Fowler mentioned in his Layering Principles <a href="https://martinfowler.com/bliki/LayeringPrinciples.html">https://martinfowler.com/bliki/LayeringPrinciples.html</a>. Due to this separation, you can ask a person who knows only HTML and collaborate efficiently with your team of JavaScript developers.</p><h3>How does it apply to post-COVID19?</h3><p>I believe the post-Covid19 period will require even more scalable solutions to serve even more people on-line efficiently. If this will happen, we can save a lot of funds just by eliminating waste in resources by over-provisioning. In addition, to be able to quickly adapt and deploy new features for customers, relying solely on Cloud Providers and what they will have to offer.</p><p>You need to find a reliable cloud provider who is resilient during the pandemic.There is no better time than now to invest in Serverless product development using Amazon Web Services.</p><h3>Credits and appreciations</h3><p>All credits and thank-yous go to AWS SAM, Lambda and Ember.js Teams. I remember 2006, when I thought I could easily build a better Twitter. But working with complex systems and applications faded that feeling over the years. With SAMBER, the excitement of the Serverless approach and a new “all-is-possible” feeling is back again! Thank you for all your hard work and inspiration.</p><p>Image Credits:</p><ul><li>SAM — <a href="https://aws.amazon.com/blogs/aws/new-aws-sam-local-beta-build-and-test-serverless-applications-locally/">https://aws.amazon.com/blogs/aws/new-aws-sam-local-beta-build-and-test-serverless-applications-locally/</a></li><li>Ember.js — <a href="https://mattmazzola.typeform.com/to/iBiWjt">https://mattmazzola.typeform.com/to/iBiWjt</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e1a94d51b89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Salesforce to Oracle NetSuite Custom Connector. Closed-Won-Opportunities Synchronization]]></title>
            <link>https://medium.com/@konstankino/salesforce-to-oracle-netsuite-custom-connector-closed-won-opportunities-synchronization-3145917ce691?source=rss-1ca758931754------2</link>
            <guid isPermaLink="false">https://medium.com/p/3145917ce691</guid>
            <category><![CDATA[data-integration]]></category>
            <category><![CDATA[custom-connector]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[oracle-netsuite]]></category>
            <category><![CDATA[outsourcing]]></category>
            <dc:creator><![CDATA[Bogdan Kulbida]]></dc:creator>
            <pubDate>Tue, 26 Nov 2019 01:02:55 GMT</pubDate>
            <atom:updated>2019-11-26T01:02:55.944Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently <a href="https://konstankino.com/">we</a> were privileged to work on a Salesforce to NetSuite integration for one of our dear customers. This time our task was to build an Extract-Transform-Load (ETL) system for <em>Closed Won Opportunities</em> data synchronization from <strong>Salesforce to Oracle NetSuite</strong> (which we will call the Connector).</p><p>[The Complete Case-Study is available here <a href="https://konstankino.com/closed-won-opportunities-synchronization.html">https://konstankino.com/closed-won-opportunities-synchronization.html]</a></p><h3>Our Goals</h3><p>There are so many similar connectors available today, so you may ask why you would want to build a custom one? Our goal was to create an Information Technology solution that our customer would own as opposed to paying expensive monthly subscription fees and close to zero monthly associated expenses and burden on the IT department during adoption and product lifetime.</p><h3>Action</h3><p>Also, while working on the connector, we were able to add value by finding and resolving multiple data consistency issues. Data consistency issues are among the most expensive and hardest to fix IT problems. Only by carefully analyzing the data and talking to different people within the organization is it possible to build the system that proactively helps to investigate potential data consistency issues and gives enough controls for people to react proactively.</p><p>Checks for consistency and awareness about data integrity issues were the two free benefits that our customer got with the Connector engine. Perhaps we delivered such exceptional results because we worked so closely with the client’s Sales, Finance, and IT departments, collaborating as a single cohesive team. We were sharing ideas and our experiences to provide the best solution that fits perfectly into their business workflows.</p><p>When your goal is to deliver predictable results and value to your customer, there is no one-solution-fits-all. Business processes within an organization involve massive amounts of data, many systems working together, and a lot of people in-between. Keeping people away from raw data is probably the best thing the company can do to avoid many headaches.</p><p>We can’t emphasize the importance of this point enough. Most likely, there is no single person within the organization who knows everything, especially for large scale corporations. That is why it is vital to cooperate and carefully analyze requirements on every stage of the software development lifecycle. <em>Functional requirements may and will change, the specs may miss some of the critical aspects, but that is completely fine.</em> <em>What is essential and the most challenging is to deliver a product in time that solves problems and works predictably with the “bad” data it may consume.</em></p><p>Robust functionality and graceful data processing are not the only vital aspects in such strategically important integration. Proper security controls, logging, operational excellence, as well as awareness of what is happening within the system at any point in time all are crucial aspects as well. Together we learned a lot, shared ideas, and made tremendous improvements.</p><h3>Conclusion</h3><p>As a result of our collaboration on the Connector, our customer is now equipped with the robust and predictable ETL system that gives their personnel an ability to troubleshoot and investigate potential sources of “bad” data, react proactively by improving the data, and mitigate the root cause of the issues.</p><p><strong>We would not be able to achieve these results without many people within our customer’s multiple departments. A lot of gratitude and appreciation for this project goes to them. I am excited and thankful for the trust and cooperation.</strong></p><p>As of this writing, monthly cloud computing fees, for this integration, are around two dollars, expenses associated with the burden on IT are close to zero.</p><p>I believe there is so much more that <a href="https://konstankino.com/">Konstankino</a> has yet to offer to our dear customers to help them achieve greater efficiency and better meet their goals.</p><p>Everyone at <a href="https://konstankino.com/">Konstankino</a> hopes to continue mutually beneficial cooperation in the future.</p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3145917ce691" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Common Programming Concepts]]></title>
            <link>https://medium.com/@konstankino/common-programming-concepts-7e160f7cae6d?source=rss-1ca758931754------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e160f7cae6d</guid>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[quality-software]]></category>
            <dc:creator><![CDATA[Bogdan Kulbida]]></dc:creator>
            <pubDate>Sun, 26 May 2019 04:08:12 GMT</pubDate>
            <atom:updated>2019-05-26T04:08:12.802Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xw0qRgkX_hRCOEsM-JjaSg.png" /></figure><h3>Inspiration</h3><p>There are so many code camps these days and so many options of technology to learn. However, we ware surprised to see a lack of value, and some of those code camps provide very little of the fundamentals and programming concepts if any. This is how we got inspired to write this article.</p><blockquote>We really enjoy seeing your excitement! If you will find this article useful, please tap 👏 button below :)</blockquote><p>This article aims to quickly refresh knowledge in your memory or help to better understand common programming concepts and best practices. It will provide an introduction and give you the ability to dig deeper into the specific topic. There is so much more as this article only scratches the surface of the topic. However, the key aspects and general approach are elaborated in this article.</p><h3>Data</h3><p>Let’s start with data. This is any data that your program may work with, including command line interface parameters, database, file, API, or any other data source that you can think of. All those sources are very different but from the data consumer standpoint, it does not matter what data source you have. Each part of your program has to reason about the data it consumes. Here are a few key aspects:</p><ol><li>Do not trust your data.</li><li>Check all input parameters.</li><li>Decide how to process “bad” data.</li><li>Garbage-in, NO garbage-out.</li></ol><p>Let’s go through them one by one.</p><p><strong>Do not trust your data</strong></p><p>Programmers tend to take many things for granted and the data is not an exception. Do not take for granted that your program, method or function, or any other routine, will always receive legitimate data. This is especially true when we deal with dynamically-typed languages (using so called late-binding), such as Ruby, Python, or JavaScript, to name a few. <strong><em>Always validate your data</em></strong> before you start to process it.</p><p><strong>Check all input parameters</strong></p><p>This is a subset of the previous recommendation. In scope of the method call, within your method body always check for appropriate input parameters for the valid values. That can be done in many ways, and the most common ones are validation with regular expressions or testing for inclusion into the range of values. Make sure you cover all cases.</p><p><strong>Decide how to process “bad” data</strong></p><p>Always have a convention and a strategy for how you deal with bad data. <strong><em>Be consistent about how your program processes “bad” data</em></strong> throughout the program. Define a strategy and stick to it. Keep it simple.</p><p><strong>Garbage-in, NO garbage-out</strong></p><p>When you work on production grade software, make sure you gracefully deal with “bad” data. Your program or function should not produce “bad” data if it receives “bad” data. Encapsulate a graceful response to “bad” data throughout the program and make sure you handle it properly. This does not mean that you should “hide” issues. It means that you should fall back to “default” reasonable values and notify the appropriate part of your program about inappropriate data that your method has received. If someone gives your program “bad” data, do not propagate it up or down the chain. Again, try to be as consistent as possible.</p><h3>Sequential Code</h3><p>If you can write good <strong><em>sequential code</em></strong> then you are a good programmer. Writing good sequential code is not easy because you constantly need to resist changing it to be more “efficient” or “simpler to understand.” Code duplication is not always a bad thing and it depends on the specific situation. To write code that others will understand is a key aspect of programming. <strong><em>Avoiding complexity</em></strong> is probably the best advice in programming that one can get.</p><p>Sequential code assumes that your code is structured in logical blocks. All the similar instructions are placed close to each other, forming a logical block. Each block of code does one specific operation and the flow goes to the next one. Sequential code and <strong><em>proper naming</em></strong> convention dramatically improve your code readability and quality, and makes code support and collaboration easier and sweeter. That is why all the frameworks have a so-called “canonical way” to do some specific thing. They have specific terms and naming conventions as well.</p><h3>Naming</h3><p>Naming is probably the most important aspect in programming. We tend to take naming for granted, do not have solid conventions as to how we name things throughout the program, and sometimes miss the fact that <strong><em>naming is what makes the program clear and easy to read</em></strong> for other developers on the team or even for us six months in the future. Here are some general advices:</p><ol><li>Make sure the name of your variable or function reflects the point of its existence.</li><li>Make sure the name of your variable reflects the data type it holds.</li></ol><p>Here is some that you may want to avoid:</p><ol><li>Avoid abbreviations and names with double meanings.</li><li>Avoid names that sound similar.</li><li>Do not name things that have different meanings with similar names.</li><li>Avoid numbers in names.</li><li>Avoid spelling errors.</li></ol><p>We name things only to improve code readability of the code we produce. Among restrictions and limitations that we have expressing the logic, <strong><em>naming is a very powerful tool</em></strong> that you should thoughtfully use. Keep that in mind: stick to a solid naming convention and you will start to produce better code in no time.</p><h3>Conclusion</h3><p>In this article, we have shed some light on a few common programming concepts. As you can see, most of the programming and code organization issues can be avoided just by having solid conventions in place. For instance, good names for your variables, constants, and/or methods will make your code easier to read and maintain. Proper and consistent strategy for how to handle “bad” data will help to build reliable and production grade software, and the low code complexity and sequential code organization will conform to a better portability and the <a href="https://medium.com/@konstankino/code-elasticity-why-you-should-care-2c5f35e071c6">code elasticity</a>.</p><blockquote>Please tap 👏 button below :) Here is our clap 👏 to you. Thank you!</blockquote><p>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e160f7cae6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Code Elasticity & Why You Should Care]]></title>
            <link>https://medium.com/@konstankino/code-elasticity-why-you-should-care-2c5f35e071c6?source=rss-1ca758931754------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c5f35e071c6</guid>
            <category><![CDATA[elasticity]]></category>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[apps-development]]></category>
            <category><![CDATA[refactoring]]></category>
            <dc:creator><![CDATA[Bogdan Kulbida]]></dc:creator>
            <pubDate>Tue, 21 May 2019 15:57:37 GMT</pubDate>
            <atom:updated>2019-05-21T15:57:37.324Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBqQWdqeiEg8x20SQJSA8Q.png" /></figure><p>Have you ever wondered why a code becomes harder and harder to support and maintain? Or why you received a mind-blowing estimate from a contractor? Or maybe when you asked someone from your team to add a few simple features, you’ve gotten resistance of some sort? That’s probably not because they want to take advantage of you. There’s another reason, namely, the code they have to deal with.</p><p>In this article, we will explain why sometimes it is costly to change code, even when you might think the change is minor.</p><h3>1. Why?</h3><p>With just a handful of new features may come a significant burden on changing the code, and in most cases that is not a quick or straightforward operation. The code complexity and its ability to improve are two opposites, and both are based on the specific type of code cohesion.</p><p>If the code is complex and coupled, then, as a result, it may be harder and more expensive to change. On the other hand, if the code is simple and straightforward, it is based on another type of cohesion and so will be much simpler and cheaper to support, maintain, and add new features.</p><h3>2. Code Elasticity</h3><p>At <a href="https://konstankino.com/">Konstankino</a> we strive to deliver a quality product, that is why we use a specific term — “Code Elasticity.” This term is not new, and we did not invent it, but we do use it frequently. Code is considered elastic only when it is easy to change and improve. Code Elasticity is an elegant and ultimate process for any developer, whether senior or junior. The code can lose its elasticity when anyone on your team stops caring about its quality. That is why we have code review processes and quite a few gatekeepers before we get approval to merge our code into a major branch.</p><p>Elasticity is a constant process, and it is not a product. You cannot buy it, but you can gain it! So, let’s see how we can achieve this and make our code more elastic. Following some specific recommendations and principles can help to “elasticify” our code.</p><p>Cohesion (or code coupling) has many forms, and we will cover some of them in this article.</p><p>Here are the major players:</p><ol><li>Temporal Cohesion.</li><li>Communicational Cohesion.</li><li>Sequential Cohesion.</li><li>Logical Cohesion.</li><li>Coincidental Cohesion.</li><li>Procedural Cohesion.</li><li>Functional Cohesion.</li></ol><h3>3. Functional Cohesion</h3><p>Let’s start with Functional Cohesion since it is the most favorable. Functional Cohesion is your goal. That is what Ruby on Rails developers mean when they refer to the notion of Cohesion. Functionally Cohesive code is code that does one thing well and not much of anything else.</p><p>In terms of methods or functions it can be `<strong>getCustomer</strong>()`, `<strong>chargeCustomer</strong>()`, or `<strong>getProductFee</strong>()`, for instance. Those are the basic methods that do one specific thing and are named properly. The functions above can be constructed into a chain of calls, such as `<strong>chargeCustomer</strong>(<strong>getCustomer</strong>(), <strong>getProductFee</strong>(<strong>ProductA</strong>))`. Of course, some frameworks have their own “way” to do things. This specific example shows us what Functional Cohesion is and how you can achieve it. Strive to achieve Functional Cohesion.</p><h3>4. Procedural Cohesion</h3><p>Procedural Cohesion is a code smell that you should be aware of. It is a yellow flag for you to notice you might be going a little off course. This type of code cohesion assumes operations in the code are executed in a specific order. This is to say that you have a procedure, and your method has to follow it. This is OK, but what you can do to improve it is extract those operations into specific methods or a class (depends on how that particular operation deals with the data and interacts with other activities) so that each new method will be responsible for the complete execution of one single logical operation.</p><h3>5. Coincidental Cohesion</h3><p>Coincidental Cohesion is a huge red flag. This type of Cohesion happens within a method which has a few operations that are not related to each other. An example might be when the code requests a customer’s record from the database, then asks for his or her profile, and then does something with that data. In this case, the only person who reads this method wholly and thoroughly understands it will be able to change it safely. Operations in this type of arrangement have nothing to do with each other; it is you, a developer, who ties things together and tries to keep all moving parts in your head. There is no simple way to improve this type of Cohesion. The most straightforward way to deal with it is probably to completely rewrite your method or class and redesign it from the ground up.</p><h3>6. Logical Cohesion</h3><p>We have another yellow flag: Logical Cohesion. And actually, you can also see it in tutorials on how to use some specific tools. Developers from the React and Redux community will find it familiar, or at least this is what some tutorials about Redux tell you to do. During Logical Cohesion, there are a lot of choices within the method, and a specific logical choice gets chosen based on the flag passed into the method. Recall Reducers in the React world? (Note: ReactJS Reducer functions sometimes return a huge object with the key: value pars) That is Logical Cohesion example, so now you are aware of it. What can you do? The simplest thing might be to create a method for each operation and call those methods within a wrapper class. If there is some code repetition you would like to avoid, then you may extract that code into a lower-rank (of private) methods and wrap higher-rank (or public) methods together with lower-rank methods into a class.</p><h3>7. Sequential Cohesion</h3><p>Another yellow flag is a Sequential Cohesion where you have a few operations within your method that must be executed in a specific order and use intermediate data from the previous procedures. All those procedures do not form a coherent functionality. An example might be when the code incrementally shapes an object by passing it as a parameter to the next function, and each subsequent function call mutates the current object state. The same solution can be applied here by splitting this method into a set of smaller methods and then nesting them to form an execution chain.</p><h3>8. Communicational Cohesion</h3><p>If you think about global data and how it impacts the understanding of the code, then that is Communicational Cohesion which is yet another yellow flag. An example may be when a few operations within your method use the same data, but none of those operations relate to each other in any other way. To get rid of this antipattern, you may want to split your method into smaller methods or classes, and each method will be responsible for data initialization and accessing data independently via a data source.</p><h3>9. Temporal Cohesion</h3><p>Temporal Cohesion is when you have a few operations within your method, and each operation must be executed during one specific interval of time. An example might be when you create a user, and then you do some other “related” operations, such as sending emails, generating default configuration or profiles, etc. Again, the quick way to improve this is to split your method into smaller methods and call them within a high-order method.</p><h3>Conclusion</h3><p>In this article, we explained what Cohesion is, how to differentiate between types of Cohesion, and what to do to improve your code. As you can see, sometimes adding more features or new functionality may dramatically impact your code elasticity, budget, agility, and ability to deliver a quality product. As with Coincidental Cohesion, you have no other choice but to completely rewrite the code to improve it which is not feasible in most cases, and your product ends up a hostage with poorly designed code that is prone to errors, expensive to develop, and hard to maintain.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c5f35e071c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2019 Redux and Redux-Thunk for ReactJS. Explained.]]></title>
            <link>https://medium.com/@konstankino/2019-redux-and-redux-thunk-for-reactjs-explained-e249b70d6188?source=rss-1ca758931754------2</link>
            <guid isPermaLink="false">https://medium.com/p/e249b70d6188</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[2019]]></category>
            <category><![CDATA[apps-development]]></category>
            <category><![CDATA[redux-thunk]]></category>
            <dc:creator><![CDATA[Bogdan Kulbida]]></dc:creator>
            <pubDate>Mon, 20 May 2019 01:41:50 GMT</pubDate>
            <atom:updated>2019-06-04T04:43:54.561Z</atom:updated>
            <content:encoded><![CDATA[<h3>2019 Using Redux and Redux-Thunk with ReactJS. Explained.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SyVnOjQZF-FVaPPYdNjkTQ.png" /></figure><p>In this article, we are going to clarify what is <em>Redux</em> and <em>Redux-Thunk</em>. Here you will find all the information you need to understand where each fits into your application. Also, you will find a lot of examples with detailed explanations that will help you to understand all the concepts. Complementary source code will be provided for you as well with illustrations for a quick refresh.</p><blockquote><strong>We really enjoy seeing your excitement! If you will find this post useful, please tap 👏 button below :)</strong></blockquote><blockquote><strong>We will so much appreciate that!</strong></blockquote><h3>1. Redux and Redux-Thunk</h3><p>First, let’s clarify what <em>Redux</em> is. In simple words, <em>Redux</em> is a tool or an addon for your <em>ReactJS</em> App that mutates your application state and makes two-way state exchange possible between your App and a Store. <em>Redux</em> changes your application state upon actions that the user of your application initiates. Such an action could be a mouse click or a button press.</p><figure><a href="https://konstankino.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lRusm6IzNtCF0bEeWJRocQ.png" /></a></figure><p>A Store is a place in the memory within the browser where your application keeps its state.</p><p>What is <em>Redux-Thunk</em>? Essentially, it is an orchestration mechanism for commands for <em>Redux</em>. In other words, <em>Redux</em> changes application state upon instructions, and <em>Redux-Thunk</em> puts those instructions into a queue and makes sure each action is performed one at a time.</p><h3>2. Why?</h3><p>You may be wondering why we would want to orchestrate those commands? Since most of the events (or actions) within nearly all <em>ReactJS</em> applications happen asynchronously, to avoid race conditions, we need a robust mechanism, and <em>Redux-Thunk</em> is yet another synchronization tool.</p><p>Here is an example. Let’s assume you want to fetch data sequentially as part of your App logic. In request “<strong>A</strong>”, you fetch from the back end API user profile information, and then in request “<strong>B</strong>” by the CompanyID that came in the payload of the request “<strong>A</strong>”, you want to fetch details about the company. Since both requests are asynchronous, request “<strong>B</strong>” may start and finish before request “<strong>A</strong>” completes. Put simply, we have a few concurrent requests (because of the asynchronous nature of the environment in which our code executes), and so our code is prone to race condition bugs unless we explicitly control the order of each action’s execution. <em>Redux-Thunk</em> does that for us; it helps us to mitigate those issues and avoid data race conditions.</p><h3>3. Data-Down, Actions-Up</h3><p>Before we dive into <em>Redux-Thunk</em>, we need to understand some core concepts of the <em>Redux</em>. As we already mentioned, <em>Redux</em> is a tool that changes our application state, and to do that <em>Redux</em> needs to know where to take State object and where to put that object back once a mutation is done. We know that Store is a storage of some sort for our application State object. To achieve the desired behavior, we need to glue Store and our App together. How we do that? We create a Root component which takes our App and wraps it into a <em>Redux</em> native “Provider” component. A Root component is a gluing proxy object between our App and a Store. By wrapping App into the Producer component, we create a link for <em>Redux</em> and acknowledge it with the existence of our App.</p><p>To know what is “Data-Down, Actions-Up” design pattern is, please r<a href="https://medium.com/@konstankino/2019-reactjs-best-practices-design-patterns-516e1c3ca06a">ead this article</a>.</p><p>Now we need to acknowledge within our App the existence of the Store and create a link for two-way communication (remember, it is a two-way binding information exchange to make <em>Data-Down -&gt; Actions-Up</em> work).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f523d987347cc4f6eb1a42fa2d604ee/href">https://medium.com/media/5f523d987347cc4f6eb1a42fa2d604ee/href</a></iframe><p>We do that by passing “store” property into the Provider component. So now the Provider is aware of our App’s existence and where the Store location is. Here is some code on the left that illustrates what we have just said.</p><p>Let’s step back and clarify where `this.props.store` came from. And to answer that question, let’s take a look at our entry point `index.js` file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70c2b56eac29a79efacd38e96539399f/href">https://medium.com/media/70c2b56eac29a79efacd38e96539399f/href</a></iframe><p><strong>Line #18</strong> we mount our Root component into the HTML page — nothing exciting there. However, look at how we pass on “store” as a property (or props) into Root component. Also, <strong>on line #16</strong> we create our “store” object. We use the method `createStore` that ships with <em>Redux</em> and apply middleware with “<strong>thunk</strong>” object. About “<strong>thunk</strong>” we will talk later in this article. The line that has the most interest for us is <strong>line #12</strong>. We create a “<strong>reducer</strong>” object on that line, which is essentially a management layer for <em>ReduxJS</em> to mutate application `state` object.</p><p>Here is a general overview of what we have just said:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FB3CmLoP7jdNorwp5p86-g.png" /><figcaption>General structure of pretty much any ReactJS app</figcaption></figure><h3>4. Reducer</h3><p>`combineReducers` function accepts a hash object, and in our case that object has a single key-value pair. Please note that we named the key `state` — it is important. We will get back to that in a bit. For now, it is essential to understand that we need to create a single `reducer` object by calling `combineReducers` function and pass on all reducers our application may have. In our example, we have one reducer that is brought into the scope as a `subscriptions` object from the external file. Let’s take a look at our <em>Reducer</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11d0ef6dfb89d58a094d411b8c5e4dd1/href">https://medium.com/media/11d0ef6dfb89d58a094d411b8c5e4dd1/href</a></iframe><p>The <em>Reducer</em> has a few constants that represent action names that it needs to know how to handle. Then it has some default or better to say the initial state. <strong>Line #13 to #46</strong> is our <em>Reducer</em> in its glory. As we can see, it knows now to handle three commands or actions (match arm for each case operator).</p><p>OK, let’s pause with our <em>Reducer</em> for a second and switch back to our App component. We have a few more concepts to clarify.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13ff3caac0c790f042046ca3432c3961/href">https://medium.com/media/13ff3caac0c790f042046ca3432c3961/href</a></iframe><p>Let’s take a look again at the `App` component. Previously, we mentioned two-way communication <em>Store</em> -&gt; <em>Redux</em> -&gt; <em>App</em> to render our application with data on the screen, and <em>App</em> -&gt; <em>Redux</em> -&gt; <em>Store</em> to continue the same state in the <em>Store</em> when <em>Reducer</em> updates (or shapes) our application `state`.</p><p>To make two-way communication possible, we need to apply some magic that <strong>redux</strong> and <strong>react-redux</strong> have to offer. And that is the `connect` method. We call that method with some configuration functions `mapStateToProps` and `mapActionsToProps`. Then whatever callback function is able to `connect` returns, we pass on to our `App` component and execute that callback. At this stage, you have your App “on steroids.” That is all we need to know for now. Take that for granted.</p><h3>5. Gluing Things Together</h3><p>Now, let’s take a look at `mapStateToProps`. That is a data layer of your application State. In our simple case, it returns a `state` object; however, as your application grows, you may want to slice that single `state` object into smaller, more cohesive and functional chunks of state and return a more complex data structure that conforms to your business logic and abstract or real-world objects within your application.</p><p>Another exciting portion of bits is `mapActionsToProps`. That is a behavioral or functional layer of your application. That is a scope where all your actions for all your components live. As you can see, we named our scope `actions` but again, as your application gains more code, you may want to slice and group your actions into cohesive, functional abstractions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13ff3caac0c790f042046ca3432c3961/href">https://medium.com/media/13ff3caac0c790f042046ca3432c3961/href</a></iframe><p>Now, let’s look at <strong>line #12</strong>.</p><p>Remember when we previously named our key `state` above? That is where things get glued together. We are destructuring `this.props` and binding to `actions` and `state` variables and passing them onto our main component. Now our `MainComponent` knows where to take data (or state) from the Store and has some actions to offer for nested components.</p><h3>6. Wiring Actions To the Component</h3><p>Before we move on to our `MainComponent`, let’s clarify how we make `actions` available for our components.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13ff3caac0c790f042046ca3432c3961/href">https://medium.com/media/13ff3caac0c790f042046ca3432c3961/href</a></iframe><p>On<strong> line #6</strong>, we load and bind `SubscriptionActions` from an external file. We don’t have to know what those actions are at this point; we will get back to that later. However, what interests us now is a way we plug-in those actions into our App via `mapActionsToProps` function. Again, we use some magic that <em>Redux</em> provides to us. Please note, we pass on function `dispatch` into our “actions” hash, that is how we create an interface or an API for <em>Redux-Thunk</em> to be able to manage and orchestrate operations on <em>Redux</em>’s behalf. We will get back to <em>Redux-Thunk</em> in the next section.</p><figure><a href="https://konstankino.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gtdbak1wvSano9rhaYYiMg.png" /></a></figure><p>Now it’s time to dive deeper and understand our application’s actions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd23743742f37a2e01fc228813e93bbc/href">https://medium.com/media/fd23743742f37a2e01fc228813e93bbc/href</a></iframe><p>In this file, we define names for our actions by binding them to constants since they will never change and should be reused in our <em>Reducer</em>. What is interesting in this file is a function `fetchSubscription`. That is a public API for our component to trigger an action and initiate all the related actions. Note it calls “dispatch” functions quite a few times, and that is where we use an interface of the <em>Redux</em> and plug-in <em>Redux-Thunk</em> to be responsible for subsequent actions’ execution.</p><h3>7. Tripod: Three Sub-states</h3><p>It is considered good practice to have three distinct actions (or sub-states) for one single interaction with your component. For example, when we click on a button, we expect to:</p><p>1. Show a loader =&gt; <strong>this is sub-state one</strong></p><p>2. Fetch the data from the API, and</p><p>3. Once fetch succeeds, hide our loader and re-render our component on the screen. =&gt; <strong>this is sub-state two</strong></p><p>4. If the fetch fails, we may want to hide our loader and display an error message =&gt; <strong>this is sub-state three</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd23743742f37a2e01fc228813e93bbc/href">https://medium.com/media/fd23743742f37a2e01fc228813e93bbc/href</a></iframe><p>Here is how that could be designed using three actions for one user interaction approach. `fetchSubscriptionBegin` is an action for subscription reducer to mutate our application state to show a loader. See our subscription actions code below again; <strong>on line #16</strong>, it sets `loading` to `true` via `fetchSubscriptionBegin` function. The following step, we call `fetch` function to get the data from the back end API, and once it is finished, we want <em>Redux-Thunk</em> to trigger the appropriate action: `fetchSubscriptionSuccess` or `fetchSubscriptionFailure` respectively.</p><p>Please note you may have an explicit layer to handle errors. In our subscriptions actions example below, we have a simple `handleErrors` proxy function, but for your application, you may choose a more robust approach.</p><p>All three actions (or sub-states) `fetchSubscriptionBegin`, `fetchSubscriptionSuccess` and `fetchSubscriptionFailure` inform our <em>Reducer</em> that some part of our application state needs to change. All functions must return a simple JSON object with required `type` field that corresponds to an action type and so defines a slice of the state that <em>Reducer</em> has to mutate or change. Also, you may pass on any other data, such as we do with the `payload` key-pair, which is a JSON object that we got from our back end API.</p><p>Now, it’s time to look at our `MainComponent` and see where we trigger our `fetchSubscription` action.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ba0b5787ffb47d6a30c1e5cb75a7eea/href">https://medium.com/media/4ba0b5787ffb47d6a30c1e5cb75a7eea/href</a></iframe><p>The `MainComponent` is a straightforward component; our goal is to avoid extra complexity and make it as lean as possible. The function that interests us here is `handleLoadDataOnClick`. That is where we pass-in our back end API endpoint URL and trigger action with our `SubscriptionActions` scope object. For the sake of simplicity, we hard-coded the back end API URL. Also, note how we used the `loading` flag to give feedback to the user. Here is a quick demo:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*VETzbYo9FHZUN0HjN_ccsQ.gif" /></figure><h3>8. Conclusion</h3><p>In this article, we clarified what is <em>Redux</em> and <em>Redux-Thunk</em>. Here you have all the information you need to understand where each fits into your application. We showed some real-world examples with detailed explanations that help to understand all the concepts. If you like this article, <a href="https://connect.konstankino.com/">please subscribe to our newsletters to get fresh updates</a> — it is free.</p><p>As a thank you, <a href="https://github.com/konstankinollc/redux-redux-thunk-explained">here is a complete source code that we demonstrated in this article</a>. You can use our code and pictures to refresh your knowledge at any time.</p><blockquote>We really <strong><em>need</em></strong> your clap! Please tap 👏 button below :) Here is our first 👏 to you. You are amazing!</blockquote><p>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e249b70d6188" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we built a Serverless ETL data integration from NetSuite to Salesforce]]></title>
            <link>https://medium.com/@konstankino/how-we-built-a-serverless-etl-data-integration-from-netsuite-to-salesforce-d57d963d2bae?source=rss-1ca758931754------2</link>
            <guid isPermaLink="false">https://medium.com/p/d57d963d2bae</guid>
            <category><![CDATA[currency-exchange-rates]]></category>
            <category><![CDATA[data-synchronization]]></category>
            <category><![CDATA[data-integration]]></category>
            <category><![CDATA[netsuite-to-salesforce]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Bogdan Kulbida]]></dc:creator>
            <pubDate>Wed, 10 Apr 2019 18:36:51 GMT</pubDate>
            <atom:updated>2019-04-10T20:51:09.935Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Here is an a-ha</em> <em>moment</em> in building serverless, cost-effective NetSuite and Salesforce data integration. We will tell you how we built a solution and <em>saved more than $6,000</em> annually for one of our customers.</p><p>Serverless computing is becoming a thing these days, and many companies have already adopted this approach to build their products and tools. You can see how we created serverless integration to integrate data for one of our customers. Serverless is no longer slow, as many people think. However, serverless execution for cloud-delivered applications must be applied thoughtfully.</p><h3>Our goals and requirements</h3><p>We were about to start building a long-term low total cost of ownership solution for our customer. Some of the requirements were:</p><ol><li>Reliable and robust data integration tool for currency exchange rates from NetSuite to Salesforce.</li><li>Be able to configure integration from Salesforce without writing the code in Apex.</li><li>Safely store all sensitive information.</li><li>Build a library so that our customer IT department can extend an integration in the future if needed.</li><li>Close to zero monthly associated expenses and burden on the IT department during adoption and product lifetime.</li></ol><p>We chose to use AWS Serverless Application Model (SAM) over Serverless Framework. We made this logical decision for a few reasons:</p><ol><li>A lot of new infrastructures that our customer built was already in AWS Cloud.</li><li>They were migrating old infrastructure into the AWS.</li><li>AWS provides a combination of the tools and building blocks that we needed without significant changes to the off-the-shelf.</li></ol><p>Serverless Framework suites better if you need to have multi-cloud support. For instance, if you need to deploy your serverless code to Microsoft Azure and AWS at the same time. We suggest that you may want to use AWS SAM if you are building AWS specific integrations since it designed explicitly for AWS. You may think it sounds like a vendor-lock, but it is not: both frameworks are similar, which allows you to migrate your code from AWS SAM to Serverless Framework and vice versa.</p><p>AWS SAM provides excellent support for local development out of the box without installing additional plugins.</p><p>The decision on the language came naturally. We are experts in writing serverless Python code (or Python Serverless if you will), so this came well into play with our customer needs, as most of their engineers are Python experts.</p><h3>One-time quick set-up</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LDVBT8DMU8QNWcrTPPKviQ.png" /></figure><p>Here is a diagram of the user interaction with the system. On this diagram, we show the NetSuite to Salesforce data connector which does the heavy lifting in the integration.</p><p>It only requires NetSuite and Salesforce administrators to set credentials once.</p><p>We built serverless web applications for both NetSuite and Salesforce to securely encrypt and store login credentials.</p><h3>Action</h3><p>Once the system was deployed and configured, it started to synchronize data from the NetSuite to Salesforce, based on Salesforce custom object time field. Here is a detailed diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bZxCmfhnWb4O3pOpZpnJAw.png" /></figure><p>In step one, we decided to pull schedule changes from Salesforce instead of triggering an action on custom object field change, adding a trigger in Apex would couple this integration with Salesforce implementation more tightly, which is not what we wanted. It would also expose a Lambda function endpoint to the world, which would add a vector for a cyber attack. Instead, we used the Salesforce REST API to ask for record change in our Scheduler Lambda function.</p><p>A quick demo of the serverless integration we built is shown. With a single command, you can quickly deploy the entire serverless stack.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F327614989%3Fapp_id%3D122963&amp;dntp=1&amp;url=https%3A%2F%2Fvimeo.com%2F327614989&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F771928107_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/90009c7caef90ddb20bae6df97f06b03/href">https://medium.com/media/90009c7caef90ddb20bae6df97f06b03/href</a></iframe><p>Before this integration, someone from the company, once a week has to create or update dated exchange rates in Salesforce manually. That person did not even have access to the NetSuite, so they have to use some other source for currency exchange rates for each day of the week. By eliminating this routine, repetitive and error prone work and avoiding monthly fees on expensive connectors that exist, we ware able to save for our customer thousands of dollars per year.</p><p>As of this writing, monthly cloud computing fees, for this integration, are around three dollars, expenses associated with the burden on IT are close to zero.</p><h3>Conclusion</h3><p>In this article, we have shown one example of how to implement a serverless approach for building reliable data synchronization tools. In this case, it is a data synchronization, or data connector tool. It is a cost-effective, efficient and secure way for data integration solutions.</p><p>At <a href="https://konstankino.com/">Konstankino</a>, we can solve our customers’ computing needs using effective serverless integrations. Email us at info[at]konstankino.com if you need help with your serverless computing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d57d963d2bae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Django + ReactJS * Magic = App]]></title>
            <link>https://medium.com/@konstankino/django-reactjs-magic-app-8602da53f3e4?source=rss-1ca758931754------2</link>
            <guid isPermaLink="false">https://medium.com/p/8602da53f3e4</guid>
            <category><![CDATA[django-rest-framework]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[django-with-react]]></category>
            <category><![CDATA[react-on-django]]></category>
            <category><![CDATA[django-rest-with-react]]></category>
            <dc:creator><![CDATA[Bogdan Kulbida]]></dc:creator>
            <pubDate>Sat, 16 Mar 2019 21:07:58 GMT</pubDate>
            <atom:updated>2020-02-11T16:20:37.518Z</atom:updated>
            <content:encoded><![CDATA[<h3>Django with ReactJS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EPAjI8i5QSSrEEyEnd9rcw.png" /><figcaption>Django REST + ReactJS = Fast and Snappy App</figcaption></figure><p>We are excited to share yet another happy story of a recent open-source project we were privileged to work on. The system was an old-school Django monolith application that the San Jose International Airport used for managing their ads infrastructure.</p><p>The system was developed to manage various devices via a dashboard, such as Projectors, Creston, and BACNet devices.</p><figure><a href="https://konstankino.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0iIRnF6ziYkqg3mAM1t7fA.png" /></a></figure><p>Our task, firstly, was to develop a solid architecture that could encompass hundreds of different devices; secondly, to design and code both the back-end and front-end systems to manage the airport’s infrastructure and SOLIDify (the system’s API).</p><blockquote>If you will find this post useful, please consider 👏 :)</blockquote><h3>1. Back-End API: Refactoring Django monolith application</h3><p>When our team made its initial code review and audit, we discovered that the system did not have a solid and consistent way for devices to communicate; their interoperability was hampered by incompatible interfaces.</p><p>Here is an examples of the code that we inherited, a small portion of the views.py file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/923b296f7d8b4817a862b0cd595499b3/href">https://medium.com/media/923b296f7d8b4817a862b0cd595499b3/href</a></iframe><p>The code above we refactored to the code displayed below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ad0031ddbb43b1aa1e90ed54d4b8196/href">https://medium.com/media/9ad0031ddbb43b1aa1e90ed54d4b8196/href</a></iframe><p>Also, the code was changed to use a “connector” proxy to talk to devices (the code of the “connector” is not shown here). We consolidated the code into a solid API with a versioning in place:</p><p>Here is a view_v1 of the API:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5fcb536f3c56d9befb109ff468791d3/href">https://medium.com/media/f5fcb536f3c56d9befb109ff468791d3/href</a></iframe><p>Here is an API helper module:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7fe6a356d96c6b6296857df76473e397/href">https://medium.com/media/7fe6a356d96c6b6296857df76473e397/href</a></iframe><p>We also added data serializes to feed data to our front-end ReactJS app. Here is an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/efc3d4707f5530bafe71b87493edf7c7/href">https://medium.com/media/efc3d4707f5530bafe71b87493edf7c7/href</a></iframe><p>And, of course, we covered all the API end-points with tests, to make sure they work as expected, responding with proper HTTP status code and a JSON data structure:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3533b337c52402d1f4e42394d63d3ea/href">https://medium.com/media/b3533b337c52402d1f4e42394d63d3ea/href</a></iframe><h3>2. Refactoring Django with ReactJS fast and snappy App</h3><p>We have replaced old and junky Django views with ReactJS App, here is how we bootstrapped our code into an existing App:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*_SI_gVx-qQJheGIqU7854A.png" /><figcaption>On line 12 we inject Back-End endpoint URL for our React components</figcaption></figure><p>We used coffee-script and created clean and easy to work with React components. We do not recommend you creating your App this way though. You probably should stick with a React-way of doing it and having an explicit stand-alone React App instead.</p><figure><a href="https://konstankino.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lRusm6IzNtCF0bEeWJRocQ.png" /></a></figure><p>We had to create our React components this way due to particular circumstances. Here is an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/409983f2f74f5290c7b5da6acc25f39c/href">https://medium.com/media/409983f2f74f5290c7b5da6acc25f39c/href</a></iframe><h3>3. Conclusion and a Demo</h3><p>At this time, the system has been successfully launched into production and is currently in use by the airport. We have shown you just a small part of the application, however it gives you an idea what benefits you can gain when you split your application into two parts: front-end app and a solid API. We showed how you can use powerful Django REST API to build flexible end-points and easily serialize your data.</p><p>We are excited and proud that the new system streamlines the process of managing their ads infrastructure. Here is a quick video and a demo:</p><p><a href="https://vimeo.com/324720723">https://vimeo.com/324720723</a></p><p>Original source: <a href="https://blog.konstankino.com/post/san-jose-international-airport-we-did-it/">https://blog.konstankino.com/post/san-jose-international-airport-we-did-it/</a></p><p>The project is open source and available at GitHub <a href="https://github.com/Konstankino/art-infrastructure/tree/sprint4">https://github.com/Konstankino/art-infrastructure</a></p><blockquote>If you find this post useful, please tap 👏 button below :)</blockquote><p>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8602da53f3e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CRM App Development To Streamline Enrollment Process]]></title>
            <link>https://medium.com/@konstankino/crm-app-development-to-streamline-enrollment-process-f09c80bbea86?source=rss-1ca758931754------2</link>
            <guid isPermaLink="false">https://medium.com/p/f09c80bbea86</guid>
            <category><![CDATA[crm-development]]></category>
            <category><![CDATA[reactjs-development]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[fullstack-development]]></category>
            <dc:creator><![CDATA[Bogdan Kulbida]]></dc:creator>
            <pubDate>Thu, 14 Mar 2019 01:15:21 GMT</pubDate>
            <atom:updated>2019-03-14T01:16:50.700Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PEy_UWa_s1y9eKo9.png" /></figure><p>These days there are an abundance of general-purpose tools, platforms, and apps that help us to organize our business processes. That being said, we still see many opportunities to improve, create, integrate and innovate through custom-built solutions.</p><p>Look at the case of a unique project that we built for one of our customers in 2014, another Konstankino success story. The impactful project, envisioned by our Founder, improved upon PDF forms processing for the Montessori School of Central Vermont.</p><p>Here is how the App looks on the phone</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C9PL32WZACVWu0Uv.png" /></figure><p>Back in 2014, the school did not have solid automation tools to simplify and streamline their enrollment process, customers, and data management. Bogdan’s son, Konstantin, was attending that school, so the solution came up naturally in conversations with the school’s management.</p><p>Here is how the App looks on the tablet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mZwXZw9jf6ckaebJ.png" /></figure><p>Based on various interviews, we were able to create a proposal and a quick prototype that were a perfect match to the school’s needs. Because each Montessori school has a unique enrollment process workflow, we were able to develop an app that perfectly matches school needs and enabled the school personnel to work with the app efficiently, securely and pleasantly. Once the prototype was approved, we created a production-grade CRM platform and helped the school to import all their data into a new structure.</p><p>Here is how the App looks on the laptop or desktop</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-dsimYoDYsljGKzh.png" /></figure><p>Enrolled families also felt a positive impact when we launched the app into production. We adapted it for various devices and made the system truly platform-agnostic. It works perfectly well on phones, tablets, or laptops. If desktop computers, i.e., big boxes with separate monitors and keyboards, still exist when you read this article, rest assured that our app will work just fine on them, too.</p><p>Here is a feedback from <strong>Kristen Martin, the School Principal</strong>:</p><blockquote><em>Konstankino has been an invaluable resource in the development an application of our online Parent Portal. Based on various interviews and review of paper forms needed for enrollment, Bogdan designed and developed a portal whereby all of our paper systems were eliminated. Parents of children who have attended our program for many years appreciate the ease of the system, as well as the efficiency and availability of information/required forms. Bogdan provided technical support during the initial launch, as well as welcoming any feedback or improvements that needed to be made after the portal was in use.</em></blockquote><p>The app is still in use by the school, helping to streamline and improve enrollment processes and eliminate paperwork hassles. Over the past 5 years, we have added quite a few improvements and additions to it since it was originally launched.</p><p>At <a href="https://konstankino.com/">Konstankino</a>, we are experts in creating apps that make organizations function better and get more done at lower costs. If you need to build an app for your business — we are here to help. <a href="https://konstankino.com/contact">Contact Us</a> or <a href="https://calendly.com/konstankino/welcome">Schedule a Call</a> to help you validate your idea.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f09c80bbea86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[2019 ReactJS Best Practices & Design Patterns]]></title>
            <link>https://medium.com/@konstankino/2019-reactjs-best-practices-design-patterns-516e1c3ca06a?source=rss-1ca758931754------2</link>
            <guid isPermaLink="false">https://medium.com/p/516e1c3ca06a</guid>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Bogdan Kulbida]]></dc:creator>
            <pubDate>Fri, 08 Mar 2019 16:38:53 GMT</pubDate>
            <atom:updated>2019-12-25T08:39:33.901Z</atom:updated>
            <content:encoded><![CDATA[<h3>2019 ReactJS Best Practices</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o_hcBOJGVurwNEsN.png" /></figure><p><strong>[update, May 22nd, 2019] — Add another one best practice to the list. See below.</strong></p><p>[<strong>update, May 19th, 2019] — </strong><a href="https://medium.com/@konstankino/2019-redux-and-redux-thunk-for-reactjs-explained-e249b70d6188"><strong>We added a new article about Redux and Redux-Thunk.</strong></a><strong> Simply explained with lots of examples.</strong></p><p><strong>[update, July 23, 2019] — Due to many requests, we will add a new article about ReactJS ANTIpatterns. The link will be posted here. Please support with a clap. Thank you!</strong></p><h3>1. Please welcome, ReactJS</h3><p>For the past five years, <em>ReactJS</em> has been rapidly increasing in its popularity and by the beginning of 2018 it became more popular than jQuery, at least in terms of Google searches. We will not be comparing tools in terms of their demand in the search engines; however, that gives us a clear understanding that the <em>ReactJS</em> library is definitely popular. With that being said, let’s talk about using <em>ReactJS</em> to create better Front-End apps.</p><p><strong>We really enjoy seeing you enjoy our writings. So If you find this post useful, please tap 👏 button below :)</strong></p><p>What makes <em>ReactJS</em> so popular, besides the fact that Facebook created it? We think it’s due to <em>ReactJS</em> being straightforward to work with. It is easy to learn and it’s optimized for performance by using its virtual DOM. By implementing virtual DOM, <em>ReactJS</em> offers a rendering engine a way to quickly re-render only those elements that need to be updated. As a result, <em>ReactJS</em> developers are getting apps that are fast and pleasant to use.</p><p><em>ReactJS</em> is a library that uses JavaScript to create apps. To start building apps in <em>ReactJS</em>, you need to learn its API and know JavaScript. JavaScript is probably the most popular programming language these days. <em>ReactJS</em> also enables developers to model and describe an app in UI components. So you just say what to do and <em>ReactJS</em> knows how to do it.</p><p>Here are some trends for the past five years from Google:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zk2Dnw2vsSOVm4QN9B2sdw.png" /></figure><p>One of the main <em>ReactJS</em> concepts is that you create reusable, cohesive components that can be put together and form an app. Each component may have its own state unless it is state-less (more about this later). <em>ReactJS</em> collects all your components into one bucket and applies some optimization techniques such as virtual DOM to render the app in your browser efficiently.</p><p>Let’s start by clarifying what a component is and what it is not. The component is a self-sufficient, independent part of the UI. Each component can embed other components, where each one has its state and API. By convention, you should keep your component-related code inside one specific folder. Keeping all the files for each component in a single folder allows you to create reusable components so that you can use them in the other apps.</p><h3>2. Types of <em>ReactJS</em> components</h3><p>There are four main types of <em>ReactJS</em> components:</p><ol><li>State-full or class-based components</li><li>State-less or function-based components</li><li>Presentational (or high-order) components</li><li>Container components</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*p1Ej4slk27NuCISlt0EcYA.png" /></figure><p>A preferred structure of your components tree is displayed on the left.</p><h4>State-full components or class-based components</h4><p>A state-full component has its state and data associated with the state. You can pass data inside this type of component via state or props objects. State-full components are also harder to support as they persist some data and may change the global state of the app. Also, state-full components are most often class-based components that have a constructor (it’s considered a best practice to set state for your component in the constructor).</p><p>Here is an example of the state-full, class-based <em>ReactJS</em> component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1-H1z9phHWTRfze7.png" /></figure><p>Props are immutable and are one-way bound to a state, and this is why you cannot change them within your component. You use props to set a state for the component and to render its UI. If you try to change props in your component, you will get a Type Error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81eK6pKH81DChtOV4CdjfQ.png" /></figure><p>State is an object that is exposed to a component. State scope is limited to inside the component where it is declared. Components can initialize state and pass it to another component. We can declare a state in two ways, using the constructor or declaring state property. With the second case, that is just syntactic sugar, and the transpiler (such as Babel) will turn your state property declaration into the constructor for you under the hood. State-less components or function-based components and what React Hooks is for Function-based components are just simple JavaScript functions. Function-based components return a <em>ReactJS</em> element or a collection, which can be a ‘partial component’ like &lt;&gt;...&lt;/&gt; or a fully function-based component with the logic and embedded components. Since you cannot use a constructor in a function-based component (well, actually you do, since <em>ReactJS</em> v16.8), you cannot make your component state-full. It is state-less because you cannot persist any data in these types of components. Most often you pass in props to the function-based component to render its UI.Here is an example of the state-less, function-based <em>ReactJS</em> component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UjwffjIGdUgC7F6D.png" /></figure><p>From the performance point-of-view, there is practically no difference between using class-based components and using function-based components. <em>ReactJS</em> rendering mechanism is smart enough to optimize that for us.</p><p>Function-based components are easier to work with and more comfortable to test. This is why the community of <em>ReactJS</em> developers will nudge you to write function-based components instead of class-based ones. State-less function-based components have some limitations and essentially must have one global place to manage state. That is different from the <em>ReactJS</em> paradigm of writing components (for more details, see below).</p><p>To enable developers to write state-full, function-based components and at the same time give the ability to use state and component life-cycle methods, React v16.8 added a new feature called React Hooks. Essentially, React Hooks is an attempt to remove class-based components. With React Hooks you can write state-full function-based components without using classes. Probably we will see class-based components eliminated with Hooks at some point in the future.</p><p>React Hooks also aims to simplify application design by avoiding components that do not have or do not need constructors although they are declared as classes. Most often you work with state-less components if you think about the ideal design of your app. When we build <em>ReactJS</em> apps for our clients, we usually use a thin layer between our component representation and the application’s logic. This allows us to decouple the visual representation of the component from its behavior.</p><h3>3. Data-Down, Actions-Up</h3><p>What is the «<strong>Data Down, Actions Up</strong>» design pattern? Essentially it means you have a Higher-Order Component (<strong>HOC </strong>— see explanation below) which accepts the data in its `props` and passes that data down into its view or nested components. To interact with the component, users trigger actions such as pressing a button and the component responds to that interaction by emitting events. So to say, it triggers an event up, in the opposite direction to how that data was passed.</p><p>Those events or actions are passed up to a parent component. The parent component triggers another action that changes a global application state.</p><h3>4. Higher-Order Component</h3><p>Higher-Order Component (or <strong>HOC</strong>) is essentially a design pattern, also known as a Decorator Pattern. In <em>ReactJS</em>, a <strong>HOC</strong> is a component that wraps another component by adding extra functionality or extra properties. This allows abstraction from some commonly used logic and keeps your code <strong>DRY</strong>. It is how you distribute complex component structure between other components in <em>ReactJS</em> and a way to decouple your application logic and UI. For instance, you may use container component as a <strong>HOC</strong> for your presentational Button component.</p><p>Here is an example of the <strong>HOC</strong> <em>ReactJS</em> component:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w-QLTAF5W7i42jZs.png" /></figure><h3>5. Container components</h3><p>Container components, on the other hand, have logic to set state or have functions to emit events up to a parent component. The general rule of the thumb is to keep your component as simple as possible with a Single Responsibility Principle design principle in mind, which essentially means your component must do one thing, but do it well. Most often, these types of components are the <strong>HOC</strong>s that accommodate few presentational components. Presentational components Writing simple components may reduce your overall application complexity. Here is where presentational components come into play. These components should have minimal to no logic. Presentational components accept data and emit events to a callback that they receive as part of its props. Essentially, this type of component renders UI and executes a function that was passed into it when some action in its UI happens. This type of component is a building block and is sometimes referred to as a Lower-Order Component (or <strong>LOC</strong>).</p><figure><a href="https://konstankino.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lRusm6IzNtCF0bEeWJRocQ.png" /></a></figure><h3>6. Best Practices List</h3><ul><li><strong>[Update May 22nd, 2019] — </strong>When using <em>ReduxJS</em>, split your <em>Reducer</em> code into smaller methods to avoid huge JSON within your <em>Reducer</em>.</li><li>Consider using TypeScript in your apps if you do not do it already.</li><li>Use the create-react-app generator to bootstrap your <em>ReactJS</em> app.</li><li>Keep your code DRY. Don’t Repeat Yourself, but keep in mind code duplicate is NOT always a bad thing.</li><li>Avoid having large classes, methods or components, including <em>Reducers</em>.</li><li>Use more robust managers to manage application state, such as <em>Redux</em>.</li><li>Use event synchronizer, such as <em>Redux</em>-<em>Thunk</em>, for interactions with your back end API.</li><li>Avoid passing too many attributes or arguments. Limit yourself to five props that you pass into your component.</li><li>Use <em>ReactJS</em> defaultProps and <em>ReactJS</em> propTypes.</li><li>Use linter, break up lines that are too long.</li><li>Keep your own jslint configuration file.</li><li>Always use a dependency manager with a lock file, such as NPM or yarn.</li><li>Test your commonly accessed code, code that is complex and prone to bugs.</li><li>Write more tests that give more test coverage for your code with a little effort and test code to ensure its proper functioning.</li><li>Every time you find a bug, make sure you write a test first.</li><li>Use function-based components by starting to use React Hooks, a new <em>ReactJS</em> way to create state-full components.</li><li>Use ES6 de-structuring for your props.</li><li>Use conditional rendering.</li><li>User `map()` to collect and render collections of components.</li><li>Use partial components, such as `&lt;&gt;` … `&lt;/&gt;`</li><li>Name your event handlers with handle prefixes, such as `handleClick()` or `handleUpdate()`.</li><li>Use `onChange` to control your inputs, such as `onChange={this.handleInputChange}`.</li><li>Use JEST to test your <em>ReactJS</em> code.</li></ul><p>We have mentioned event synchronizers, such as <em>Redux-Thunk</em>. <em>ReactJS</em> v16.3 introduced a new feature called React Context API. Part of its functionality is to mimic redux-thunk functionality and synchronize events with <em>ReactJS</em> means. That is a feature that is in high demand, as nearly any <em>ReactJS</em> application talks to back end API and needs to synchronize requests and events. We will keep our eye on that API and will keep you posted with updates.</p><p>Here is an example of using defaultProps and propTypes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jRKmcUovWbWh9tkt.png" /></figure><h3>7. Conclusion</h3><p>We hope this article sheds some light on <em>ReactJS</em> best practices and patterns that are very popular in 2019. As a bonus see another article below. There is one more thing…</p><blockquote>We really need your clap! If you find this post useful, please tap 👏 button below :) Here is our first 👏 to you. You are awesome!</blockquote><p>.</p><p><strong>Bonus material:</strong> Here is our recent article about <strong><em>Redux</em></strong> and <strong><em>Redux-Thunk</em></strong>. We will explain how two work together.</p><p><a href="https://medium.com/@konstankino/2019-redux-and-redux-thunk-for-reactjs-explained-e249b70d6188">https://medium.com/@konstankino/2019-redux-and-redux-thunk-for-reactjs-explained-e249b70d6188</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=516e1c3ca06a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RabbitMQ for Inter-Process Communications.]]></title>
            <link>https://medium.com/@konstankino/rabbitmq-for-inter-process-communications-7a2e3ed7ac43?source=rss-1ca758931754------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a2e3ed7ac43</guid>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[interprocess]]></category>
            <category><![CDATA[rabbitmq]]></category>
            <category><![CDATA[ipc]]></category>
            <dc:creator><![CDATA[Bogdan Kulbida]]></dc:creator>
            <pubDate>Mon, 18 Feb 2019 23:50:18 GMT</pubDate>
            <atom:updated>2019-02-18T23:50:18.677Z</atom:updated>
            <content:encoded><![CDATA[<h3>RabbitMQ for Inter-Process Communications</h3><p>Often, the solution to some very specific issue we have involves the use of scripts. This can be one or a few scripts organized with a particular structure and a specific design. Most likely you will need to have an intercommunication mechanism for your scripts to work. We call it Inter-Process Communication or IPC for short. In general, it’s common for applications to be implemented as a combination of particular components working together by sending and intercepting messages since it allows components to be independently changed without amending other components, as well as decoupling logic. As a result, application design is made more coherent and it becomes much easier to test individual components since they are independent from other components and its dependencies can be relatively easy stubbed.</p><p>Depending on the particular IPC implementation, the intercommunication mechanism can be organized in quite a few ways: files, channels (or pipes), sockets, remote procedure calls (RPCs), memory separation, etc. Each way has its own pros and cons. For instance, when we use a channel, the script must “hold” a connection all the time to make it possible to send data. RPC, on the other hand, is appropriate only when each script in a chain of calls gets executed sequentially, so that a result from the previous call is passed to the input for the next one. In fact, most of the implementations for any of these methods can vary based on operating system. The RPC method is probably hard to adapt to asynchronous intercommunication. In this case, the simplest way to enable communication would be to use files or a database as a temporary store for messages. But the most reliable way is to use Message Brokers or Message Queues.</p><p>The most popular services that provide Messages Queues are AWS SQS, Microsoft Azure Service Bus, IBM MQ, Apache Kafka, RabbitMQ, and others. The most interesting services for us are AmazonMQ and RabbitMQ. These are two very similar tools: AmazonMQ, a managed service provided by the AWS, and RabbitMQ, open source software that can be installed on your own server.</p><p>RabbitMQ is probably the most widely deployed Message Broker, it is based on the Advanced Message Queuing Protocol (AMQP) standard, and as we have said, it is open source. In short, RabbitMQ is a powerful and flexible Message Broker despite its compact design.</p><h3>RabbitMQ: basic usage</h3><p>We are not going to talk about RabbitMQ installation since you can find a lot of good resources online. Once you have your RabbitMQ up and running we can install pika library to easily work with the message broker. Installation is as simple as running the following command:</p><pre>pip install pika</pre><p>Since we will be working with messages in the queue we will need to have a messages producer that will fill in our queue. Here is the simple code to do that:</p><pre>producer.py</pre><pre>import pika<br>from datetime import datetime</pre><pre>def main():<br>    # Creating connection for RabbitMQ<br>    connection = pika.BlockingConnection(pika.ConnectionParameters(host=&#39;localhost&#39;, port=5672))<br>    <br>    # Getting channel descriptor<br>    channel = connection.channel()</pre><pre>    # Declare new queue if it doesn&#39;t exist<br>    channel.queue_declare(queue=&#39;test_queue&#39;)</pre><pre>    # Create new message with timestamp<br>    data = &quot;Hi, consumer! [{}]&quot;.format(datetime.strftime(datetime.now(), &#39;%Y/%m/%d %H:%M:%S&#39;))</pre><pre>    # Publish message in queue<br>    channel.basic_publish(exchange=&#39;&#39;,<br>                          routing_key=&#39;test_queue&#39;,<br>                          body=data)<br>    # Close connection<br>    connection.close()<br></pre><pre>if __name__ == &#39;__main__&#39;:<br>    main()</pre><p>To write to the queue we will need to get a channel descriptor then initialize the queue and then call the method basic_publish. Once this is done, close the connection.</p><p>Here is a simple script that will read from the queue:</p><pre>producer.py</pre><pre>import pika<br>from datetime import datetime</pre><pre>def main():<br>    # Creating connection for RabbitMQ<br>    connection = pika.BlockingConnection(pika.ConnectionParameters(host=&#39;localhost&#39;, port=5672))<br>    <br>    # Getting channel descriptor<br>    channel = connection.channel()</pre><pre>    # Declare new queue if it doesn&#39;t exist<br>    channel.queue_declare(queue=&#39;test_queue&#39;)</pre><pre>    # Create new message with timestamp<br>    data = &quot;Hi, consumer! [{}]&quot;.format(datetime.strftime(datetime.now(), &#39;%Y/%m/%d %H:%M:%S&#39;))</pre><pre>    # Publish message in queue<br>    channel.basic_publish(exchange=&#39;&#39;,<br>                          routing_key=&#39;test_queue&#39;,<br>                          body=data)<br>    # Close connection<br>    connection.close()<br></pre><pre>if __name__ == &#39;__main__&#39;:<br>    main()</pre><p>We run a similar set of basic commands in the beginning. Please note that despite the fact that the Consumer reads from the queue, we initialize the queue just in case Consumer will be executed earlier. This allow us to avoid issues in case the Producer will try to connect to a queue that does not exist yet.</p><p>To read from the queue we use the method basic_get which provides direct access to the queue. The no_ask flag instructs our library to delete the message from the queue without waiting for confirmation. In our simple example it is not as important, but please keep in mind that for your production grade scripts and make them robust, you may need to additionally manage your messages in case there is an error, so to say, handle gracefully. In other cases, you may lose your message without acknowledgment. Be sure to handle this condition as well.</p><p>Here is an example reading from the queue with confirmation:</p><pre># Start fetching from queue<br>while True:<br>        method_frame, header_frame, body = channel.basic_get(queue=&#39;test_queue&#39;, no_ack=False)<br>        if body:<br>            print(body.decode(&quot;utf-8&quot;))<br>            channel.basic_ack(method_frame.delivery_tag)<br>        else:<br>            break</pre><p>In the example above, if the confirmation after message processing is left intact the message will stay in the queue and block all other messages from been processed and you will end up with a hanging script.</p><p>The other way to read from the queue is to use method basic_consume which listens to a queue and in case it receives a new message it will call the callback method:</p><pre>def callback(channel, method, properties, body):<br>    print(body.decode(&quot;utf-8&quot;))</pre><pre>channel.basic_consume(callback, queue=&#39;test_queue&#39;)</pre><pre>channel.start_consuming()</pre><p>The main downside of using this method is that it will be running and waiting for new messages while manually stopped. This approach will not work should you have a function that must return the proper status code upon completion.</p><h3>Processing “dead” messages</h3><p>Sometimes you may face a situation where you have messages in the queue that cannot be processed. For instance, you may get an error for message processing and would like to retry it later. Sometimes those messages can block your main queue from processing other messages. That can lead to data inconsistency or queue overflow and can lead to message loss and data integrity issues.</p><p>FIFO principle allows us to easily and efficiently move messages in the queue which may be not as transparent to implement or to think about.</p><p>Here are a few options to solve such an issue:</p><ol><li>If the message resides in the queue and is poorly formed with an error in its structure, it can be simply ignored with a request to resend a message after reading it. Simply remove it by using a method basic_ack which stands for basic acknowledgement:</li></ol><pre>method = channel.basic_get(queue=&#39;test&#39;, no_ack=False)<br>channel.basic_ack(method.delivery_tag)</pre><p>Or, if you use method basic_nack with the required flag set to False:</p><pre>method = channel.basic_get(queue=&#39;test&#39;, no_ack=False)<br>channel.basic_nack(method.delivery_tag, requeue=False)</pre><p>Here is a catch. Before RabbitMQ version 2.7, the basic_nack method usage with flag required set to True would put a message in the end of the queue, which would solve our issue. However, in the newer versions, RabbitMQ persists messages in the same order as they were added to the queue.</p><ol><li>If the message cannot be processed, you may delay its processing and retry later. The best practice would be to use “Dead Letter Exchanges”. The basic idea is to temporarily put problematic, unconfirmed messages (marked with a method basic_nack or basic_reject) into a separate queue, so to say temporary storage, and once you processed all messages, put them back into the main queue and retry processing. Here is an example:</li></ol><pre>...<br>channel.exchange_declare(exchange=&#39;dlx&#39;, exchange_type=&#39;direct&#39;)<br>channel.queue_declare(queue=&#39;rejected&#39;)<br>channel.queue_declare(queue=&#39;main&#39;, arguments={<br>            &#39;x-dead-letter-exchange&#39;: &#39;dlx&#39;,<br>        })<br>channel.queue_bind(exchange=&#39;dlx&#39;, routing_key=&#39;main&#39;, queue=&#39;rejected&#39;)<br>...</pre><pre>method = channel.basic_get(queue=&#39;test&#39;, no_ack=False)<br>if random.random() &lt; 0.5:<br>    channel.basic_nack(method.delivery_tag, requeue=False)<br>else:<br>    channel.basic_ack(method.delivery_tag)<br>...<br>rejected_cnt = channel.queue_declare(queue=&#39;rejected&#39;, passive=True).method.message_count</pre><pre>if rejected_cnt:<br>    for _ in range(rejected_cnt):<br>             method, header, body = channel.basic_get(queue=&#39;rejected&#39;, no_ack=False)<br>             channel.basic_publish(exchange=&#39;&#39;, routing_key=&#39;main&#39;, body=body)<br>             channel.basic_ack(method.delivery_tag)</pre><h3>Data Consistency and Data Integrity in RabbitMQ</h3><p>Another important issue that you as a developer may face is data integrity. Most likely in the real world your scripts will be running on slow and unreliable connections, so interruptions will happen all the time and sometimes our servers go down unpredictably.</p><p>By default, RabbitMQ will not persist messages to the underlying file system and will use in-memory storage, unless you explicitly set it.</p><p>According to the best practices, you should initialize your queues with the durable flag set to True:</p><pre>channel.queue_declare(queue=&#39;queue&#39;, durable=True)</pre><p>Also, make sure you send your messages with delivery mode set to 2, which represents durable mode of message transmittance:</p><pre>channel.basic_publish(exchange=&#39;&#39;, routing_key=self.queue_name, body=data, properties=pika.BasicProperties(<br>                         delivery_mode=2  # persistent mode<br>                      ))</pre><p>This will write your messages to file system and will work reliably well in case of interruptions. Keep in mind that this change may impact your system performance.</p><h3>Conclusion</h3><p>RabbitMQ is quite an easy and handy tool to work with the queues and transmit messages between systems in order to decouple logical pieces of your platform.</p><p>We showed some basic functionality and explained basic workflow to write to the queue, read from the queue, and process messages. Also, we showed some best practices for using RabbitMQ to make your system robust and predictable. At <a href="https://konstankino.com/">Konstankino</a> we utilize RabbitMQ for interprocess communications to make complex systems simpler and easier to work with. Also, this method allows us to scale our creations better, so our customers can be prepared to handle an increasing number of users.</p><p>Source: <a href="https://blog.konstankino.com/post/rabbitmq-explained/">https://blog.konstankino.com/post/rabbitmq-explained/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a2e3ed7ac43" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>