<?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 Helani Waidyarathne on Medium]]></title>
        <description><![CDATA[Stories by Helani Waidyarathne on Medium]]></description>
        <link>https://medium.com/@helani1234?source=rss-faa8d5f8759f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*nTs_hb8Hd8MiUZS1eCdTXA.jpeg</url>
            <title>Stories by Helani Waidyarathne on Medium</title>
            <link>https://medium.com/@helani1234?source=rss-faa8d5f8759f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 09:12:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@helani1234/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[GraphQL vs REST]]></title>
            <link>https://medium.com/@helani1234/graphql-vs-rest-420fe7e67421?source=rss-faa8d5f8759f------2</link>
            <guid isPermaLink="false">https://medium.com/p/420fe7e67421</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[Helani Waidyarathne]]></dc:creator>
            <pubDate>Fri, 07 Aug 2020 08:08:02 GMT</pubDate>
            <atom:updated>2020-08-07T08:08:02.872Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OqsUcppIgxN0tcLM7xSxTg.jpeg" /></figure><p>When you’re working with web APIs in web development typically have the choice between rest APIs and GraphQL APIs.</p><p>Let’s have a quick gander at what GraphQL and REST API means. Over the past year, REST became the standard for designing APIs. Because it offered a connection to stateless servers and structured access to resources, many developers used it. However, it is can be too inflexible.</p><p>To overcome the inflexibility of REST APIs, GraphQL was developed. It solves many of the shortcomings and inefficiencies that developers experience.</p><h3>What?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*WH-AK6LsxAs-csOUeCxvoQ.jpeg" /></figure><p>APIs that we expose on some servers. For building such a web service typically follow two approaches. Either build such a rest API and use concept related to that or you follow that graphql API approach and build your web service in that way. In both cases, you have a web service, but how you build your web service, also how the client queries that service.</p><p>A rest API embraces the concept of having multiple endpoints which means multiple URLs are exposed by your web service to be precise URLs or paths on that domain when you host that web service that reacts to different Http methods being used in the requests that reach that web service.</p><p>Graphql API works with one endpoint only which always reached with a post request.</p><p>In both APIs typically exchange JSON data through, also the same is that you can use any server-side language or framework. Also common for both API is that they’re stateless.</p><h3><strong>URL Driven vs Query Language</strong></h3><p>The core difference between these two kinds of APIs really is how you send requests to them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FHVf-Z_Etc9bbe-UlFzIOg.jpeg" /></figure><p>REST is an acronym for <strong>RE</strong>presentational <strong>S</strong>tate <strong>T</strong>ransfer. It is an architectural style for <strong>distributed hypermedia systems. </strong>In Rest API you have to work with multiple endpoints. These are the 3 important things that makeup such a request. They are Http verb, path, and request body. Not all requests need such a body. For example, GET requests don’t include a body.</p><p>GraphQL is a <strong>query language</strong>. This query language is mainly used in APIs and to fulfill queries with the existing data. It provides a complete and understandable description of the data in the API. GraphQL API has one endpoint. That endpoint can have any path you want. Often it’s /graphql. It always takes a POST request.</p><h3>Conclusion</h3><p>GraphQL and REST are two approaches to API architecture. GraphQL certainly has many advantages over REST but you should consider your project size/complexity before usage.</p><p>If you want to learn more about GraphQL and wish to develop this architecture to your application, have a look at the <a href="https://graphql.org/learn/">documentation</a>.</p><p>That’s all for now. I hope this was very useful. See you in the next article!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=420fe7e67421" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 Tips for Angular Developers]]></title>
            <link>https://medium.com/@helani1234/10-tips-for-angular-developers-bd27cce18d4?source=rss-faa8d5f8759f------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd27cce18d4</guid>
            <category><![CDATA[tips]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular-developers]]></category>
            <dc:creator><![CDATA[Helani Waidyarathne]]></dc:creator>
            <pubDate>Sun, 14 Jun 2020 07:37:39 GMT</pubDate>
            <atom:updated>2020-06-14T07:43:44.962Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*iG_ahM0gFOflmhpVIf4UFA.png" /></figure><p><strong>Angular </strong>is a TypeScript-based open-source web application framework led by the Angular Team at Google and by a community of individuals and corporations. Angular is a complete rewrite from the same team that built AngularJS. Here are 10 tips that should be known for angular developers.</p><h4><strong>1. Components</strong></h4><p>When you’re working with components, angular, or any framework you should always keep them small and manageable. Keep it with the single responsibility principle which means it states that a class should have one and only one reason to change, meaning that a class should have only one job. In other words, if you’re creating an about component it what should be in it is the about component and if you have other things like alerts, special widget then you may want to abstract that out to separate classes that you can import in as child components to your parent component which is the about.</p><p>Create extra components because it makes the code easier to read, understand, and test.</p><h4>2. <strong>Testing</strong></h4><p>When you do ng generate command it creates the spec file for you to use. You don’t have to use that spec file the way it’s generated but usually what it does is when you create a spec file with a generator, it creates a TestBed. The TestBed is a great way to test your component, not the typescript file or class, or also the template itself. Look at the official documentation The Angular <a href="https://angular.io/api/core/testing/TestBed">TestBed</a> facilitates this kind of testing as you’ll see in the sections below. But in many cases, testing the component class alone, without DOM involvement, can validate much of the component’s behavior in an easier, more obvious way. For example,</p><pre>describe(‘LightswitchComp’, () =&gt; {<br> it(‘#clicked() should toggle #isOn’, () =&gt; {<br> const comp = new LightswitchComponent();<br> expect(comp.isOn).toBe(false, ‘off at first’);<br> comp.clicked();<br> expect(comp.isOn).toBe(true, ‘on after click’);<br> comp.clicked();<br> expect(comp.isOn).toBe(false, ‘off after second click’);<br> });</pre><pre>it(‘#clicked() should set #message to “is on”’, () =&gt; {<br> const comp = new LightswitchComponent();<br> expect(comp.message).toMatch(/is off/i, ‘off at first’);<br> comp.clicked();<br> expect(comp.message).toMatch(/is on/i, ‘on after clicked’);<br> });<br>});</pre><p>This is the light switch component. This has the instance of the light switch component. You can test some of the fields in it. ‘is on’ you can see what happens when the components clicked and also you can see what’s happening even check the messages that you see. This is testing without testbed.</p><h4><strong>3. Unsubscribe</strong></h4><p>You will start creating subscriptions make sure you unsubscribe them at the bottom at one point. If you don’t unsubscribe it you can have issues with like memory leak because you’ll be moving from component to component.</p><p>RxJS subscription sink for unsubscribing gracefully in a component. SubSink is a dead-simple class to absorb RxJS subscriptions in an array. Call unsubscribe() to unsubscribe all of them, as you would do in your component library&#39;s unmount/onDestroy lifecycle event.</p><p>Example of using the .add technique. This is similar to what RxJS supports out of the box.</p><pre>export class SomeComponent implements OnDestroy {</pre><pre>private subs = new SubSink();</pre><pre>...</pre><pre>this.subs.add(observable$.subscribe(...)); //easy syntax</pre><pre>this.subs.add(observable$.subscribe(...)); //if you insist</pre><pre>// Add multiple subscriptions at the same time<br>this.subs.add(<br>  observable$.subscribe(...),<br>  anotherObservable$.subscribe(...)<br>);</pre><pre>...</pre><pre>// Unsubscribe when the component dies<br>ngOnDestroy() {<br>  this.subs.unsubscribe();<br>}</pre><pre>}</pre><h4>4. Public and Private</h4><p>Make sure you set public and private on all variables and methods. The reason for doing this is, it is all about encapsulation., and when you have a field or method on your component that you want to encapsulate it, making it clear that it shouldn’t be accessed from anywhere else, then you should absolutely make it private: that’s what private is for: It signals your intent that whatever you’ve put it on shouldn’t be touched from outside the class.</p><h4>5. Use Angular Forms</h4><p>Use both dynamic and template-based forms. The Angular form discussed in this page takes advantage of the following framework features to provide support for data modification, validation, and more:</p><ul><li>An Angular HTML form template.</li><li>A form component class with a @<a href="https://angular.io/api/core/Component">Component</a> decorator.</li><li>Handling form submission by binding to the <a href="https://angular.io/api/forms/NgForm#ngSubmit">NgForm.ngSubmit</a> event property.</li><li>Template-reference variables such as #heroForm and #name.</li><li>[(<a href="https://angular.io/api/forms/NgModel">ngModel</a>)] syntax for two-way data binding.</li><li>The use of name attributes for validation and form-element change tracking.</li><li>The reference variable’s valid property on input controls to check if control is valid and show/hide error messages.</li><li>Controlling the <em>Submit</em> button’s enabled state by binding to <a href="https://angular.io/api/forms/NgForm">NgForm</a> validity.</li><li>Custom CSS classes that provide visual feedback to users about invalid controls.</li></ul><pre>     &lt;h1&gt;Hero <a href="https://angular.io/api/forms/Form">Form</a>&lt;/h1&gt;<br>     &lt;form (ngSubmit)=&quot;onSubmit()&quot; #heroForm=&quot;<a href="https://angular.io/api/forms/NgForm">ngForm</a>&quot;&gt;<br>       &lt;div class=&quot;form-group&quot;&gt;<br>         &lt;label for=&quot;name&quot;&gt;Name&lt;/label&gt;<br>         &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;name&quot;    <br>                required<br>                [(<a href="https://angular.io/api/forms/NgModel">ngModel</a>)]=&quot;model.name&quot; name=&quot;name&quot;<br>                #name=&quot;<a href="https://angular.io/api/forms/NgModel">ngModel</a>&quot;&gt;<br>         &lt;div [hidden]=&quot;name.valid || name.pristine&quot; <br>              class=&quot;alert alert-danger&quot;&gt;<br>           Name is required<br>         &lt;/div&gt;<br>       &lt;/div&gt;</pre><h4>6. Use Classes / Enums</h4><p>Classes are very valuable, and enums are helpful when passing to your components. This idea is like the open-closed principle. Objects or entities should be open for extension but closed for modification. This simply means that a class should be easily extendable without modifying the class itself.</p><h4>7. Learn RxJS</h4><p>Lots of great operators you should checkout. (retry, pipe, skip filter) RxJS provides an implementation of the Observable type, which is needed until the type becomes part of the language and until browsers support it. The library also provides utility functions for creating and working with observables. These utility functions can be used for:</p><ul><li>Converting existing code for async operations into observables</li><li>Iterating through the values in a stream</li><li>Mapping values to different types</li><li>Filtering streams</li><li>Composing multiple streams</li></ul><pre>import { ajax } from &#39;rxjs/ajax&#39;;<br>import { map, retry, catchError } from &#39;rxjs/operators&#39;;</pre><pre>const apiData = ajax(&#39;/api/data&#39;).pipe(<br>   retry(3), // Retry up to 3 times before failing<br>   map(res =&gt; {<br>     if (!res.response) {<br>       throw new Error(&#39;Value expected!&#39;);<br>     }<br>     return res.response;<br>   }),<br>   catchError(err =&gt; of([]))<br> );</pre><pre>apiData.subscribe({<br>   next(x) { console.log(&#39;data: &#39;, x); },<br>   error(err) { console.log(&#39;errors already caught... will not run&#39;); } <br>});</pre><h4>8. Lazy Loading</h4><p>. For large apps with lots of routes, consider lazy loading — a design pattern that loads NgModules as needed. Lazy loading helps keep initial bundle sizes smaller, which in turn helps decrease load times.</p><pre>const routes: Routes = [<br>  {<br>    path: &#39;customers&#39;,<br>    loadChildren: () =&gt; import(&#39;./customers/customers.module&#39;).then(m =&gt; m.CustomersModule)<br>  },<br>  {<br>    path: &#39;orders&#39;,<br>    loadChildren: () =&gt; import(&#39;./orders/orders.module&#39;).then(m =&gt; m.OrdersModule)<br>  },<br>  {<br>    path: &#39;&#39;,<br>    redirectTo: &#39;&#39;,<br>    pathMatch: &#39;full&#39;<br>  }<br>];</pre><h4>9. Transclusion</h4><p>Sometimes known as content projection. Transclusion is a way to let you define a fixed view template, and at the same time allow you to define a slot for dynamic content by using &lt;ng-content&gt; tag.</p><pre>&lt;div class=&quot;card&quot;&gt;<br>    &lt;div class=&quot;card-header&quot;&gt;<br>        {{ header }}<br>    &lt;/div&gt;<br><br>    &lt;!-- single slot transclusion here --&gt;<br>    &lt;ng-content&gt;&lt;/ng-content&gt;<br><br>    &lt;div class=&quot;card-footer&quot;&gt;<br>        {{ footer }}<br>    &lt;/div&gt;<br>&lt;/div&gt;</pre><h4>10. NGRX</h4><p>NgRx is a framework for building reactive applications in Angular. NgRx provides state management, isolation of side effects, entity collection management, router bindings, code generation, and developer tools that enhance developers experience when building many different types of applications.</p><p>That’s all for now. I hope this was very useful for angular developers. See you in the next article!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd27cce18d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Word Embeddings]]></title>
            <link>https://medium.com/@helani1234/word-embeddings-6af08a8cf881?source=rss-faa8d5f8759f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6af08a8cf881</guid>
            <category><![CDATA[word-embeddings]]></category>
            <category><![CDATA[word2vec]]></category>
            <dc:creator><![CDATA[Helani Waidyarathne]]></dc:creator>
            <pubDate>Sat, 23 May 2020 14:59:17 GMT</pubDate>
            <atom:updated>2020-05-23T14:59:17.081Z</atom:updated>
            <content:encoded><![CDATA[<p>Word embedding is a general term that refers to creating a vector representation of the meaning of a word. Word embedding tends to refer to slightly more sophisticated models that do not rely entirely on representations where each variable within a vector directly reflects a document. So, this means that they often contain information about the close-range context of rather than relying simply on co-occurrence within a document. Word embedding models are by and large machine learning algorithms that aim to provide us with meaningful representations of word semantics. Among the most successful of this model is word2vec. This is technically two distinct neural network-based models skip-gram and continuous bag of words or CBOW. Another embedding model is fast-text which is created by the research team at Facebook. Gensim contains an implementation of both of these algorithms. Ideally, we should be able to perform math on the word vectors to learn about semantic relationships.</p><p>So, for example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*k2xwyfGYlaAmG36M7pk-jQ.png" /></figure><p>The position of Beijing to China should be similar to Berlin relative to the position of Germany.</p><p>Another classic example is,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*CPyQq2KmZmr7S5_QioPH8g.png" /></figure><p>We should ideally be able to take the vector for king that the model creates subtract the vector from man add in the vector for women and arrive somewhere pretty close to the vector for queen.</p><h3>Architecture of word2vec models</h3><p>Two algorithms found in word2vec. These two models behave and related but essentially opposite manners.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*zXBzF7exPM10hmnRvDvLAA.png" /></figure><p>In Skip Gram the model tries to learn a projection that can take a word as input and predict the context in which the word was found.</p><p>CBOW takes a context and tries to predict the word that should appear there.</p><h3>Conclusion</h3><p>I hope this was very useful and good luck with your text analysis.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6af08a8cf881" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>