<?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[Tech Tackle - Medium]]></title>
        <description><![CDATA[This Page is to share learning about Programming. if anyone want to share any technical story. Email your story to prabusubraa@gmail.com. I will publish it on this page. - Medium]]></description>
        <link>https://medium.com/codeengineer?source=rss----10791b52f715---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Tech Tackle - Medium</title>
            <link>https://medium.com/codeengineer?source=rss----10791b52f715---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 10:19:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/codeengineer" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Spring Bean Lifecycle]]></title>
            <link>https://medium.com/codeengineer/spring-bean-lifecycle-f3763d3ebdef?source=rss----10791b52f715---4</link>
            <guid isPermaLink="false">https://medium.com/p/f3763d3ebdef</guid>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[spring-bean]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Prabu Subra]]></dc:creator>
            <pubDate>Fri, 25 Nov 2022 21:01:27 GMT</pubDate>
            <atom:updated>2022-11-25T21:00:32.659Z</atom:updated>
            <content:encoded><![CDATA[<p>Spring IoC container create the beans and perform few post process activities based on the configurations like implementing <strong><em>Aware</em></strong> <em>interfaces</em> and <em>annotations</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*2th4UTVoDV_l_sn6yUpLQQ.png" /><figcaption>Spring Bean Lifecycle hooks</figcaption></figure><p>In a nutshell, Spring IoC Container first check for dependency then calls its constructor. After creation of bean, it first injects the dependencies auto wired 0n constructor, Field and setters. Then Aware interfaces(<strong><em>BeanNameAware</em></strong>, <strong><em>BeanClassLoaderAware</em></strong>, <strong><em>ApplicationContextAware…</em></strong>) and annotated method like <strong><em>PostConstruct</em></strong> is invoked. At last<strong> <em>init-method</em></strong> is invoked.</p><p>Main Method:-</p><pre>public class Solution1 {<br> public static void main(String[] args) {<br>  AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SolutionConfig.class);<br>  Post post1 = context.getBean(Post.class);<br>  context.close();<br> }<br>}</pre><p>Configuration file.</p><pre>@Configuration<br>public class SolutionConfig {<br> <br> @Bean<br> public Author author() {<br>  return new Author(&quot;Aplha, Engineer&quot;, &quot;alphaengineer@gmail.com&quot;);<br> }<br> <br> @Bean<br> public Post post() {<br>  return new Post(&quot;Spring Bean Lifecycle hooks&quot;, author());<br> }<br>}</pre><p>Post class:-</p><pre>@Getter<br>@Setter<br>@NoArgsConstructor<br>public class Post {<br> <br> private UUID id;<br> private String content;<br> private Author author;<br> <br> @Autowired<br> public Post(String content, Author author) {<br>  System.out.println(&quot; Author from Post constructor : &quot;+author.toString());<br>  this.id = UUID.randomUUID();<br>  this.content = content;<br>  this.author = author;<br> }<br> public void setAuthor(Author author) {<br>  System.out.println(&quot; setAuthor : &quot;+author.toString());<br>  this.author = author;<br> }<br> @Override<br> public String toString() {<br>  return &quot;Post [id=&quot; + id + &quot;, content=&quot; + content + &quot;, author=&quot; + author.toString() + &quot;]&quot;;<br> }<br>}</pre><p>Author Class:-</p><pre>@Getter<br>@Setter<br>@NoArgsConstructor<br>public class Author {<br> <br> private UUID id;<br> private String fullName;<br> private String email;<br><br> public Author(String fullName, String email) {<br>  System.out.println(&quot;Author constructor&quot;);<br>  this.id = UUID.randomUUID();<br>  this.fullName = fullName;<br>  this.email = email;<br> }<br> <br> @Override<br> public String toString() {<br>  return &quot;Author [id=&quot; + id + &quot;, fullName=&quot; + fullName + &quot;, email=&quot; + email + &quot;]&quot;;<br> }<br>}</pre><p>Sample Output:-</p><pre>Author constructor<br>Author from Post constructor : Author [id=0b6afb4d-02d8-4f17-adfd-57aeafb8f206, fullName=Aplha, Engineer, email=alphaengineer@gmail.com]<br>Post : Post [id=4d5e403f-a75b-43f0-bf8f-d596a0e5814d, content=Spring Bean Lifecycle hooks, author=Author [id=0b6afb4d-02d8-4f17-adfd-57aeafb8f206, fullName=Aplha, Engineer, email=alphaengineer@gmail.com]]</pre><p>Dependencies are instantiated and injected based on Auto wiring configuration. if we use setter auto wiring then respective setter will called and add dependency.</p><p>Configuration:-</p><pre>@Configuration<br>public class SolutionConfig {<br><br> @Bean(initMethod = &quot;initMethod&quot;, destroyMethod = &quot;destroyMethod&quot;)<br> public Author author() {<br>  return new Author(&quot;Aplha, Engineer&quot;, &quot;alphaengineer@gmail.com&quot;);<br> }<br> <br> @Bean(initMethod = &quot;initMethod&quot;, destroyMethod = &quot;destroyMethod&quot;)<br> public Post post() {<br>  return new Post(&quot;Spring Bean Lifecycle hooks&quot;, author());<br> }<br>}</pre><p><strong>Aware Interfaces:-</strong></p><p>Aware interfaces are used to check and configure information about bean name, class loader and Application Context details.</p><pre>@Getter<br>@Setter<br>@NoArgsConstructor<br>public class Post implements BeanNameAware, BeanClassLoaderAware, ApplicationContextAware, InitializingBean, DisposableBean {<br> <br> private UUID id;<br> private String content;<br> private Author author;<br> <br> public Post(String content, Author author) {<br>  System.out.println(&quot;Author from Post constructor : &quot;+author.toString());<br>  this.id = UUID.randomUUID();<br>  this.content = content;<br>  this.author = author;<br> }<br> <br> @PostConstruct<br> public void init() {<br>  System.out.println(&quot;Post, @PostConstruct annotated method&quot;);<br> }<br> <br> @PreDestroy<br> public void predestroy() {<br>  System.out.println(&quot;Post, @PreDestroy annotated method&quot;);<br> }<br> <br> public void initMethod() {<br>  System.out.println(&quot;Post, initMethod method&quot;);<br> }<br> public void destroyMethod() {<br>  System.out.println(&quot;Post, destroyMethod method&quot;);<br> }<br> <br> public void destroy() {<br>  System.out.println(&quot;Post, destroy method from Disposable interface&quot;);<br> }<br> <br> @Autowired<br> public void setAuthor(Author author) {<br>  System.out.println(&quot;setAuthor : &quot;+author.toString());<br>  this.author = author;<br> }<br> @Override<br> public String toString() {<br>  return &quot;Post [id=&quot; + id + &quot;, content=&quot; + content + &quot;, author=&quot; + author.toString() + &quot;]&quot;;<br> }<br><br> public void setBeanName(String name) {<br>  System.out.println(&quot;Post, setBeanName method from BeanNameAware interface : &quot;+name);<br> }<br><br> public void setBeanClassLoader(ClassLoader classLoader) {<br>  System.out.println(&quot;Post, setBeanClassLoader method BeanClassLoaderAware interface : &quot;+classLoader.getName());<br> }<br><br> public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {<br>  System.out.println(&quot;Post, setApplicationContext method ApplicationContextAware interface : &quot;+applicationContext.getApplicationName());<br> }<br><br> public void afterPropertiesSet() throws Exception {<br>  System.out.println(&quot;Post, afterPropertiesSet method InitializingBean interface  &quot;);<br> }<br>}</pre><pre>@Getter<br>@Setter<br>@NoArgsConstructor<br>public class Author implements BeanNameAware, BeanClassLoaderAware, ApplicationContextAware, InitializingBean, DisposableBean {<br> <br> private UUID id;<br> private String fullName;<br> private String email;<br><br> public Author(String fullName, String email) {<br>  System.out.println(&quot;Author constructor&quot;);<br>  this.id = UUID.randomUUID();<br>  this.fullName = fullName;<br>  this.email = email;<br> }<br> @PostConstruct<br> public void init() {<br>  System.out.println(&quot;Author, @PostConstruct annotated method&quot;);<br> }<br> @PreDestroy<br> public void predestroy() {<br>  System.out.println(&quot;Author, @PreDestroy annotated method&quot;);<br> }<br> public void destroy() {<br>  System.out.println(&quot;Author, destroy method from DisposableBean interface&quot;);<br> }<br> public void initMethod() {<br>  System.out.println(&quot;Author, initMethod method&quot;);<br> }<br> public void destroyMethod() {<br>  System.out.println(&quot;Author, destroyMethod method&quot;);<br> }<br> @Override<br> public String toString() {<br>  return &quot;Author [id=&quot; + id + &quot;, fullName=&quot; + fullName + &quot;, email=&quot; + email + &quot;]&quot;;<br> }<br> public void setBeanName(String name) {<br>  System.out.println(&quot;Author, setBeanName method from BeanNameAware interface : &quot;+name);<br> }<br><br> public void setBeanClassLoader(ClassLoader classLoader) {<br>  System.out.println(&quot;Author, setBeanClassLoader method BeanClassLoaderAware interface : &quot;+classLoader.getName());<br> }<br><br> public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {<br>  System.out.println(&quot;Author, setApplicationContext method ApplicationContextAware interface : &quot;+applicationContext.getApplicationName());<br> }<br> public void afterPropertiesSet() throws Exception {<br>  System.out.println(&quot;Author, afterPropertiesSet method InitializingBean interface  &quot;);<br> }<br>}</pre><p>Sample Output:-</p><pre>Author, setBeanClassLoader method BeanClassLoaderAware interface : app<br>Author, setApplicationContext method ApplicationContextAware interface : <br>Author, @PostConstruct annotated method<br>Author, afterPropertiesSet method InitializingBean interface  <br>Author, initMethod method<br>Author from Post constructor : Author [id=1e360880-50eb-4bdf-a230-1e825ed67b39, fullName=Aplha, Engineer, email=alphaengineer@gmail.com]<br>setAuthor : Author [id=1e360880-50eb-4bdf-a230-1e825ed67b39, fullName=Aplha, Engineer, email=alphaengineer@gmail.com]<br>Post, setBeanName method from BeanNameAware interface : post<br>Post, setBeanClassLoader method BeanClassLoaderAware interface : app<br>Post, setApplicationContext method ApplicationContextAware interface : <br>Post, @PostConstruct annotated method<br>Post, afterPropertiesSet method InitializingBean interface  <br>Post, initMethod method<br>Post : Post [id=ff29cc5a-b05c-448b-aa7d-05fbe17709ca, content=Spring Bean Lifecycle hooks, author=Author [id=1e360880-50eb-4bdf-a230-1e825ed67b39, fullName=Aplha, Engineer, email=alphaengineer@gmail.com]]<br>Post, @PreDestroy annotated method<br>Post, destroy method from Disposable interface<br>Post, destroyMethod method<br>Author, @PreDestroy annotated method<br>Author, destroy method from DisposableBean interface<br>Author, destroyMethod method</pre><p>Spring Bean Lifecycle Flow:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*q9ItECFrJCNl9OEPHkdqAQ.png" /><figcaption>Spring Bean lifecycle flow</figcaption></figure><p>Spring IoC container first creates the depend beans, inject and then create the bean for usage, then delete the bean and its depend beans. if any runtime exceptions happen in any of these lifecycle hook methods. it breaks the bean instantiation. on successful execution of all these hooks spring bean is ready to use.</p><p>Thanks for spending your valuable time, Think blog is based on my understanding ony, if you feel anything is wrong please feel free to comment.</p><p>Reference:-</p><ul><li><a href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/BeanFactory.html">BeanFactory (Spring Framework 6.0.2 API)</a></li><li><a href="https://www.amazon.in/Pro-Spring-Depth-Guide-Framework-ebook/dp/B076FQ5KFK">Pro Spring 5: An In-Depth Guide to the Spring Framework and Its Tools</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3763d3ebdef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeengineer/spring-bean-lifecycle-f3763d3ebdef">Spring Bean Lifecycle</a> was originally published in <a href="https://medium.com/codeengineer">Tech Tackle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ES2019(ECMAScript2019) Features]]></title>
            <link>https://medium.com/codeengineer/es2019-ecmascript2019-features-2a22f524d5a9?source=rss----10791b52f715---4</link>
            <guid isPermaLink="false">https://medium.com/p/2a22f524d5a9</guid>
            <category><![CDATA[es-2019]]></category>
            <category><![CDATA[es10]]></category>
            <category><![CDATA[ecmascript10]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Prabu Subra]]></dc:creator>
            <pubDate>Tue, 26 Mar 2019 11:06:46 GMT</pubDate>
            <atom:updated>2019-04-04T14:43:58.948Z</atom:updated>
            <content:encoded><![CDATA[<h3>ES10/ES2019(ECMAScript2019) Features</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X4e4xbe3eBLw7hEtmp-_ug.png" /></figure><p><strong>Introduction:-</strong></p><p>Recently, TC39 committee has approved and added few bunch of feature to ECMAScript 2019 Standard, which are ported to major JavaScript engine like V8,SpiderMonkey…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eNTUiW681UAaKb5Od5zutA.png" /></figure><p>Let’s start explore…</p><p><strong>Catch binding:-</strong></p><p>If there is no use of exceptions details in catch block, developer can remove catch binding happily. This will remove unused and boilerplate code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ucu0yTHONWqHmGJO" /></figure><p><strong>Unicode:-</strong></p><p>Firstly, What is unicode?</p><p><em>Unicode provides a unique number for every character, no matter what the platform, no matter what the program, no matter what the language.</em></p><p>To be short, JavaScript internally encode the everything to unicode, not only JavaScript everyone does.</p><p>if you want to know more about, how unicodes are handled in ES5 and ES6 refer <a href="https://mathiasbynens.be/notes/javascript-encoding">here</a>.</p><p>The unicodes<strong><em> u2028</em></strong> and <strong><em>u2029</em></strong> represent <strong>Line separator</strong> and <strong>Paragraph separator repetitively </strong>. Before this proposal, JavaScript engines does not infer these two unicodes for string literals. Now string literals understands these unicodes as well.</p><p>Nashorn ES6 JS Engine:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5gtCA8uZrobXROoLt-1YLw.png" /></figure><p>V8 ES10 Engine:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gFdYmBmLNLXoA3lTsoYMAQ.png" /></figure><p>Apart from the above change,<strong> JSON.stringify</strong> also improved to return well-formed unicode for alone surrogate.</p><p>In a nutshell, A few bunch of characters like emojis need more than 16 bit to represent a single character, to solve this issue, UTF-16 has combined two 16 bits and represent those characters. Individually these characters doesn’t have any meaning. hereafter these alone surrogates are prevented from returning invalid junk characters.</p><p>Examples:-</p><p>U+1F60D SMILING FACE WITH HEART-SHAPED EYES</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*GgnwiuFI79lNXP6afTOdAQ.png" /></figure><p>In the above table, JavaScript Representation of SMILING FACE WITH HEART-SHAPED EYES is <strong><em>\uD83D\uDE0D</em></strong>, it has two UTF-16 bit unicodes. Individually \uD83D or \uDE0D alone doesn’t represent any character, it should be escaped instead of showing junk characters. for more about unicode representation refer <a href="https://codepoints.net/">here</a>.</p><p><strong>ES6:-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/0*A90zODslQooTMlZi" /></figure><p><strong>ES10:-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/0*4wdRTwGS8L1AOULh" /></figure><p><strong>Function.prototype.toString():-</strong></p><p>Newly revised to string method will not remove space and lines from source code for functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKwOyrQEEtl8Hse14boM3Q.png" /></figure><p>For all the built-in, Built-in, bound functions, it should return <strong>NativeFunction</strong> string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/0*Ff-Wy096n9jEknrs" /></figure><p>For dynamically creating function, it should synthesise the source text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_4xEQLRz50Wsv9b_c3LZQ.png" /></figure><p><strong>String:-</strong></p><p>Two new methods have added to trim a string.</p><ol><li>String.prototype.trimStart()</li><li>String.prototype.trimEnd()</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/0*LZbiiR72J1MHrCxH" /></figure><p><strong>Symbol:-</strong></p><p>As we know Symbol is built in datatype for unique values and it is used as keys for object, Symbol.iterator and so on, a new Symbol.prototype.description is added to get description from symbol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/0*Uru5VIRSWyrBmnl1" /></figure><p><strong>Object:-</strong></p><p>A new static method Object.fromEntries is added to Object.</p><p>To be specific, it converts array of arrays(Array which has nested arrays in it) in to Object, Let’s see, how is it working.</p><p>Example:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V3TivlQaAbbXAxx_" /></figure><p>In above example, array data can be converted to object key value pairs. After looking above example few questions may raise in our head. let’s try to list.</p><ol><li>What if, Array doesn’t have any array inside?</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/0*KFbTpH4tAQd0ziSV" /></figure><p>Apparently, it applies only to arrays which are having nested arrays. it converts arrays to objects with only first two elements which is at index 0 and 1, ignore other elements.</p><p>2. What if, Nested arrays have more than 2 elements in it?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*sdvnAnF3jXf-V1DM" /></figure><p>3. What if, Array inside arrays contains objects?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dOvvGS7hvWGGjibm" /></figure><p>Instead of object as key, we can use strings to construct pragmatic javascript objects.</p><p><strong>Arrays:-</strong></p><p>Two methods has added.</p><ol><li>Array.prototype.flat</li><li>Array.prototype.flatMap</li></ol><p>Array.prototype.flat:-</p><p>It is originally proposed as Array.prototype.flatten, flattens arrays recursively up to the specified depth, which defaults to 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/0*rRBRqN29XH5gcO1O" /></figure><p>Array.prototype.flatMap:-</p><p>Combined flatten and map behaviour for arrays. Flatten the result in to single array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*V3qe2_-tFmUh_sj2" /></figure><p><strong>Conclusion:-</strong></p><p>As we know, ECMAScript standards are used in various programming languages like Microsoft’s JScript, Oracle Nashorn Engine, it is strictly based on the language engine to choose which standard to support. let’s keep an eye on TC39 proposal for latest updates.</p><p>Thanks for reading!!!</p><p>Please feel free to comment your suggestions.</p><p><strong>Reference:-</strong></p><ul><li><a href="https://github.com/tc39/proposals">GitHub - tc39/proposals: Tracking ECMAScript Proposals</a></li><li><a href="https://developers.google.com/web/updates/2018/03/smooshgate">#SmooshGate FAQ | Web | Google Developers</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a22f524d5a9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeengineer/es2019-ecmascript2019-features-2a22f524d5a9">ES2019(ECMAScript2019) Features</a> was originally published in <a href="https://medium.com/codeengineer">Tech Tackle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Local variables Type Inference in Java]]></title>
            <link>https://medium.com/codeengineer/var-in-java-b2a647104ee3?source=rss----10791b52f715---4</link>
            <guid isPermaLink="false">https://medium.com/p/b2a647104ee3</guid>
            <category><![CDATA[java12]]></category>
            <category><![CDATA[java11]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Prabu Subra]]></dc:creator>
            <pubDate>Wed, 02 Jan 2019 07:06:50 GMT</pubDate>
            <atom:updated>2019-03-26T11:16:16.583Z</atom:updated>
            <content:encoded><![CDATA[<p>To be short, This post is about a type called <strong>var</strong>, which is introduced in java 10. Before started using var type, i have analysed and summarised about where to use and not to use var type like as an argument for methods, constructors, Exceptions, lambdas, Streams, etc…</p><p><strong>what is var ?</strong></p><p>It<strong> </strong>is<strong> </strong>used to declare local variables and reduces the boilerplate code.</p><p><strong>Is it a new keyword introduced in java ?</strong></p><p>The answer is big <strong>No</strong>, it is not a keyword, a new type called var has created to improve type inference.</p><p><strong>Is java becoming dynamic type language like JavaScript ?</strong></p><p><strong>No</strong>, Added an intelligent for compiler to understand the type of the local variable using its initializer without specifying explicitly.</p><p><strong>How are the possible ways to declare local variables?</strong></p><p>Examples:-</p><pre>List&lt;String&gt; list = new ArrayList&lt;String&gt;(); // level 1</pre><pre>List&lt;String&gt; list = new ArrayList&lt;&gt;(); // level 2</pre><pre>var list = new ArrayList&lt;String&gt;(); // level 3</pre><p>There are the places to use and not to use. Lets see few of that.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ec5bb4e4f4cb9b28475b85314dbb092/href">https://medium.com/media/6ec5bb4e4f4cb9b28475b85314dbb092/href</a></iframe><p>Law of var:-</p><p>Properly initialized, Non-array variables can use the luxury of type inference.</p><p>Summary:-</p><p>Eventually, Java has added few spoons of sugar to an existing Type Inference feature. it is not completely freed developers hands to use var in code, it comes with its own laws. Type inference is not completely new feature in java, it has improved a step to use for local variables,mostly to avoid boilerplate code with less upgrade hurdles. The target source code base shouldn’t contains class or interface, which was named as var and possibility also rare, nearly nothing. It is one of the way(not only way) to declare local variables.</p><p>Reference:-</p><ul><li><a href="http://openjdk.java.net/jeps/286">JEP 286: Local-Variable Type Inference</a></li><li><a href="https://docs.oracle.com/javase/tutorial/java/generics/genTypeInference.html">Type Inference (The Java™ Tutorials &gt; Learning the Java Language &gt; Generics (Updated))</a></li><li><a href="https://github.com/prabusubra/Learning/blob/master/Java/JShell/jshell.txt">prabusubra/Learning</a></li></ul><p>Note:- if you feel something has to be added or wrong, feel free to comment below. Thanks for reading!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2a647104ee3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeengineer/var-in-java-b2a647104ee3">Local variables Type Inference in Java</a> was originally published in <a href="https://medium.com/codeengineer">Tech Tackle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Under the hood: understanding docker Containers and images]]></title>
            <link>https://medium.com/codeengineer/understanding-docker-containers-and-images-af40f229ecb3?source=rss----10791b52f715---4</link>
            <guid isPermaLink="false">https://medium.com/p/af40f229ecb3</guid>
            <category><![CDATA[dockerfiles]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[linux-kernel]]></category>
            <dc:creator><![CDATA[Prabu Subra]]></dc:creator>
            <pubDate>Thu, 22 Nov 2018 16:10:31 GMT</pubDate>
            <atom:updated>2019-02-25T10:59:03.010Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Containers</strong> — A technology to run one or more than one <strong><em>process </em></strong>on an independent and isolated environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*6uEk36bQi4O6S0upkauc1A.png" /><figcaption>docker</figcaption></figure><p>What are <strong><em>process </em></strong>here?</p><p>Execution of programs(set of instructions). It could be applications, databases, message queues, etc…</p><p>What are resources needed to execute a process standalone?</p><ul><li>Memory</li><li>CPU</li><li>I/O devices</li><li>Files Systems</li></ul><p>In our day to day life, we use the containers without knowing it. For example Parallel Space/Secondary space and Dual apps features in Android mobiles are using Linux Container technology.</p><p>In Linux kernel, we have options to create more than one parallel space and run processes in it, like jail, These are called as containers.</p><p>Linux kernel features behind containers:-</p><p>Using linux Kernel features like <strong>Namespace</strong>, <strong>Cgroup, chroot </strong>and <strong>UnionFS, </strong>host Linux kernel can split it’s resources and provide the isolated space to run a process.</p><p><strong>Namespaces </strong>→ This feature isolates below terms from host and other containers.</p><ul><li><strong>Mount </strong>— isolate <strong>filesystem </strong>mount points.</li><li><strong>UTS </strong>— isolate <strong>hostname </strong>and domain name.</li><li><strong>IPC </strong>— isolate interprocess communication (IPC) resources.</li><li><strong>PID </strong>— isolate the PID number space.</li><li><strong>Network </strong>— isolate network interfaces.</li><li><strong>User </strong>— isolate UID/GID number spaces.</li></ul><p><strong>Cgroups </strong>→ limits resources like CPU, memory, network...</p><p><strong>Chroot </strong>→ change the root directory for specified process and its child processes.</p><p><strong>UnionFS </strong>→ layered File system. docker images are created as immutable layer and data are persisted on mutable layer. Mutable layer can be mount to local storage or external cloud store. it help for effective reuse of docker image and data management.</p><p>If containers share host operating systems, then</p><p><strong>Why do we have operating system images(Container OS) on docker registries?</strong></p><p>Even though Containers are running on same machine, OS utilities and libraries are not available, because of its isolation(Namespace). So Containers cannot access softwares installed on Host OS. so we have to configure required software for each docker container as docker image in Dockerfile.</p><p><strong>What exactly is operating systems image(Container OS)?</strong></p><p>These images are not full fledged Operating systems, just a bunch of utilities/libraries.</p><p>Therefore, To run a container, we just need to load few utilities and libraries not entire operating systems.</p><p>Docker Container CLIs:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*jK3q1sAWjES0W6PwTfqJOA.png" /><figcaption>docker container cli</figcaption></figure><p><strong>Images</strong> — A blueprint or template, from which one or more than one containers can be created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*wpvOzSALb04tJF-5BDb-Ow.png" /></figure><p>Most of the images are build based on Scratch image. It is like super parent image. Scratch doesn’t have any utility, it is empty image with zero size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*1qD9P7gIb9EtmdrphtVYpA.png" /></figure><p><strong>Docker image CLIs:-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*Wt-SD135Y0V9KO39pnvzaQ.png" /><figcaption>docker image cli</figcaption></figure><p><strong>Dockerfile:-</strong></p><p>Docker image is created from Dockerfile. it has a set of vocabularies to execute processes with its dependencies independently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*TdL30kqOgK5lukxzhiS0dw.png" /></figure><p>Eventually, using container technology software can be created/changed, packed, tested and shipped quicker with less hurdles than traditional ways. It simplifies software business. programmable Platform (PaaS) accelerate software development and deployment(SaaS).</p><p>Thanks for reading… This is my understanding after using docker for few months. Feel free to comment your suggestions !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af40f229ecb3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeengineer/understanding-docker-containers-and-images-af40f229ecb3">Under the hood: understanding docker Containers and images</a> was originally published in <a href="https://medium.com/codeengineer">Tech Tackle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reactive Sprint boot application using Spring WebMVC and WebFlux]]></title>
            <link>https://medium.com/codeengineer/sprint-boot-application-using-spring-webmvc-and-webflux-d94672b70595?source=rss----10791b52f715---4</link>
            <guid isPermaLink="false">https://medium.com/p/d94672b70595</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[spring-training]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <dc:creator><![CDATA[Prabu Subra]]></dc:creator>
            <pubDate>Wed, 15 Aug 2018 14:42:48 GMT</pubDate>
            <atom:updated>2018-09-06T07:58:33.881Z</atom:updated>
            <content:encoded><![CDATA[<p>A Spring Boot application can be written in</p><ul><li><strong>Imperative style(Spring WebMVC)</strong> or</li><li><strong>Functional Style(Spring WebFlux)</strong>.</li></ul><p><strong>What is Reactive Spring Boot application?</strong></p><p>It is a implementation of reactive streams(i.e sequence of data pushed from source to subscribers with back pressure), which are non-blocking, asynchronous and event-driven by nature. Spring Reactive libraries are build as part of Project Reactor <a href="https://projectreactor.io/">projectreactor.io</a>.</p><p><strong>What is imperative style?</strong></p><p>It is not imperative programming, just a imperative style of programming. it means Reactive Spring boot application can be written using sprint mvc annotations, so with minimum modifications, the old, legacy, big applications can also be converted to reactive nature and can use its features and benefits.</p><p><strong>What is declarative style?</strong></p><p>It is the latest functional lambda style of programming, This suits for applications which are starting from scratch.</p><p>let move further…</p><p>Recently, I have converted a project from Spring webmvc to webflux style. Initially, i faced few difficulties to understand and use WebFlux Routers, Handlers and lambda functions, so i thought, writing a flat and simple webmvc controllers and its equivalent webflux Routers in a single page may simplify the understanding and broke the confusions around it.</p><ol><li>As of now, The Spring boot supports either Spring WebMVC or WebFlux style, it is like… this or that, not a mix of both in a single application. so <strong><em>you</em></strong> <strong><em>shouldn’t have RestController annotation or spring-boot-starter-web dependency in pom.xml.</em></strong></li><li>REST endpoint should be defined on Configuration annotated class as a Bean of RouerFunction, Neither as a RestController nor Controller annotations.</li></ol><p>Spring webflux is a programming paradigm used to compose Spring Boot applications on functional style(declarative style) using lambda functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b7EFW7REaAXfmuuOKdvxEA.png" /><figcaption>Spring MVC to WebFlux</figcaption></figure><p>lets see some code on each model. i have used below bean and written few GET/POST/DELETE Rest endpoints.</p><p>Bean:-</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a95cb40d2c45f3a77ed6a3394fc7350c/href">https://medium.com/media/a95cb40d2c45f3a77ed6a3394fc7350c/href</a></iframe><p>REST end points in Spring Web-MVC:-</p><p>Here everything is defined using annotations.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b97e6d3eaa4b9a0dae9e80f46d82d2f/href">https://medium.com/media/6b97e6d3eaa4b9a0dae9e80f46d82d2f/href</a></iframe><p>REST endpoints in Spring WebFlux:-</p><p>Few bunch of annotations are replaced with lambda functions, Not all the annotations. it is working with combination of annotations and lambda functions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1658b4ea18dc27521783c2ceb9d2df91/href">https://medium.com/media/1658b4ea18dc27521783c2ceb9d2df91/href</a></iframe><p>For better re usability/structure of code, we can have a dedicated handler and utility classes as Spring Component or Service.</p><p>Conclusion:-</p><p>Eventually, Controller becomes Router. Request and Response related annotations become lambda functions, it may look like Spring framework is moving towards lambda function based configurations (XML → Annotations → lambda functions). but still annotations are playing huge role, even RouterFunction itself configured with Configuration and Bean annotations.</p><p>Refer the below git hub repository for code.</p><p><a href="https://github.com/prabusubra/microservicelearning">prabusubra/microservicelearning</a></p><p>Thanks for spending your time!!! Feel free to comment your views or suggestions…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d94672b70595" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeengineer/sprint-boot-application-using-spring-webmvc-and-webflux-d94672b70595">Reactive Sprint boot application using Spring WebMVC and WebFlux</a> was originally published in <a href="https://medium.com/codeengineer">Tech Tackle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streams in Java 8]]></title>
            <link>https://medium.com/codeengineer/stream-in-java-8-81e0a3cc79d6?source=rss----10791b52f715---4</link>
            <guid isPermaLink="false">https://medium.com/p/81e0a3cc79d6</guid>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Prabu Subra]]></dc:creator>
            <pubDate>Thu, 12 Jul 2018 16:32:55 GMT</pubDate>
            <atom:updated>2018-07-12T16:33:26.875Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Streams!!!</strong> A Java Interface to perform certain set of operations on bunch of items/data/elements serially or parallel.</p><p>It is a functional or declarative style of programming in java. streams doesn’t store any data with it so we can’t get a data by address or index.</p><p>Streams can be created on Collections, Arrays, or I/O resources.</p><p><strong>Mode of Streams:-</strong></p><p>The way of creation of initial stream will result 2 different streams. it can be Serial or Parallel.</p><ol><li>Serial → streams()</li></ol><p>it just work like for loop, one by one on single thread.</p><p>2. Parallel → parallelStream()</p><p>it will run on multiple threads.</p><pre>import java.util.ArrayList;<br>import java.util.List;<br><br>public class StreamsUnderstanding{<br><br>    public static void main(String[] args) {<br>        List&lt;Integer&gt; productList = new ArrayList&lt;Integer&gt;();<br>        productList.add(1000);<br>        for (int i = 0; i &lt; 6; i++) {<br>            int lastvalue = productList.get(i);<br>            productList.add(lastvalue+1000);<br>        }<br>        <br>        System.out.println(&quot;Input List --&gt; &quot;+productList);<br>        <br>        List serialList = new ArrayList();<br>        productList.stream().filter(p-&gt;p&gt;3000).forEach(s-&gt;{<br>              System.out.println(&quot;Thread Name --&gt; &quot;+Thread.currentThread().getName());<br>                serialList.add(s);<br>            });<br>        System.out.println(&quot;Serial Stream --&gt; &quot;+serialList);<br>        List parallelList = new ArrayList();<br>        productList.parallelStream().filter(p-&gt;p&gt;3000).forEach(s-&gt;{<br>             System.out.println(&quot;Thread Name --&gt; &quot;+Thread.currentThread().getName());<br>                parallelList.add(s);<br>            });<br>        <br>         System.out.println(&quot;Parallel Stream --&gt; &quot;+parallelList);<br>        }<br>    }</pre><pre>--------------------------------------------------------------------<br>Output:-<br>--------------------------------------------------------------------<br>Input List --&gt; [1000, 2000, 3000, 4000, 5000, 6000, 7000]</pre><pre>Thread Name --&gt; main<br>Thread Name --&gt; main<br>Thread Name --&gt; main<br>Thread Name --&gt; main</pre><pre>Serial List --&gt; [4000, 5000, 6000, 7000]</pre><pre>Thread Name --&gt; ForkJoinPool.commonPool-worker-3<br>Thread Name --&gt; ForkJoinPool.commonPool-worker-3<br>Thread Name --&gt; main<br>Thread Name --&gt; ForkJoinPool.commonPool-worker-2</pre><pre>Parallel List --&gt; [5000, 4000, 6000, 7000]</pre><p>Conversion of Streams:-</p><p>After the initial creation of Streams, it can be converted from Parallel to Sequential or vice versa..</p><pre>/**<br>* sequential() - will convert Parallel stream to Serial Stream.<br>* parallel() - will convert Serial stream to Parallel Stream.<br>**/</pre><p><strong>Stream Operations:-</strong></p><ol><li>Intermediate</li><li>Terminal</li></ol><p>Intermediate Operations:-</p><ul><li>it will return a new stream always.</li><li>Statefull(Maintain whether visited or not) and stateless</li><li>It is lazy</li></ul><p>Terminal Operations:-</p><p>1. it is eager.</p><p>2. when the terminal operator is initiated stream pipeline will be executed sequentially or parallel.</p><p>Stream Pipeline:-</p><p>A stream pipeline consists of a source (such as a Collection, an array, a generator function, or an I/O channel); followed by zero or more intermediate operations such as Stream.filter or Stream.map; and a terminal operation such as Stream.forEach or Stream.reduce.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*BWWxGPN1igiPib9ao7yf0g.png" /><figcaption>Stream Pipeline</figcaption></figure><p>Short-Circuits in Streams:-</p><p>Streams has couple of methods to disturb normal flow of intermediate and terminal operations. Examples:- limit(), findFirst(), findAny().</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81e0a3cc79d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codeengineer/stream-in-java-8-81e0a3cc79d6">Streams in Java 8</a> was originally published in <a href="https://medium.com/codeengineer">Tech Tackle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>