<?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 Vijay Dharap on Medium]]></title>
        <description><![CDATA[Stories by Vijay Dharap on Medium]]></description>
        <link>https://medium.com/@dharapvj?source=rss-71ef7482620------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rYLRdSqI0T71PmfutA3x_g.jpeg</url>
            <title>Stories by Vijay Dharap on Medium</title>
            <link>https://medium.com/@dharapvj?source=rss-71ef7482620------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 06:55:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dharapvj/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[Dear Mom (aka Infosys), I seek your blessings!]]></title>
            <link>https://dharapvj.medium.com/dear-mom-aka-infosys-i-seek-your-blessings-1375504e6380?source=rss-71ef7482620------2</link>
            <guid isPermaLink="false">https://medium.com/p/1375504e6380</guid>
            <category><![CDATA[last-days]]></category>
            <category><![CDATA[emotional]]></category>
            <category><![CDATA[gratitude]]></category>
            <category><![CDATA[infosys]]></category>
            <dc:creator><![CDATA[Vijay Dharap]]></dc:creator>
            <pubDate>Fri, 26 Feb 2021 03:25:31 GMT</pubDate>
            <atom:updated>2021-02-26T07:52:23.000Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PFr2CtXUDD4QfoN4MZpQQw.jpeg" /><figcaption><strong>Infosys Bangalore DC!</strong> Image by <a href="https://www.flickr.com/photos/ashwinkumar/4910685163/in/photolist-8tWxBz-8tZAHy-8tWwsH-8tWq6P-8tZDg3-8tZz8S-85XmJU-8tZtid-8tWyrv-8tWw7X-8tWoWg-8tZvL1-8tWuwZ-8tWx4c-8tZtMy-8tZzuU-8tZuC5-8tWuJD-8tWr4V-cEu6Cq-cEtRzy-cEtN7J-ifd1n-hp13A-fM9vB-PntuJV-4DN81x-7zC6ai-7zC75p-7zC6AT-5Xh5E3-oyaVVt-5XcQHz-4jpuYu-9t1TyF-7NYQjS-sWJZi-8ijLA-4atFB1-PADH8-bLXoc2-afnrQb-wtLzp-7qJTv-4ew6yp-cucTt-5XcQPn-ujQ2E-89FDYz-zsc6Q">Ashwin Kumar</a></figcaption></figure><p>As I stand on the cusp of 2 major life events — I am turning 40 and I am leaving Infosys after a long stint of 18 years — I cannot remove the tremendous fear (and excitement) that is present in my gut right now!</p><p>I remember myself being an unconcerned and irresponsible college student.. one who had no campus placement and no clarity on what I want do in my life as a Electronics Engineer. From there to becoming a successful technical architect who has overseen many large projects, its been a journey beyond my wildest dreams! One which was possible only due to Infosys — which pretty much stood like a Mom behind me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tPLBGsnfeP9Yupk0kZOKMw.jpeg" /><figcaption><strong>Pune DC Iconic Droplet!</strong> Image by <a href="https://www.flickr.com/photos/evidences/4035373556/in/photolist-932t2P-Exa4a-Exa4k-EjD8Y-e1GFBF-79Akth-jjGJKT-79AkY9-79AmxC-79wu2p-79Aknf-79wsPP-jjGMiD-jjJhGe-79AjDq-jjM4Ku-4z1DZx-79Am4u-79Ama3-79wthg-4z1DB6-sRHaw-79wrJk-4z1DwR-8QBb9e-4z1Dkp-9352fm-79AkQ1-79And5-BaGwqh-79wuxt-79An83-79Akij">evidences</a></figcaption></figure><p>I am grateful to Infosys for:</p><ul><li>Providing me with development projects from Get Go,</li><li>Entrusting me with writing logic for the most challenging button in my life (AKA Calculate Quote),</li><li>Giving me a super-fast path to USA and a fulfilling 6 years of stay in US,</li><li>Providing opportunity to create financial corpus for good life in India,</li><li>Supporting me to transition back from US to India,</li><li>Encouraging to try different technologies,</li><li>Having welcoming seniors — who trusted my guts when I proposed new directions and when I opposed established processes / directions,</li><li>Providing a solid process oriented organization — which made life easy for me be it for getting visas or travel tickets or overseas calling,</li><li>Most badass sprawling campuses — mesmerizing architecture, greenery everywhere and tons of food courts to eat your heart out :D</li><li>And most of all —always cheering for me loudly from sidelines — by giving me fast tracked promotions and rewards and recognition throughout my career.</li></ul><p>When Infy has done all this, why part ways now!! I am pretty sure that I am acting as a typical rebellion teenager (in my 18th year, you see) — who seems to recognize everything his parents have done for him, <em>and yet</em>, seeks to break free and explore new world outside the comfortable shell of his home!</p><p>There is no dearth of gems at every level from CEO to facilities staff in Infosys! The biggest lighthouses for me in my Infosys journey would be <a href="https://www.linkedin.com/in/vijith-v/"><strong>Vijith</strong></a><strong> and </strong><a href="https://www.linkedin.com/in/ruchir-budhwar-0b71883/"><strong>Ruchir</strong></a><strong> </strong>—both of them are my mentors whom I will respect for life! The way they believed in me tough situations and challenged me to become even better was very very encouraging. A HUGE THANK YOU TO YOU FOLKS!</p><p>One reason I believe I stayed in Infosys was because there are so many other core techie people. I had opportunity to work closely with so many of them! <strong>Vijith, Shashi, Kiran G, Avinash, Deb, Ajit, Ravi Anupindi, Abhay Joshi, K.K., Amit Deshpande, Kailas Kore, Ek, Vivek Chaturvedi, Shivraj, Vineesh, Gouri, Sanjay, Ravi 27, Naveen36, Atul, Gaurav Rajderkar, Archana Sawant, Vikas Gujjar, Viral, JSrini, Jitendra Jain, DeepakPN, Samir Joshi </strong>and countless others! I mean when you know we have so many experts at just ping’s distance, your confidence to try new things go really next level, isn’t it? Some of these folks have already chosen different path from Infosys but I must say that I stayed on because all these stars were there for me helping me, guiding me and just achieving awesome technology feats by themselves too! I am sure I have missed on taking few names here… and I am sorry for the inadvertent omission.</p><p>Infosys was a wonderland to enter due to awesome friends made during training—<strong>DJ, Sandy, Chait, Ruchi, Swaroop, Soumya, Sumant </strong>— Wow, I can still remember all the fun we had in those 4 months of worry-free life! Ab kaun dega woh din vapis! 😢</p><p>In my initial years, I had so many great mentors to learn from.. <strong>Venkat, Prabhu, Priyan, Vijith, Ragi, Karthikeya Bisht, Ruchir</strong>. Everyday was learning and growing. Thank you all for your support!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FpiFpbJQLkumkgADDs4sKA.jpeg" /><figcaption>Nostalgic with all the trips from FH</figcaption></figure><p>Shifting to Farmington Hills was yet another highly exciting thing in life and all the folks from FH have become my friends-for-life! <strong>Jeet, Andy, Abhi, Prasi, Saif, Zayeem, Vikram, Manasa, Vivek, Vinay, Sonal, Vijith, and of course Prachi</strong>… You are the best! Remembering all the trips we took and all the “<em>miles we have cut</em>” and Thank you for “<em>not messing with my life</em>” 😆</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0LPWBtNIfamFVWDHz80W_Q.jpeg" /></figure><p>After moving back from US, I landed in a very cheerful team, many of whom I am in touch. <strong>Hitesh, Abhigyan, Javed, Priyanka, Amruta, Prakhar, Anoop, Prashant, Abhay, Vinay Kale </strong>to name a few.. Had a loads of fun in the corner of building 8 — didn’t we? I still remember Hitesh lifting entire monitor to show issue across the cubicles :D</p><p>While working at offshore, I came across few opportunities to propose and make changes — which helped entire organization like Defining Open Source contribution policy for Infosys via OSSmosis program, Nexus setup, Gitlab setup, Internet whitelisting for maven and npm etc…</p><h3></h3><p>In his keynote @vsikka encourages infoscions to contribute more to #opensource #OSSmosis pic.twitter.com/TRJ3bolIKH</p><p>I learnt a lot about how org works and also learnt to have patience. It was not possible without continuous support from bigwigs and stalwarts of Infosys like <strong>Naresh Choudhuri, Ganesh Subramanian, Ajit, Deepak PN, Lakshmanan, </strong>and others. Thank you showing faith in my abilities as I wore a pirate hat and challenged status quo of the organization in these instances!</p><p>Another such cross-org initiative which is always special in my heart is Technotsav (errrm Techzooka) and the Hacktoberfest. <strong>Viral, Deepak, Ambadas, Sachin </strong>and rest of the core team has been virtually unchanged for last 11 years. I always get amazed at the amount of energy they pour into organizing it and I have tried to do my small bit in helping them wherever possible! I wish them and entire Techzooka very best!! And, oh yes, always looking forward to joining the team, as a “<em>external speaker</em>” now! 😃</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zl0AiLkrxQ2jwH1-oYHgbA.jpeg" /><figcaption>Account Onsite team</figcaption></figure><p>In last few years, Ajit asked me to go under the wings of <strong>Vivek Goel</strong> and, man, what a genuine personality Vivek has! I am in continued awe of his gentleness yet a very thorough nature. Always analyzing things with a critical eye and always trying to find ways to make the best of the situations. Definitely so many qualities to learn there! Under Vivek and Vijith, we undertook a mammoth program. Met so many great people there starting from <strong>Ajay Neti, Pranob, Anoop, Ambarish, Ravi, Khalid, Kiran G, Nayan, Jyothi, Anuj, Bhanu, Sarawathi, Atul, Muthu, Naveen36, Naveen62, Saptarshi, Satish, Himanshu, Varun, Anand, Jason, Archana, Jainesh, Suji, </strong>and others! Yes, I was kind of daemon to many of the developers during initial years of the program.. but I did what I felt was necessary to get delivery done and get people shaped up. and I hope I did good on both fronts!</p><p>During the entire journey, I had great customers with whom I got to interact personally and professionally! <strong>Harish M, Greg B, Ajay S</strong>, <strong>Tina V, Vince A, Rich B, Paul W</strong>, <strong>Michael W, Tim K, Leif G, Kiran K, Eric and Gerdi, Andre K, Christian H</strong>.. Thank you for entrusting me with challenging jobs!</p><p><strong>Last but not the least — my family!! </strong>Many of my contributions in Infosys came at cost to my family time. They supported me throughout the journey and their commitment to myself and Brand Infosys was key for my long journey here!</p><h3>All in all — its simply impossible to repay the debt of network that is known as Infosys. So I humbly request the entire Infosys team to please accept my simple “Thank you” for providing me a solid support net!</h3><h3>And I seek your blessings for next endeavor!</h3><p>As I am leaving the organization, I am really at a huge loss in terms of relationships.. So I urge you to connect with me digitally everywhere with handle <strong>dharapvj.</strong> Be it <a href="https://www.linkedin.com/in/dharapvj/">linkedin</a>, <a href="https://twitter.com/dharapvj/">Twitter</a>, <a href="https://github.com/dharapvj">github</a>, gmail, <a href="https://www.facebook.com/dharapvj">facebook</a>, . I can never forget Infosys and each and every one of you! Will always be eager to meet / chat / call with you to discuss something exciting and join hands together again!</p><h4>Until then — Keep the Infosys flag flying!</h4><p><strong>PS:</strong> A lot of us have separate personal whatsapp numbers (beyond Infosys numbers) and I might not have them… please ping me on <a href="https://www.facebook.com/dharapvj">facebook</a> your numbers so that we can keep in touch in future!</p><p><strong>PPS: </strong>I am venturing into slightly different (and risky) territory of self managed consultancy and I am scared to be honest! I am seeking your help here in cementing my branding. I really want my future customers to see my worth!</p><h4>If we worked together and you enjoyed working with me.. can I ask you to spend 5 minutes and <a href="https://www.linkedin.com/in/dharapvj/detail/recommendation/write/">write me a recommendation</a>? Consider it as my final pay day for my services to you. Thanks a lot in advance!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1375504e6380" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Changing the behavior of a 3rd party Angular Component]]></title>
            <link>https://medium.com/angular-in-depth/changing-the-behavior-of-a-3rd-party-angular-component-91f84fb9af28?source=rss-71ef7482620------2</link>
            <guid isPermaLink="false">https://medium.com/p/91f84fb9af28</guid>
            <category><![CDATA[ionic]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Vijay Dharap]]></dc:creator>
            <pubDate>Thu, 16 Aug 2018 20:48:29 GMT</pubDate>
            <atom:updated>2020-04-30T00:09:21.123Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/743/0*2GwfC5AKvXbTNRdP.png" /></figure><blockquote><a href="https://medium.com/angular-in-depth"><strong><em>AngularInDepth</em></strong></a><strong><em> is moving away from Medium. More recent articles are hosted on the new platform </em></strong><a href="https://indepth.dev/angular/"><strong><em>inDepth.dev</em></strong></a><strong><em>. Thanks for being part of indepth movement!</em></strong></blockquote><p>As I use more and more Angular libraries, my need for tweaking the out-of-the-box behavior of the library components has also been growing. Today, I took on the challenge of doing one such morphing where I attempted to change the behavior of a 3rd party Angular component to suit my needs.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F151917852%3Fapp_id%3D122963&amp;dntp=1&amp;url=https%3A%2F%2Fvimeo.com%2F151917852&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F551775785_640.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a7c2b9609a8b0b676997bf5ca1bded5/href">https://medium.com/media/2a7c2b9609a8b0b676997bf5ca1bded5/href</a></iframe><h3>The Need</h3><p>Ionic 3 (which is a highly popular Mobile Hybrid Application development framework based on Angular) has an ion-select component which is largely based on a combination of ion-radio options presented within an alert dialog box with two buttons (<strong>OK</strong> and <strong>Cancel</strong>). The user must select a radio button to choose an option and then click the OK button to close the Alert Dialog to see the selection reflected in the <strong>Selectbox</strong>.</p><p>Users complained that in a Native Android application the selection interface works without users needing to click on the OK button. They can simply select an appropriate Radio button and the dialog closes automatically for them.</p><p>There seemed to be no direct and simple way to get such a UI created via the various options available with the ion-select component. By the way: Ionic components are typically highly customizable and user friendly. But, I stumbled upon this specific feature that just happened to be lacking in this component.</p><p>Thus started the need to hack together a solution which:</p><ul><li>fulfills the need.</li><li>is elegant enough to be maintainable.</li><li>is largely black-boxed and hides the internal intricacies.</li></ul><h3>TL;DR</h3><p>For the busy readers, here is summary of what you will learn.</p><p>There are a few things you should know and work around:</p><ol><li>Angular component inheritance does not inherit the @metadata decorators. So customizing Angular components by just overriding the existing methods in the component is not quite straightforward.</li><li>In order to customize a component’s behavior you must get access to the instance of the component at run time. In your directive you can use the @Host annotation which was introduced in Angular 4.3.3.</li><li>Once you have access to the instance, you can use plain old JavaScript tricks like overriding the existing prototype method and adding custom code before or after or around execution of any existing public method which is invoked by the component itself.</li><li>Placement of your custom directive is crucial.</li></ol><p>Please read on to get full story and also links to an example directive I created to customize Ionic’s <a href="https://ionicframework.com/docs/components/#select">ion-select</a> component.</p><h3>The path through the obstacles to a solution</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XEPc30bcEXxUtedA" /><figcaption>Photo by <a href="https://unsplash.com/@savvas_kalimeris?utm_source=medium&amp;utm_medium=referral">Savvas Kalimeris</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Initially, as an optimist, I was sure that I can simply copy and paste the ion-select source-code and create my own component and just be done with it in 20 minutes or so.</p><p>But, developer-optimism never plays out, does it?</p><p>After copy pasting <a href="https://github.com/ionic-team/ionic/blob/v3.9.2/src/components/select/select.ts">select.ts</a> into my codebase and adjusting all the import statements from that file, my initial enthusiasm waned. I quickly realized that all the import statements were not playing out well. Most likely, it was because Ionic does not export the original source .ts files, but only the compiled commonjs modules of the Ionic codebase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jN3bWp5DYUw9Rya_RF8EOw.jpeg" /><figcaption>Original image from <a href="https://www.flickr.com/photos/122662432@N04/13740073235">Flickr</a></figcaption></figure><p>After tiring myself like this guy in the photo… I buckled myself up again.</p><p>An idea came to mind that maybe I could keep the existing ion-select element and somehow control its behavior by “extending” or “transforming” it.</p><p>I already had my share of Extending-Angular-component experiences and I knew that the @metadata decorator and other such things don’t inherit well in Angular; at least as of yet (my current exposure is up to Angular5). So, I decided that I am going to try and transform the behavior of the existing ion-select Angular component by adding a custom directive to it.</p><h3>Accessing the “parent” component in your custom directive</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*g1zDlO_OBl8twz4ixZZPMQ.jpeg" /><figcaption>The first right step toward solution</figcaption></figure><p>Of course, accessing the parent ion-select component instance was a piece cake. 😒</p><p>I tried and tried to figure out how to get access to the host component in the constructor or any other method of my directive. I could not figure it out for a good half a day. Finally, after searching around and learning about InjectionToken etc, I finally came across a fantastic GitHub issue and <a href="https://github.com/angular/angular/issues/8277#issuecomment-323678013">a comment</a> which gave me hope. With Angular 4.3.3+, you get access to the parent directive/component via the @Host decorator.</p><p>So now we can do something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3912c020e5c6245f8848b47d078e0eb0/href">https://medium.com/media/3912c020e5c6245f8848b47d078e0eb0/href</a></iframe><p>And that’s all there is to it! Using this approach, we can now completely change the behavior of any 3rd party component to suit our needs.</p><p>Take a look at the screenshot below to see the visible difference that I was able to bring to ion-select:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*S0wy2xtUawjYemSjvUEL_A.gif" /></figure><p>I mean, imagine the possibilities! If the &lt;ion-button&gt; directive was supposed to allow the user to click on the button to perform the action, you can now modify the ion-button directive behavior to make the button run away from mouse pointer so that user can never click on the button. 😆 Something like this:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fjsvgoncalves%2Fembed%2Fpreview%2FAnlcv%3Fheight%3D600%26slug-hash%3DAnlcv%26default-tabs%3Djs%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2Fjsvgoncalves%2Fpen%2FAnlcv&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F46534.Anlcv.small.3e3494781411464f5358493c73c6b8b9.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/af151bea7caac8266dabe3665b9d37ee/href">https://medium.com/media/af151bea7caac8266dabe3665b9d37ee/href</a></iframe><p>OK, that was fun. But, I hope you can see the power of the @Host decorator. It allows you change the behavior of existing Angular components including the 3rd party components in a meaningful way.</p><p>The small library that I developed to change behavior of ion-select can be seen on <a href="https://github.com/dharapvj/ionic-radio-select">GitHub</a> and can be consumed via <a href="https://www.npmjs.com/package/ionic-radio-select">npm</a> in your ionic application. <br>npm i ionic-radio-select</p><p>If you liked this article, don’t forget to clap ( a lot of times 😅) and star my library on GitHub as well on <a href="https://www.npmjs.com/package/ionic-radio-select">npmjs.com</a>!</p><p>I’m looking forward to your reactions!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91f84fb9af28" width="1" height="1" alt=""><hr><p><a href="https://medium.com/angular-in-depth/changing-the-behavior-of-a-3rd-party-angular-component-91f84fb9af28">Changing the behavior of a 3rd party Angular Component</a> was originally published in <a href="https://medium.com/angular-in-depth">Angular In Depth</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enterprise ready Angular-CLI seed]]></title>
            <link>https://medium.com/hackernoon/enterprise-ready-angular-cli-seed-618b35a66c1e?source=rss-71ef7482620------2</link>
            <guid isPermaLink="false">https://medium.com/p/618b35a66c1e</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular-cli]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[angular-5]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Vijay Dharap]]></dc:creator>
            <pubDate>Wed, 24 Jan 2018 20:15:45 GMT</pubDate>
            <atom:updated>2018-01-25T05:01:23.240Z</atom:updated>
            <content:encoded><![CDATA[<p>Over the last year, I have helped my team develop and deliver many Angular applications into production. This included Desktop web, RWD, Hybrid, etc. Over this period, I started feeling the need to have a ready starter kit for the teams — which include more enterprisy features. Angular CLI is a great starter kit to get Angular app setup. It gives you the foundation piece but that’s pretty much where it leaves ya! So I decided to build a enterprise ready seed app for Angular using Angular-CLI as foundation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8c333d_YNEHG4q3UDb1wTA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/5fNmWej4tAA?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Helloquence</a> on <a href="https://unsplash.com/search/photos/enterprise?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Goals</h3><p>Every project has possibility to see success, if it had some good goals defined. Goals for this project would be:</p><ul><li>Add few libraries / custom implementations to provide for enterprise focused features— Busy indicators, Authorization check in templates and functions (along with route-guards, of course)</li><li>Provide lazy loading of routes by default, including home page and thereby reduce the bundle size of main bundle to absolute minimum.</li><li>Keep bundle size in check, after every iterations. Discard any library that proves to add too much deadweight.</li><li>Add notifications — in page as well as floating</li><li>Add form validation sample</li><li>Slim scrollbars</li><li>Conditional Logging (disable certain logs in PROD automatically)</li><li>Animations</li><li>more…</li><li>Make it open-source under MIT license!</li></ul><p>I am planning to write series of best practices (at a code level) here based on how this seed shapes up.</p><h3>TL;DR; Where is my code?</h3><p><a href="https://github.com/Infosys/enterprise-angular-seed">Here</a> is the code for Angular CLI based Enterprise App Seed which I developed! Remember to 🌟️ the project on github for bookmarking it!</p><p>But I do urge you to read through this entire piece to understand various code pieces of the seed and why they exist.</p><p>This code implements many best practices and hence I have decided to split this post into multiple posts with 3–4 best practices at a time.</p><h3>Architecturally Significant Best Practices — part I</h3><h4>1. Defaulting to SCSS</h4><p>SCSS provide far more advantages than regular CSS e.g. variables support (helpful in global changes, theming etc), compact style definition by adapting tree structure, mixins, code generation, etc. Almost all mature styling libraries and component libraries use SCSS as their style definition engine. Any enterprise app should definitely use SCSS.</p><p>Angular CLI new command by default generates application with css as styling option. While this is OK for some naive implementations, any application that uses bootstrap or any other css system — should know that they are adding way too much of CSS by adding entire distribution css file. Bootstrap4 is OOTB sass enabled. Bootstrap v3 has bootstrap-sass npm package which is fully supported.</p><p>So — its important that our application supports SCSS and you include only the required parts of any CSS library using scss.</p><p>If you are about run new then — please add additional option --style scss. That’s it! Now newly generated code will default to SCSS. Any new components you will generate will also have .scss as default extension for styles. If you have already generated the app, you can still make change in .angular-cli.json file in defaults section for future component generations.</p><p><strong>Pro Tip</strong>: While you are doing this — you might also want to add --skip-test and--skip-install options if you do not intend to write tests and if you don’t want Angular CLI to start running the install (using Yarn if you have it installed). --routing option is also highly recommended for enterprise apps.</p><h4>2. CSS reset (normalize)</h4><p>Its very important to use a good style reset so that most basic rendering of html components appears identical in all browsers. If you use bootstrap / Zurb foundation — they have resets built into it. If you are starting from scratch though, a reset is a MUST. You can go for one of the <a href="https://github.com/necolas/normalize.css">normalize.css</a> + <a href="https://github.com/jonathantneal/sanitize.css">sanitize.css</a> / <a href="https://meyerweb.com/eric/tools/css/reset/reset.css">meyerweb reset</a> / <a href="https://github.com/mirego/simple-css-reset">simple css reset</a> / <a href="https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css">html5 boilerplate reset</a>.</p><p>For this seed — I have <a href="https://github.com/Infosys/enterprise-angular-seed/blob/master/src/styles.scss#L2-L3">used</a> normalize.css + sanitize.css option. While normalize is a great reset. It does not provide box-sizing: border-box and other such defaults. These are added by sanitize.css — which is written by co-author of normalize.css.</p><p>If you are planning to use bootstrap — you can remove this combo are those things are taken care of by bootstrap.</p><h4>3. Ready-made Authorization directives</h4><p>One more key ask from all enterprise applications is to have authorization support. After sifting through multiple libraries, I narrowed down my selection to <a href="https://github.com/AlexKhymenko/ngx-permissions">ngx-permissions</a>.</p><ul><li>ngx-permissions provide 3 directives to quickly describe the authorization requirements in templates.</li><li>The directives are AOT ready.</li><li>It also provides comprehensive routeguard and redirection to another route when user is not authorized for that route.</li><li>Both canActivate as well as canLoad guards are supported.. so you can exclude modules from getting downloaded when the user does not have right permissions.</li></ul><p><strong>How to include this in your code?</strong></p><p><a href="https://github.com/Infosys/enterprise-angular-seed/blob/master/package.json">package.json </a>— (yarn add ngx-permissions) <br><a href="https://github.com/Infosys/enterprise-angular-seed/blob/9eed90dd0fc7644ae9ab4121c81bcb4c34517666/src/app/app.module.ts#L36">src/app/app.module.ts</a> — Add NgxPermissionsModule.forRoot() in imports. IMPORTANT: This must be in your applications main module (often app.module in Angular-CLI generated projects)<br><a href="https://github.com/Infosys/enterprise-angular-seed/blob/9eed90dd0fc7644ae9ab4121c81bcb4c34517666/src/app/app.component.ts#L27-L38">src/app/app.component.ts</a> — retrieve set of permissions from backend service call / OAuth2 redirect headers, etc and push them ngx-permissions’ PermissionService and RoleService instances.<br><a href="https://github.com/Infosys/enterprise-angular-seed/blob/9eed90dd0fc7644ae9ab4121c81bcb4c34517666/src/app/home/components/home/home.component.html#L12-L23">src/app/&lt;yourcompoent&gt;/&lt;your comp.html&gt;</a> — add ngxPermisssions* directives. e.g.</p><pre>&lt;div *ngxPermissionsOnly=”[‘listExperts’]”&gt;<br>   &lt;div&gt;Viewable List of Experts here.. accessible to permission “listExperts”&lt;/div&gt;<br>&lt;/div&gt;</pre><h4>4. Using shared modules</h4><p>If you have not been creating modules in your Angular application; you should stop now and first <a href="https://johnpapa.net/introducing-angular-modules-feature-modules-2/">read</a> about <a href="https://medium.com/@cyrilletuzi/understanding-angular-modules-ngmodule-and-their-scopes-81e4ed6f7407">benefits</a> of doing so. One of the important reason being Lazy Loading of rest of the application. Other being re-usability.</p><p><a href="https://angular.io/docs/ts/latest/guide/ngmodule.html#!#shared-module">Shared modules</a> help providing commons services and components which can be re-used across multiple application modules. Any enterprise app — I can envision — to have at least one shared modules.</p><p>Take a look at <a href="https://github.com/Infosys/enterprise-angular-seed/blob/9eed90dd0fc7644ae9ab4121c81bcb4c34517666/src/app/appcommon/appcommon.module.ts">src/app/appcommon/appcommon.module.ts</a> for understand how to write common modules.. Especially, see the <a href="https://github.com/Infosys/enterprise-angular-seed/blob/9eed90dd0fc7644ae9ab4121c81bcb4c34517666/src/app/appcommon/appcommon.module.ts#L16">exports</a> property to understand how we make shared-module code accessible to rest of the world.</p><p>For the sake of content length, I would stop here. Next parts of this post would elaborate below items. The code on github already has the required implementation for many of these items:</p><ul><li>UX Improvement — Thin scrollbars</li><li>High productivity — PrimeNG Component Library</li><li>Using Animations in various parts of application</li><li>Dynamic log level setting to do effective debugging</li><li>Lazy-loading everything including the home page.</li><li>Common HTTP Headers using HTTP_INTERCEPTORS</li><li>Global Shared state using AppState</li><li>Keeping Track of your bundle size</li><li>Settle between NPM and Yarn (via yarn-or-die)</li><li>IE11 Support</li><li>json-server and freedom from backend integration to a certain extent</li><li>Adverse impacts of calling forRoot() call for various 3rd party modules in shared modules.</li><li>Why using Async pipes ( | async ) in templates is awesome</li><li>PageNotFoundComponent</li><li>LocalStorage / IndexedDB for persistent.</li></ul><p>You are welcome to contribute to the code via code-review, feature requests, PRs and other ways.</p><p>To ensure you get the rest of the posts — please follow me on Medium by clicking my “follow” button next to my name below this line.</p><h3>Connect</h3><p>As always, please clap, comment, follow on <a href="https://medium.com/@dharapvj">medium</a>, <a href="https://twitter.com/dharapvj">twitter</a> to keep in touch and have awesome technical conversations!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=618b35a66c1e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/enterprise-ready-angular-cli-seed-618b35a66c1e">Enterprise ready Angular-CLI seed</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Webpack Bundle Analysis — A necessary step for all React, Angular, Vue application developers!]]></title>
            <link>https://medium.com/hackernoon/webpack-bundle-analysis-a-necessary-step-for-all-react-angular-vue-application-developers-fe6564fa62ca?source=rss-71ef7482620------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe6564fa62ca</guid>
            <category><![CDATA[bundle-analysis]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[bundling]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Vijay Dharap]]></dc:creator>
            <pubDate>Mon, 08 Jan 2018 19:33:48 GMT</pubDate>
            <atom:updated>2018-01-08T19:33:48.949Z</atom:updated>
            <content:encoded><![CDATA[<h3>Webpack Bundle Analysis — A necessary step for all React, Angular, Vue application developers!</h3><p>If you are trying to create a modern performant web application.. then chances are high that you are using Webpack Directly or indirectly!</p><p>Are you using <a href="https://github.com/facebookincubator/create-react-app/">CRA (create-react-app)</a> for React? Are you using <a href="https://github.com/angular/angular-cli/">Angular-CLI</a> for starting your angular app? Are you using <a href="https://github.com/vuejs/vue-cli">Vue-cli</a> to initialize your Vue applications?</p><p>If your answers are YES to any of the question above — then you are using webpack in the background!</p><p>webpack follows its parsing logic and generates bundles. The process of bundling is very flexible to accommodate variety of js files and bundle formats like cjs, ES modules, amd, umd, etc. However due to this flexibility, however the side effects can be bundling more code on accident if you don’t know what module type you are shipping to webpack. <strong>This is why — we the users of webpack, should analyze and gain insights into what did really get into our bundles.</strong></p><p>We should question each module’s presence and its applicability, its presence in specific bundles and across bundles etc. But typically, a medium complexity angular application easily includes 1000–1500 modules so.. if one tries to look through the generated modules, that person is going to lose couple of days in his/her life!</p><p>Thankfully, webpack comes with its own --json option and <a href="https://webpack.github.io/analyse/">an Analyzer</a> to visualize that json yourself. There are couple of very <a href="https://chrisbateman.github.io/webpack-visualizer/">useful</a> <a href="https://github.com/th0r/webpack-bundle-analyzer">plugins</a> which also provide their own visualization which I find very useful in making sense of contents of my bundles! Today, I will be walking through one of my experience of applications bundle tuning!</p><p>So — when I was asked to help on performance of the application, I was told that it took 40 seconds for home page to become responsive! To me that was little too slow. And home page did not actually have a lot of content that it should take <em>that</em> long!</p><h3>Iteration 0</h3><p>So I started analysis. What follows is series of screenshots and fixes suggested..</p><p>I started off by creating a json file and loading it in <a href="http://chrisbateman.github.io/">Chris bateman’s visualizer</a>.</p><p>This was the report that I saw!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*ATck_WL05xl4cdzyk7quuw.png" /><figcaption>Iteration 0— AS-IS code analysis</figcaption></figure><p>Armed with this information, I could immediately saw my first opportunity to achieve better TTI. The 4.2MB bundle. I explained my team to <a href="https://alligator.io/angular/lazy-loading/">use LazyLoading technique</a> for routes and soon I was given a new code. I also checked network tab for the application to realize that the web-server was not making use of gzip <a href="https://httpd.apache.org/docs/2.4/mod/mod_deflate.html">content-encoding header</a>.. a very basic step for web-server configuration. I instructed my team to get this sorted out.</p><h3>Iteration 1</h3><p>The new chart was as below .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*ElXPEBtNEITa2zGiz7NzrA.png" /><figcaption>First improvement — 6 bundles instead of one. main bundle is now 1/3 of the original size!</figcaption></figure><p>Now I wanted to focus and understand what is inside the main bundle as well. While 1.8MB (non-gzip) from 4.2MB was a great improvement, I still felt 1.8MB is still quite a bit of code to get downloaded on first page. So I selected main bundle in the dropdown in the above screenshot and inspected what’s present in that bundle. Below is what I saw…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*qXYDxNHdR_mDUZw1c0u7jA.gif" /></figure><h4>My observations:</h4><ol><li>Overall 97% code was from node_modules (essentially libraries)</li><li>various modules from Angular took 55% of the same — which is about 1MB in size.</li><li>Moment.js locales folder occupied 150KB</li><li>Lodash was getting added in multiple modules and in each module was taking up 50–70KB.</li><li>D3 was imported via import * as d3 from &#39;d3&#39;; This meant that we were including entire D3.js library even though we were not using all the features.</li><li>16% of overall app (or 300KB) — which was shown under node_modules was actually application stylesheet which was part of main bundle. I was not sure if the stylesheet should be that large.</li></ol><p>So I decided to further investigation of Styles..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*FrGsVqeY27m67YaxVqgfFw.png" /></figure><p>Upon inspection, I realized that each of my stylesheet files are unusually large at 35kb+ each! Also I saw that we were including unrelated stylesheets in main bundle.</p><p>At this juncture, I cracked open the editor and started checking SCSS files. I immediately saw an incorrect scss import getting added on top of all SCSS files causing each SCSS file to be so large.</p><p>I confirmed this issue by checking other bundles too!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*gK3jHJhc-bSvbD1qFtTxeg.png" /><figcaption>Other bundles also were showing large file sizes for scss files.</figcaption></figure><p>I asked my team to first fix SCSS imports on priority as it was affecting all the bundles.</p><h3>Iteration 2</h3><p>The next iteration was quite better immediately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*3O6iO37uQ0LcGiSCMQ4WjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*8hgIfc-QhUcHPDXT-HwA3Q.png" /><figcaption>All the bundles now have 1–3% CSS code — which is somewhat to my expectation.</figcaption></figure><p>Now I asked my team to concentrate on removal of momentjs locales, lodash tree shaking, D3 treeshaking and Angular AOT compilation so that Angular compiler will not get included in the application codebase.</p><p>The new build was really satisfactory to me now!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*EpXrVBqfhncZbYdjvPgqqw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*RvCUW5LGf8gOQevzD3ElGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*_SsGdif7frCd8xr_CPRn9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*2xnQWyPBpVpP0GK3SJTzzA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*N37VOPcxhq2_gGwHoN2PXQ.png" /><figcaption>open each image to see specific improvements.</figcaption></figure><h4>Summary of configuration fixes to achieve above improvements</h4><ul><li>For Lodash — we just need to add lodash-webpack-plugin into webpack config.</li><li>For momentjs — we need to use context-replacement-plugin to only <a href="https://github.com/jmblog/how-to-optimize-momentjs-with-webpack">include specific moment locales</a> that we desire.</li><li>For D3 — we need to import specific imports from D3 (works for D3 v4+).</li><li>For AOT build — latest version of Angular-CLI ng build --prod is already AOT enabled.</li></ul><p>As a summary below is table that shows First page bundle size going down over iterations..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*qxEb3yjzjFN-dDPwIPsVIA.png" /><figcaption>By final iteration — first page download size came down by 90%!</figcaption></figure><h3>Main improvements</h3><p><strong>Iteration 1</strong> — SCSS imports fixed. GZip content encoding added in web-server</p><p><strong>Iteration 2</strong> — Momentjs, D3, Lodash fixes, AOT compilation</p><h3>More improvement ideas</h3><ul><li>Don’t use D3+C3/nvD3/Dimple combos, at least on your home page. At the time of writing, <a href="https://github.com/c3js/c3/blob/master/package.json#L41">C3</a> <a href="https://github.com/novus/nvd3/blob/master/package.json#L24">nvD3</a> do not make use D3 v4 and hence cannot make use of ES modules that D3 v4 employs. this means, you are easily adding about 150kb to your bundle via D3+C3/nvD3 combo. I would rather recommends <a href="https://gionkunz.github.io/chartist-js/">Chartist</a> — a really tiny (10kb) SVG based charting library (at least on home pages).</li><li>Similarly, we should really try to drop moment and use <a href="https://github.com/date-fns/date-fns/">date-fns</a> library.. Its a beautiful date operations library and provides ES modules so it saves on JS file size. Right now moment.js is clocking 51kb with no tree shaking possible.</li><li>Upgrade Angular-CLI v1.5 &amp; angular v5.0+ asap to utilize <a href="https://blog.angular.io/version-5-0-0-of-angular-now-available-37e414935ced">build optimizer</a> feature of Angular CLI to compress your bundles even more.</li><li>Upgrade to Webpack 4 (when available) to boost your tree shaking by <a href="https://twitter.com/TheLarkInn/status/938188174794223616">large</a> <a href="https://twitter.com/TheLarkInn/status/938198701738147841">margin</a>!</li></ul><h3>Summary:</h3><ul><li>Webpack is an awesome and super flexible bundling library. But one must pay attention to what kind of libraries are getting bundled via webpack.</li><li>This can have a large impact on application bundle sizes and thereby on your first page load and parse time.</li><li>There are multiple tools available to help you visualize the webpack’s json output and arrive at optimization strategies.</li></ul><h3>Connect</h3><p>Please clap, comment, follow on <a href="https://medium.com/@dharapvj">medium</a>, <a href="https://twitter.com/dharapvj">twitter</a> to keep in touch and have awesome technical conversations!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe6564fa62ca" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/webpack-bundle-analysis-a-necessary-step-for-all-react-angular-vue-application-developers-fe6564fa62ca">Webpack Bundle Analysis — A necessary step for all React, Angular, Vue application developers!</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Application Performance Fixes — Story #1]]></title>
            <link>https://medium.com/hackernoon/angular-application-performance-fixes-story-1-9bfa353d0fc4?source=rss-71ef7482620------2</link>
            <guid isPermaLink="false">https://medium.com/p/9bfa353d0fc4</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[angular-application]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mirage]]></category>
            <dc:creator><![CDATA[Vijay Dharap]]></dc:creator>
            <pubDate>Thu, 16 Nov 2017 18:40:56 GMT</pubDate>
            <atom:updated>2017-11-16T18:40:56.989Z</atom:updated>
            <content:encoded><![CDATA[<p>You know, being in programming job means — once in a while — you come across a bug — what I call a <strong><em>Mirage Bug</em></strong>. And solving such bugs is actually one of the joys of programming troubleshooting — the interesting journey of striking out all the false positives and zeroing in on the real culprit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PzekYRwiBeAQ7Tc1Tp5pHA.jpeg" /><figcaption>The mirage… by <a href="https://flic.kr/p/556Uvk">Michael</a></figcaption></figure><p>I had the luck of coming across and solving one such mirage bug today.. So I thought I will share the journey with you as well.</p><p>Today, one of my team members reached out to me saying that their application — which uses <a href="https://www.primefaces.org/primeng/#/datatable">PrimeNg Datatables</a> is irrationally slow on IE11 <em>“once the data table renders”</em>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ceCZFZ9NGVvkRfa-gtf2KA.png" /><figcaption>Demo of PrimeNg Datatable Angular Component..</figcaption></figure><p>He presented me his analysis which included reference to a number of github issues claiming PrimeNg Datatable had performance issues ( even at smaller number of rows and columns ). This is a season of IE11 Angular performance issues and this particular analysis worried me. I have come to love PrimeNg library and its simplicity. And here was a big blow to my belief in that library!</p><p>In a screensharing session, the developer showed me the unbelievable plight of his IE window.. literally reeling under the load of rendering a simple datatable.. and … and I was sold to the idea that the bug really really exists with data table and somehow PrimeNg — a very fine library — somehow has done a super shoddy job in designing their data table — which cannot even load 20 rows x 6 column table without chocking the browser!!</p><p>While he demonstrated the issue — I ignored other signs which I should have paid heed to. e.g. He had to choose couple of dropdowns before hitting a button that brings data for Datatable.. and the application seemed just a wee bit sluggish when he tried to open the dropdown to select one item out of it. Had I questioned that behavior — I would have saved 3–4 hours of my life.. but I guess I wouldn’t have been exhilarated at the end like I felt now!</p><p>So.. since I could not find any issue / reason for such behavior of Datatable on IE.. I asked my developer to allow me to do my own debugging in my little corner. After spending 2–3 hours reading through various github issue descriptions for PrimeNg datatable and analysis about Data table performance issues.. all the issues seemed to be fixed by v4.1.0 and we were already on v4.1.2 and that is what was baffling me.</p><p>Finally I took out last tool in my arsenal —<strong><em>Divide and Rule</em></strong> . I knew if this does not work, nothing will! I started clearing the out all specialties of DataTable, checkbox column, inline editing, selection.. suspecting that one of it causing IE to trip! But no matter what I was doing IE was stuttering and my machine’s CPU usage was going out of the roof. Even when I was not even touching IE! <strong><em>Ta da!</em></strong> And, after several minutes it hit me.. What if I am looking at wrong place for wrong person? What if it’s IE’s high CPU usage (due to some other cause) was <em>THE</em> culprit affecting Datatable rendering in IE?</p><p>Now I started checking exact event which triggers IE to have high CPU usage and I was terrified to see that IE had high CPU usage right from the home page rendering — which hardly had 2 buttons along with bunch of static text and images (apart from header and footer). Forget PrimeNg Datatable, I really started doubting performance of Angular itself on IE11 now!!</p><p>Again, I continued my <em>divide and rule</em> strategy to finally isolate the issue in lamest component in my entire application — Footer Component — one which had just 4–5 links! If I comment out that component.. world is a happy place again!</p><p>God, what is happening in the world! What on earth could we possibly write in harmless footer component that grinds entire application to halt!! Anxiously, I started going through the template and component code for footer .. and there it was… sitting patiently for me to find him ngAfterViewChecked() implementation laughing at me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*GGgkdL-G3H3qwVzm3j9mZw.png" /><figcaption>The Angular Lifecycle hooks!</figcaption></figure><p>ngAfterViewChecked gets called automatically by the Angular rendering engine automatically if component properties change. And this particular implementation was changing one of the component properties via setTimeout() thereby triggering another call to ngAfterViewChecked.. which was again causing another call to ngAfterViewChecked and so on.. in an infinite cycle!</p><p>I simply adjusted the implementation to work without ngAfterViewChecked and boom, we were in business! World was a happy place again! Angular application was working fine in IE without a hitch! PrimeNG Datatable was a high quality component without rendering issues for simple usecase like ours! It was our own 6 lines of code that was making our life miserable!</p><p>I had fun in figuring it out and I hope you had too!</p><p>I will come back with more such stories of performance improvement / fixes for Angular App.. Keep reading. Subscribe to my channel to get notified about new stories from my side!</p><p>Oh and hit <strong><em>claps</em></strong> as many times as you could to keep encouraging me to write more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9bfa353d0fc4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/angular-application-performance-fixes-story-1-9bfa353d0fc4">Angular Application Performance Fixes — Story #1</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best-practices learnt from delivering a quality Angular4 application]]></title>
            <link>https://medium.com/hackernoon/best-practices-learnt-from-delivering-a-quality-angular4-application-2cd074ea53b3?source=rss-71ef7482620------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cd074ea53b3</guid>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[components]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Vijay Dharap]]></dc:creator>
            <pubDate>Fri, 06 Oct 2017 15:02:57 GMT</pubDate>
            <atom:updated>2018-01-16T07:27:06.116Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IKWAhYGQDY1DpqRcPVMPAQ.png" /><figcaption>Best Practices for developing with Angular Framework</figcaption></figure><p>Back in Sept 2016, just when Angular team bit the bullet and <a href="http://angularjs.blogspot.in/2016/09/angular2-final.html">released Angular2 Final</a>, I was able to convince my customer to use Angular2 for it’s one of bigger applications.</p><p>As some of you might recall, Angular2 went through an unusually long Alpha, Beta and RC stages. It seemed as if the entire Angular2 was re-written since the first Alpha release. So at the time of 2.0 final release, the entire Angular scene was <strong><em>very</em></strong> chaotic. There were hardly any good tutorials or resources which were working with 2.0.0.Final release.</p><p>I also did not have AngularJS(1.x) background. I had just delivered a huge SPA using Backbone-Marionette-Rivets.js stack. In the hindsight, it was a good thing to not have baggage from AngularJS!</p><blockquote>All in all, we took a leap of faith! I placed my faith on Angular developers, community and my ability to adapt to new framework and jumped into the valley without a parachute!</blockquote><p>Me and my core team members — we had about 3–4 weeks time to create the first spike and we all ran fence to fence; fell often but learnt a lot. My overall experience of JavaScript development scene also came handy when we scaled from 4 people to about 18 people team in couple of months.</p><p>Looking back, after 6–8 months of development and product delivery of the application, I can see that some good practices saved the day. This post summarizes them for everyone’s benefit. Without further ado, here are some of the best practices that you might want to adopt to deliver a quality Angular application…</p><h3>Best practices for Absolute beginners</h3><h4>Become comfortable with ES2015</h4><p><strong>Most of the initial curve for angular is just about getting comfortable with ES2015. </strong>So ensure all the developers on the team have READ and actually TRIED ES2015 and ES2016 flavors of JavaScript. There is A LOT to learn here but it will just make ready to face the external world tutorials which often makes use of these syntax. E.g. syntax like () =&gt; { } or […a, b,] should not trip you. Or usage of import, class, let, const, etc should be first nature to your developers.</p><h4><strong>Embrace Typescript and Visual Studio Code (VSCode).</strong></h4><p>Most of the code snippets for Angular you will find online are in Typescript.. which is a superset of ES2015. I will highly recommend that you use this so that code snippets online will make sense. Also as a companion, use Visual Studio for Code as your IDE, TSLint as your linter and TSLint plugin in VSCode to ensure you get best static code analysis experience. Plus — by using TS, you don’t need Babel. <strong>Bonus</strong>: Also add <a href="https://marketplace.visualstudio.com/items?itemName=Angular.ng-template">Angular Language Service</a> plugin to VSCode. This gives far better angular experience especially in the Angular templates.</p><h4><strong>Master npm ecosystem.</strong></h4><p>Along-side ES2015, Angular is also all about being comfortable with Node and NPM Ecosystem. Any serious example will make use of package.json (npm) and node to build and run their example. Virtually EVERY angular component out there will give you instructions about how to install it using npm. So make absence of Npm and VSCode deal-breaker for your teams. Either your developers are using these tools or they are not on your team! Seriously!</p><h3>Angular Application Development Best Practices</h3><h4>Eat, Sleep, Breath Components!</h4><p><strong>Angular is all about components.</strong> <strong>Design the components first, before starting to code</strong>. By design, I mean –</p><ul><li><em>Draw outlines on the Visual-Designs to clearly demarcate which screen area will be owned by which component. Make the components small enough so that they can be reused at many places But large enough that making them any smaller makes no sense. It takes a bit of time to get used to creating this this logical grouping but you can naturally do this in 2–3 sprints. I insist on my entire team doing this for EVERY story in EVERY sprint.</em></li><li><em>Once you know your component, document the “inputs” and “outputs”. I have a small design-checklist which I make every developer fill-up as a short design documentation for each story. Please see </em><strong><em>Design Narrative</em></strong><em> section at the bottom of below this post if you want to adapt it in your project.</em></li></ul><p>Design each component with Re-usability in mind. Try to create commonly used UI element as separate component and re-use them in the screens.</p><h4>Use seed projects to hit the ground running!</h4><p>Make use of some kickass starter seed projects because they would have done a great job at incorporating many features for you. I wholeheartedly recommend <a href="https://github.com/AngularClass/angular2-webpack-starter">AngularClass webpack starter</a> or <a href="https://github.com/blacksonic/angular2-babel-esnext-starter">BlackSonic’s ES6 starter</a>. This will get you running in no time with a great foundation for large project.</p><h4>Or… Use Angular-CLI</h4><p>Other option is to use <a href="https://cli.angular.io/">Angular-CLI</a>. Angular CLI is really good option for those who are finding entire ES2015+TypeScript+Angular a bit overwhelming. It abstract away quite a few things from you including entire webpack configuration. But that abstraction is also a downside since you cannot tinker around those abstracted parts. Thankfully, there is a eject option in Angular-CLI to eject most of abstracted things.</p><h4>RIP SystemJS, Hello Webpack!</h4><p>From the beginning, stop using SystemJS and switch over to <a href="https://webpack.js.org/">Webpack</a>. Webpack is far more powerful and versatile tool. Optimize <a href="https://webpack.js.org/">webpack</a> bundles effectively to ensure that you are not bundling same modules in multiple chunks. There are bundle-analyzers from webpack which do brilliant job of telling you about this. <strong>Bonus</strong>: <a href="http://tiny.cc/webpack101">Webpack Learning Slides</a> and <a href="http://tiny.cc/learn-webpack-code">Step-by-step code</a></p><h4>Use AoT FTW!</h4><p>Usage of <a href="https://angular.io/guide/aot-compiler">AoT</a> (ahead of time) compilation is a great step towards performance gains at runtime. It also reduces your bundle by about 30kb (gzipped) which is a LOT of improvement. Angular 4.0+ brings about 30% improvement in app bundles due to how it generates the AoT code.</p><h4><strong>Understand Observables from RxJS.</strong></h4><p>A LOT of Angular work is about understanding what is <strong><em>Observable</em></strong>. It’s very important to understand how Observables work and becoming comfortable with RxJS library which helps you become Observable Ninja.</p><h4>Lazy Loading the non-first-page routes</h4><p>Lazy-load every route which don’t need at 1st page hit. Webpack2 import() <a href="https://webpack.js.org/api/module-methods/#import-">function</a> will come handy for you. Also webpack’s <a href="https://www.npmjs.com/package/ng-router-loader">ng-router-loader</a> will help automate the bundle creation for each lazy loaded module automatically..</p><h4>Using Widgets and Libraries</h4><p>Consider using standard widget library like <a href="https://www.primefaces.org/primeng/">PrimeNG</a> or <a href="http://valor-software.com/ngx-bootstrap">ValorSoft</a>. Try to avoid JQuery as it <a href="https://github.com/rollup/rollup/issues/509#issuecomment-182423609">cannot be tree-shaken</a>.</p><h4>Debugging</h4><p>Make use of ng.probe() in chrome console to do <a href="https://juristr.com/blog/2016/02/debugging-angular2-console/">effective debugging</a> / Or make use of <a href="https://augury.angular.io/">Augury chrome extension </a>— which wraps ng.probe for you.</p><h4>Stay safe in Dark Corners of NgZone</h4><p>NgZone and ZoneJS are some of the dark corners of Angular. When things don’t work fine even after you trying 100 different things for many days, you might be up against these two adversaries. I call them dark corners because no error will ever tell you that that error can be fixed if you fiddle around with NgZone. You must correlate your error and potential NgZone conflict yourself 😧. As such, NgZone is quite <a href="https://blog.thoughtram.io/angular/2016/02/01/zones-in-angular-2.html#running-code-outside-angulars-zone">easy to use</a> but I did not even know it existed for almost 5 months in my project.</p><h4>Other wins via code structuring</h4><ol><li><strong>Shared Modules</strong> — Try to make use of shared module. Create a module and that should import &amp; export all the commonly used modules &amp; providers and import this in other modules.</li><li><strong>Global vs local CSS </strong>— Whenever writing the CSS, try to visualize if this kind of element might be used at lot of places and then write the style at application level instead of component, it will avoid the re-writing it again in new component. You can just override any small change is required in component level.</li><li><strong>Theme File with SCSS</strong> — When using any CSS preprocessor, always define a file which has variables only related to color, font-size, etc. of the applications, it will help when you need to change the theme.</li><li><strong>Typescript Inheritance for your help </strong>— Try to utilize the Inheritance in Typescript. If you have some view related functionality that might be required in many screens, you can create a base component with common functionality and then all other components can just extend it.</li><li><strong>Use Services </strong>— Strive for complete segregation between the View implementation and service call. In the UI component, keep code only related to view, and delegate to a service to make the backend calls and for any functional logic.</li></ol><h3>General Web Developer Productivity Best Practices</h3><ol><li><strong>Improve development workflow </strong>— Often times, developer do not think about finding shortcuts to improve their developer productivity. This includes, circumventing login locally, caching backend calls which are not required for your current work, making small code fixes to skip through 10 screens / clicks to arrive at the screen where they need to do their change. One should spend half an hour to tweak these things reach their current screen instantly and save time on every minor code update.</li><li><strong>Mandatory Human Code Review </strong>— We have mandated that all developers must deliver code as pull_request in Git. Architect would review and approve the code before merging. This ensures that each line of code has been reviewed before merging. This help catching bugs and quality / performance problems which cannot be caught using Linters.</li></ol><h3>Design narrative:</h3><p>One of the best thing that we implemented was — process of design elaboration from each developer for their story.</p><p>I insist that my developers follow this narrative.</p><h4>To deliver story xyz,</h4><ol><li>Which component(s) would be required to be “created” or “modified”.</li><li>How will the component be accessed? From a topNav? Routing? From some user interaction on other components?</li><li>Which folder would those components belong?</li><li>What kind of @input, @output would be provided to / emitted from these components.</li><li>What would be your backend call requirement and it’s sequence</li><li>Any form validations?</li><li>Any spl technical things / libs required? E.g. moment, datepicker, modal, etc.</li><li>“Productivity improvement”? How will you reach your page fast — hardcoding? Proxying?</li></ol><p>I have found that the developers were far more confident and their code quality improved once we established above design documentation process. Hopefully, you will find similar change in your team quality as well.</p><p><em>This post is adapted from my original post on my </em><a href="https://dharapvj.wordpress.com/"><em>blog</em></a><em>.</em></p><p>That’s it folks for now. Thank you for patiently reading till the end! If you liked the story — please follow me on <a href="https://twitter.com/dharapvj">twitter</a> and hit ❤️ symbol below the story.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cd074ea53b3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/best-practices-learnt-from-delivering-a-quality-angular4-application-2cd074ea53b3">Best-practices learnt from delivering a quality Angular4 application</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>