<?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 André Nunes on Medium]]></title>
        <description><![CDATA[Stories by André Nunes on Medium]]></description>
        <link>https://medium.com/@cnandre.nunes?source=rss-498de433e038------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*d3nnaWn-gd3UuyaUfsRqOg.jpeg</url>
            <title>Stories by André Nunes on Medium</title>
            <link>https://medium.com/@cnandre.nunes?source=rss-498de433e038------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 09:47:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cnandre.nunes/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[Simplify Your Java Code With Functional Programming: Quick overview]]></title>
            <link>https://blog.devgenius.io/simplify-your-java-code-with-functional-programming-quick-overview-856f016f5600?source=rss-498de433e038------2</link>
            <guid isPermaLink="false">https://medium.com/p/856f016f5600</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[functional-programming]]></category>
            <dc:creator><![CDATA[André Nunes]]></dc:creator>
            <pubDate>Wed, 03 Jun 2020 00:25:30 GMT</pubDate>
            <atom:updated>2020-06-03T18:59:24.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*k3LuFvJNudJ9U5Vk1OA_kw.png" /></figure><p>You may have heard about functional programming, it’s a programming paradigm like many others. Functional programming is a style of programming that helps us to implement some tasks in a really easy and robust way.</p><h3><strong>Lambda Expressions</strong></h3><p>Lambda expressions were added to Java in 2014 together with Java 8 version. Simply put, a Java lambda expression is a function which can be created without belonging to any class and express an instance of a functional interface.</p><h3><strong>Functional Interface</strong></h3><p>Basically, in Java a functional interface is an interface with only a single abstract method. There many functional interfaces in Java World like Runnable, ActionListener, Comparable.</p><p>Since Java 8 we have a package called <a href="https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html"><strong><em>java.util.function</em></strong></a> which provides some predefined functional interfaces to help us write common tasks.</p><p>In this article I’m going to present the following 4 types of functional interfaces:</p><ol><li><strong>Consumer Interface</strong></li><li><strong>Supplier Interface</strong></li><li><strong>Function</strong></li><li><strong>Predicate</strong></li></ol><h3><strong>Consumer Interface</strong></h3><p>A consumer interface represents an operation that takes only one argument and doesn’t return any value. There are a lot of methods that expect a consumer interface. Below you can see in the official documentation that it has only one abstract method called accept(T t) with no returned value.</p><p><strong><em>Usage</em></strong></p><p>Here is an example of how we can make the use of a consumer interface to iterate over a list of elements and to turn your code into a declarative style.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a1f90b90705c0eb4ee1afffb26f1ce1/href">https://medium.com/media/5a1f90b90705c0eb4ee1afffb26f1ce1/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c752ea48851b44488cf49d088fb9abf/href">https://medium.com/media/0c752ea48851b44488cf49d088fb9abf/href</a></iframe><p>The forEach method has a consumer function as a parameter, so we can simply pass an anonymous function as an argument.</p><h3><strong>Supplier Interface</strong></h3><p>The supplier interface is the opposite of the consumer interface, since it supplies a value instead of consume a value. Below you can see in the official documentation that it has only one abstract method called get() which returns a value of type T.</p><p><strong><em>Usage</em></strong></p><p>Here is an example of how we can make the use of a supplier interface to generate a random value. The supplier interface also has few specializations for work with primitive values, as you can see below, it’s better to use these specializations whether working with primitive values to avoid paying the cost of autoboxing/unboxing.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/470559302004ba113f5b51016d67b2f3/href">https://medium.com/media/470559302004ba113f5b51016d67b2f3/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce971cf8ee41f711ea0430a93e75a39e/href">https://medium.com/media/ce971cf8ee41f711ea0430a93e75a39e/href</a></iframe><h3><strong>Function</strong></h3><p>A Function interface represents a function with just one argument and returns a value. Below you can see in the official documentation that it has only one abstract method called apply(T t) which takes a value of type T as an argument and returns a value of type R. It&#39;s also has a method called andThen() that takes a Function as an argument and returns a Function as a result, using this method we can split our code into small pieces and then combine them together.</p><p><strong><em>Usage</em></strong></p><p>Here is an example of how we can make the use of a Function interface to pass an Integer as an argument and return its half as a Double value, then we combine the result with another Function that takes a Double as an argument and adds 10, then return as Doublevalue.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c679ccfb2a78ad419d0bd6fb363c9e2/href">https://medium.com/media/2c679ccfb2a78ad419d0bd6fb363c9e2/href</a></iframe><h3><strong>Predicate</strong></h3><p>A predicate interface represents a function with just one argument and returns a boolean value. Predicate has thousands of applications, for example, we can use it to filter some data. Below you can see in the official documentation that it has only one abstract method called test(T t) which takes an object of type T as an argument and returns a boolean. It also has more two methods called and(Predicate&lt;? super T&gt; other) and (Predicate&lt;? super T&gt; other) that takes a Predicate as an argument, so we can use it to combine and build more complex predicates.</p><p><strong><em>Usage</em></strong></p><p>Here is an example of how we can make the use of a Predicate Interface to check whether a number is greater than 18 and then check if its lower than 30.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82aa91c47ee45531df2624888b1a647e/href">https://medium.com/media/82aa91c47ee45531df2624888b1a647e/href</a></iframe><h3><strong>Conclusion</strong></h3><p>In this article, I tried to present 4 different functional interfaces in Java 8 that can be used as lambda expressions and brings a lot of flexibility and readability to our code. We can use the power of functional interfaces in different situations in real-world applications.</p><p>There are more Functional interfaces in the package java.util.function to you to explore and have fun. <a href="https://docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html"><strong><em>Check it out</em></strong></a></p><p>I hope that this quick overview helps you to understand it better.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=856f016f5600" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/simplify-your-java-code-with-functional-programming-quick-overview-856f016f5600">Simplify Your Java Code With Functional Programming: Quick overview</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of Big O Notation]]></title>
            <link>https://medium.com/analytics-vidhya/basics-of-big-o-notation-7bee55d3239a?source=rss-498de433e038------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bee55d3239a</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[André Nunes]]></dc:creator>
            <pubDate>Mon, 13 Apr 2020 22:08:06 GMT</pubDate>
            <atom:updated>2020-04-16T16:54:41.217Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Big O Notation" src="https://cdn-images-1.medium.com/max/1024/1*83pmpWYG2drQacgCGzpeUA.png" /></figure><p>If you desire to work as software engineer for a great company and you are looking for a medium/senior job, it is inevitable to face some algorithms assignments and also face a common question during interview process: `what is big O notation?`. Learn about algorithms is an important skill to develop to become a better software developer, it will help you to think before start coding, how to design your solution and undoubtedly will help you when you go for a technical interview of that company you want so much.<br>I must say that for a long time in my career I avoided this subject, basically because I thought it was feared, useless and confusing topic for me. In the course of time I realized how important it is to solve many different kind of problems and how we use algorithms intuitively and automatically on daily basis. <br>In this article I would like share what I learned about Big O Notation to define the complexity of our algorithms and how it is used for, with a little code example.</p><h3>The Big O Notation</h3><h4>What is Big O ?</h4><blockquote><a href="https://en.wikipedia.org/wiki/Big_O_notation"><strong>Big O notation</strong> is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity.</a></blockquote><p>Simply put, we use Big O to describe the performance of algorithm, it help us to define if an specific algorithm is scalable or not as the input data set grows. When you are developing an algorithm, some operations can be more more costly than necessary depending the data structure you decided to use.<br>For example, access an array element by it’s index will be very fast, otherwise, arrays have a fixed size and if you need to alter the array by adding or removing elements it will get resized, these operations costs a lot of time if you have a large data set. So, in this case you need use a linked list, this kink of data structure can be resized in a super fast way, on the other hand, access the element of a linked list by index is very slow. <br>So, that that’s how Big O Notation comes to rescue, it defines the time complexity of an algorithm to help us to decide which data structure we should use.</p><h4><strong>O(1)</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9148822ec62adff8f695e5a04ca3106/href">https://medium.com/media/d9148822ec62adff8f695e5a04ca3106/href</a></iframe><p>In this example we have a method that prints the first element of an array, it doesn’t matter the size of the array, it could be an array of size 1 or 1 million numbers, that time complexity is going to be always the same, the number of operations to execute is going to be always 1. So, we represent it as <strong>O(1)</strong>, this is the run time complexity to execute the code, it’s constantly no matter the size of given array.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d8aeed8897815b53359a0a92f5682e2/href">https://medium.com/media/8d8aeed8897815b53359a0a92f5682e2/href</a></iframe><p>If we duplicate the operation, you could think that the time complexity would become <strong>O(2)</strong>, but when we think about runtime complexity it does not matter the number of operations, what matters is how the algorithm slows down as our input data grows up. In this case, the time complexity keep being <strong>O(1)</strong>.</p><h4><strong>O(n)</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19c6912015820730044e90f4050a4563/href">https://medium.com/media/19c6912015820730044e90f4050a4563/href</a></iframe><p>In this example, we are iterating over all elements in the given array and printing it, so, the array’s size really matters because as size increases the cost of the algorithm also increases, they have a correlation and the cost increase <strong>linearly</strong>. In this case we represent it as <strong>O(n)</strong> where <strong>n</strong> is the size of our input data set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04d65acf4873938d95a16830c9919aef/href">https://medium.com/media/04d65acf4873938d95a16830c9919aef/href</a></iframe><p>Another example could be if we iterate over two different arrays, so, in this such scenario we could represent the run time complexity as <strong>O(n + m)</strong> but when we talk about time complexity we just looking for a approximation of the cost of the algorithm relatives to it’s input size. Since the run time complexity of the algorithm still increases <strong>linearly</strong>, we could simply represent it as <strong>O(n)</strong>.</p><h4><strong>O(n²)</strong></h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65faca988856846067d66a6fc00b13b9/href">https://medium.com/media/65faca988856846067d66a6fc00b13b9/href</a></iframe><p>When we are dealing with nested loops we say that the algorithm run in <strong>quadratic</strong> time, this kind of algorithm is slower than the ones that runs in <strong>O(n)</strong>, as the input data set increases we can really see the time difference between this two.</p><p>In the below example we have another loop after first operations, this could be represented as <strong>O(n² + n)</strong>, but we can simplify it, because all we need is an approximation of the cost of the algorithm, in this case, <strong>n²</strong> will always grows faster than <strong>n</strong>, so, we can delete <strong>n</strong> and say that this algorithm runs in <strong>O(n² )</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/efbd113cc45436bc1218defe8f220b95/href">https://medium.com/media/efbd113cc45436bc1218defe8f220b95/href</a></iframe><h4>O (log n)</h4><p>A perfect example of an algorithm that runs in <strong>O(log n)</strong> is a binary search algorithm. It’s is too complex to bring an example of code here, but this kind of algorithm runs in logarithmic time and it’s much more efficient and scalable than algorithms that runs in linear time.</p><blockquote><a href="https://en.wikipedia.org/wiki/Logarithm">In mathematics, the logarithm is the inverse function to exponentiation</a></blockquote><p>So, when a algorithm grows logarithmically, it means that you are dividing the number of operations need to reach the expected result in relation to the size of input data set.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9a4b2b56273fcce70a603ee7b286224/href">https://medium.com/media/a9a4b2b56273fcce70a603ee7b286224/href</a></iframe><p>In practice, imagine that we have this sorted array and we need to find the position of number 7. Using binary search algorithm we would start looking at the middle of the array, which is number 4, if this was the number you were looking for, the algorithm would finished with just 1 operation. Unfortunately, this is not the number we need, so, as number 7 is greater than 4, we know that it must be in the right partition of this array and we can put away the left part, now we can restrict our search just by half and keep repeating the same process until we find it. On each operation we split the size of array by half and if we have millions of numbers we could find the number we looking for with jut few operations, with this approach it’s turns our algorithm very scalable.</p><h4>O(2^n)</h4><p>This is called <strong>exponential</strong> growth, it’s the opposite of logarithmic. Exponential time complexity grows faster and faster as the input data set increases. Algorithms that runs with this time complexity are not scalable and it become very slow if we have a large input data set.</p><p><strong>Ranking of time complexity:</strong></p><p>Here we have a ranking of the times of complexity ordered from the fastest to the slowest. There are another growth rates that you can use but these are the most common.</p><ol><li>Constant <strong>O(1)</strong><br>2. Logarithmic <strong>O(log n)</strong><br>3. Linear <strong>O(n)</strong><br>4. Quadratic <strong>O(n²)</strong><br>5. Exponential <strong>O(2^n)</strong></li></ol><h4>THANKS FOR READING!</h4><p>The purpose of this article was to share in a simplified way what I understand about Big O Notation and how important it is, so if I made a mistake, don’t hesitate to leave a comment.</p><p><strong><em>If you like this, leave a clap!!!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bee55d3239a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/basics-of-big-o-notation-7bee55d3239a">Basics of Big O Notation</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>