<?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 Vladimir Jovanović on Medium]]></title>
        <description><![CDATA[Stories by Vladimir Jovanović on Medium]]></description>
        <link>https://medium.com/@VladimirWrites?source=rss-d5bfb69f8b5d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZLGL1XXKsxxE3h20gJ7IaA.jpeg</url>
            <title>Stories by Vladimir Jovanović on Medium</title>
            <link>https://medium.com/@VladimirWrites?source=rss-d5bfb69f8b5d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 07:43:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@VladimirWrites/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[Firebase Predictions ]]></title>
            <link>https://proandroiddev.com/firebase-predictions-79f1594918fe?source=rss-d5bfb69f8b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/79f1594918fe</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[firebase-predictions]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Vladimir Jovanović]]></dc:creator>
            <pubDate>Sun, 24 May 2020 11:41:27 GMT</pubDate>
            <atom:updated>2020-05-24T11:43:18.372Z</atom:updated>
            <content:encoded><![CDATA[<h4>Predict user behavior and react to it!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FVuI3RyCutjHRTQs4dZqIw.png" /></figure><p>Firebase provides a wide variety of tools, something for every developer and something for every problem. But did you know that it has a tool that enables you to see into the future 🔮😮?! Yes, you heard me right, the tool called Firebase Predictions enables you to predict future actions of your users.</p><p>A lot of Android developers have never heard of Firebase Predictions or never used it, and this article will serve as a quick introduction. Apart from that, I will also explore some of the retention and monetization strategies that this tool makes possible.</p><p>To be able to start using Firebase Predictions, you need to have Firebase Analytics integrated into your app. What Firebase Predictions does is apply machine learning on your analytics data and create user segments depending on how likely those users are to execute a specific action within the next seven days. In other words, for every analytics event, it can give you a group of users who are most likely and a group of users who are least likely to execute that event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*G1HA1hgXQKjwxIkyW1Vs-g.gif" /></figure><p>Now armed with that knowledge, you can react to your users&#39; anticipated actions and needs using other Firebase tools to always stay one step ahead.</p><p>You have the option to use Remote Config and adjust user experience for specific user segments, or to use push notifications and in-app messages to inform those users about new deals tailored just for them.</p><h3>Retention and Monetization Strategies</h3><p>The best way to present the power of Firebase Predictions is with an example.<br>Let’s say that we have an app that is selling something. That can be a product, subscription to a pro version of the app, or in-app currency. And let’s say that we are tracking this purchase event in Firebase Analytics.</p><p>Using Firebase Predictions we can assign the value to the users on how likely they are to make a purchase in the next seven days. Knowing this, we can start adjusting the behavior of the app for those users.</p><p>If the users are not likely to convert, we can explore other monetization strategies, for example ads. So, using Remote Config we can show ads to those users. If the users are a bit more likely to convert we can try nudging them by, for example, sending them vouchers using push notifications and in-app messages. And if the users are super likely to convert, we can just leave them alone, and make sure that they are not disturbed by ads and push notifications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*yl2SZlWiLdBlQBi7UFpyTw.png" /></figure><p>In a similar way, you can also employ a user retention strategy. The only difference is that, in this case, you would run a prediction on the app removal event and adjust the user experience depending on how likely the users are to uninstall your app.<br>Finally, you can run Firebase Predictions on any event, and since every app is unique make sure to explore different ways to improve your application using Firebase Predictions.</p><p>Now you&#39;re probably thinking: “This Firebase Predictions thing sounds amazing. So what’s the catch? How much does it cost?” The best thing about Firebase Predictions is that it’s completely free, and you can start using it today.</p><p>If you would like to learn more about Firebase Remote Config check out my Pluralsight course: <a href="http://pluralsight.pxf.io/xgdk1"><strong><em>Firebase on Android: Remote Config and A/B Testing</em></strong></a></p><p><em>Thanks for reading! If you enjoyed this story, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share it </em></strong><em>to help others find it! Feel free to leave a comment </em>💬<em> below.<br>Have feedback? Let’s be friends </em><a href="https://twitter.com/VladimirWrites"><em>on Twitter</em></a><em>.<br>This article was first published on </em><a href="https://vladimirj.dev/intentionally-left-empty/"><em>vladimirj.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79f1594918fe" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/firebase-predictions-79f1594918fe">Firebase Predictions 🔮</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[/* intentionally left empty */]]></title>
            <link>https://medium.com/@VladimirWrites/intentionally-left-empty-method-24246b2828df?source=rss-d5bfb69f8b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/24246b2828df</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[code-quality]]></category>
            <dc:creator><![CDATA[Vladimir Jovanović]]></dc:creator>
            <pubDate>Fri, 05 Apr 2019 12:29:56 GMT</pubDate>
            <atom:updated>2019-04-05T12:29:56.260Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_c7QqMOJmXlA5Kef58JtJw.png" /></figure><p><em>A long time ago somewhere in India empty spaces were creating a lot of problems. Numbers were being written without zeros, and believe me, it’s hard to write numbers when you replace zero with an empty space. <br></em><strong><em>11 </em></strong><em>and </em><strong><em>1 1 </em></strong><em>looked almost the same. That’s why zero was created.</em></p><p><em>In its early beginnings, zero meant </em><strong><em>“intentionally left empty”</em></strong><em>.</em></p><p>Let’s now travel back to the present, and see if empty spaces are causing trouble in the life of an average software developer. There are probably places in your code base where it’s not clear if something is a mistake or if it was left intentionally empty.</p><p>Sometimes we don’t need the implementation of initialize() in every child method, so we would just create an empty implementation instead of an abstract method.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/195063defcccb70caf1926c57fb13550/href">https://medium.com/media/195063defcccb70caf1926c57fb13550/href</a></iframe><p>I know that comments are not great, but in this case, I would suggest adding them. With the added comment, there is no confusion whether the empty method is a mistake or not.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99747e54d49173095223dfe5eea073a5/href">https://medium.com/media/99747e54d49173095223dfe5eea073a5/href</a></iframe><p>Another example when we need an empty method is when we want to omit the behavior of the parent’s implementation. This clearly breaks <a href="https://en.wikipedia.org/wiki/Liskov_substitution_principle">Liskov substitution principle</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*ToXLL1aet69THe2qxuwCmQ.jpeg" /><figcaption><em>Image courtesy of Derick Bailey</em></figcaption></figure><p>However, sometimes you can&#39;t control all the code that you are using, so you have to make compromises.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cef175403d152af16a9dac0444c067fa/href">https://medium.com/media/cef175403d152af16a9dac0444c067fa/href</a></iframe><p>Then, there are those notorious listener implementations, with a lot of methods that are usually not needed. Here is one example from the Android world:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eff47a07589f29dbe2295ac21b861631/href">https://medium.com/media/eff47a07589f29dbe2295ac21b861631/href</a></iframe><p>Finally, when working on a new feature, you can’t build it all at once. Inevitably, you will have parts of the code that are unfinished. This is not really a problem, it just needs to be clearly marked as unfinished with a simple TODO.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e05df71579a9cf5938eb73cb30ad3f65/href">https://medium.com/media/e05df71579a9cf5938eb73cb30ad3f65/href</a></iframe><p>Please don’t leave your methods empty. If the method is intentionally left empty, simply leave a comment for your fellow developers or for your future self.</p><p><em>Thanks for reading! If you enjoyed this story, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to leave a comment </em>💬<em> below.<br>Have feedback? Let’s be friends </em><a href="https://twitter.com/VladimirWrites"><em>on Twitter</em></a><em>.<br>This article was first published on </em><a href="https://vladimirj.dev/intentionally-left-empty/"><em>vladimirj.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24246b2828df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[tools:title=”RemoteSampleData”]]></title>
            <link>https://proandroiddev.com/android-remote-sample-data-cd87b4da590b?source=rss-d5bfb69f8b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd87b4da590b</guid>
            <category><![CDATA[mobile-ui-design]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-layout]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vladimir Jovanović]]></dc:creator>
            <pubDate>Sat, 10 Mar 2018 15:09:41 GMT</pubDate>
            <atom:updated>2018-04-11T07:39:37.521Z</atom:updated>
            <content:encoded><![CDATA[<p>What I’ve learned from my previous <a href="https://proandroiddev.com/android-studio-layout-preview-b7b229741ec1">article</a> is that the best way to gain new knowledge about a certain topic is to write about it. When I first wrote the article, I had no idea that you can create custom sampledata for your Android project. (If you don’t have a clue what sampledata is, please read <a href="https://proandroiddev.com/android-studio-layout-preview-b7b229741ec1"><em>tools:title=”LayoutPreview”</em></a>) And then someone sent me this:</p><p><a href="https://blog.stylingandroid.com/tool-time-part-2/">Tool Time - Part 2</a></p><p>It sounded like a really cool feature, so I made the list of my favourite characters from Lord of the Rings, used it as sampledata, and got this glorious layout preview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cZHVJzVAvIfQMI47DEZo1A.png" /></figure><p>Later on, I wanted to include it in my other projects, but the only option that I had was to copy/paste the sampledata from one project to another, and that didn’t make any sense. Then I did what every (lazy) developer would do, asked a question on StackOverflow.</p><p><a href="https://stackoverflow.com/questions/48874434/use-sample-data-directory-from-a-library">Use Sample data directory from a library</a></p><p>After 10 views and no answer in sight, I’ve decided to sacrifice a bit of my reputation and start a bounty. And it worked. I got my answer, which I will share with you.</p><p>To use sampledata between multiple projects you first have to host it and then have a Gradle script which will download it into your project’s sampledata folder. This is the code which does that:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9990b558cd74f1d7860c7004445382f4/href">https://medium.com/media/9990b558cd74f1d7860c7004445382f4/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aad326896d6dea2e340dfd9b532f6936/href">https://medium.com/media/aad326896d6dea2e340dfd9b532f6936/href</a></iframe><p>The first script will delete sampledata once you do clean build, and the second one will create sampledata folder in case it doesn’t exist, and then download sample files into it. It works like a charm and from now on you can go crazy with your layout previews. I know that from now on I will never again use @tools:sample/lorem/random.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRs5qWCaRL0rpaflBjwfZQ.png" /></figure><p>This code can be found in GitHub repo:</p><p><a href="https://github.com/VladimirWrites/tools-sample">VladimirWrites/tools-sample</a></p><p>I’ve also added some sample data, and will keep adding more. If you notice that something is missing or could be improved, feel free to contribute. This could be a great opportunity for novice developers to make their first contribution 😉.</p><p><em>Thanks for reading! If you enjoyed this story, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to leave a comment </em>💬<em> below.<br>Have feedback? Let’s be friends </em><a href="https://twitter.com/VladimirWrites"><em>on Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd87b4da590b" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/android-remote-sample-data-cd87b4da590b">tools:title=”RemoteSampleData”</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[tools:title=”LayoutPreview”]]></title>
            <link>https://proandroiddev.com/android-studio-layout-preview-b7b229741ec1?source=rss-d5bfb69f8b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7b229741ec1</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-layout]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-ui-design]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vladimir Jovanović]]></dc:creator>
            <pubDate>Sun, 18 Feb 2018 07:23:26 GMT</pubDate>
            <atom:updated>2020-05-23T09:29:10.116Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KE1HSefSP2PFKHOcATMyow.png" /></figure><p>As every Android developer, I also started building my layouts by hard-coding values into them. Later on, I have realized that I should probably extract them into resources. Next step was not to have values in layouts if they are going to be changed from the code (always keep the state of your view in code). But at that point, my layout preview got broken. The layouts were full of TextViews without texts, ImageViews without images, etc. And then I discovered the power of tools:. Fast forward one year and I had layouts full of tools:text=&quot;Test text&quot;, tools:text=&quot;Jake Wharton&quot;, tools:src=&quot;@drawable/ic_random_res&quot; … you get the point. Is there a better way to do this, you may ask?</p><p>Actually, there is. And it’s pretty easy. There are predefined sample resources that you can use to make your layout preview nice and clean. By using these, we can go from this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1729a610cef92850c64a440a358b0932/href">https://medium.com/media/1729a610cef92850c64a440a358b0932/href</a></iframe><p>to this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0653040c4abd732a8846fdb1ab741c34/href">https://medium.com/media/0653040c4abd732a8846fdb1ab741c34/href</a></iframe><p>And why is this better? If your TextView is inside a repeatable element like, for example, an item inside RecyclerView, and you set up your preview correctly, then your TextView will have a different text in every item. Speaking of RecyclerView, let’s make a deep dive into making a preview of your RecyclerView as sleek as possible, using this and some other tricks.</p><p>It all starts with a normal and rather ugly RecyclerView in your layout XML file. In a preview, it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_LdKfy3_FhtdYSClfRalQ.png" /></figure><p>It would look much nicer if we could show the real item used in our RecyclerView, and even more so if that item uses sample texts <em>tools:text=</em>”@tools:sample/lorem” and <em>tools:text=</em>”@tools:sample/lorem/random” for TextViews inside. And as a result, we get the following preview:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h07HZjRlaiMwdouPyVyOCg.png" /></figure><p>It looks much better, almost like a real application. The only problem is that our application in horizontal orientation has GridLayout with two spans. Can we do something in that regard? Of course, we can. By adding tools:layoutManager=”GridLayoutManager” and tools:spanCount=”2&quot;, we are getting exactly what we want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqjxF4AQWgs07NzvH3jXiA.png" /></figure><p>Well, almost. Our Activity has some menu items in the Toolbar, and if we could display these as well, it would be perfect. Accomplishing this isn’t really that difficult. Simply adding <em>tools:menu=</em>”menu_test” to the root element of your layout does the trick. It’s important to know that for this to work you need to have a predefined menu item @menu/menu_test.xml, and your Toolbar needs to be defined in a theme and not added in layout’s XML. The final result looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIn852IO79_vJaHKVdCPtg.png" /></figure><p>The final code looks like this (minus some margins, styles etc., that are removed to make it a bit more compact):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a3f4c7be91a6f288c0d6e28441978d2/href">https://medium.com/media/3a3f4c7be91a6f288c0d6e28441978d2/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6975de0aee7e4d3bc3bcb2dc828ea97d/href">https://medium.com/media/6975de0aee7e4d3bc3bcb2dc828ea97d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab9e3d8197b85c1db0018765b8f48263/href">https://medium.com/media/ab9e3d8197b85c1db0018765b8f48263/href</a></iframe><p>As you can see, tools: gives you great power to prototype and experiment with your layout without writing a single line of Java or Kotlin code or adding unnecessary states to your view’s XML. If you start using it now, you will have a much more pleasant time developing UI on your new project, and it will be a breeze to modify it later on.</p><p>Documentation for all tools attributes is available here:</p><p><a href="https://developer.android.com/studio/write/tool-attributes.html">Tools Attributes Reference | Android Studio</a></p><p>The full source code of this and some other examples can be found in the GitHub repository.</p><p><a href="https://github.com/VladimirWrites/tools-sample">VladimirWrites/tools-sample</a></p><p><em>Thanks for reading! If you enjoyed this story, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to leave a comment </em>💬<em> below.<br>Have feedback? Let’s be friends </em><a href="https://twitter.com/VladimirWrites"><em>on Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7b229741ec1" width="1" height="1" alt=""><hr><p><a href="https://proandroiddev.com/android-studio-layout-preview-b7b229741ec1">tools:title=”LayoutPreview”</a> was originally published in <a href="https://proandroiddev.com/">ProAndroidDev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Giving your code to the community]]></title>
            <link>https://medium.com/@VladimirWrites/giving-your-code-to-the-open-source-community-e7916b7f47a9?source=rss-d5bfb69f8b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7916b7f47a9</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Vladimir Jovanović]]></dc:creator>
            <pubDate>Sat, 11 Nov 2017 08:20:55 GMT</pubDate>
            <atom:updated>2018-04-11T07:55:22.015Z</atom:updated>
            <content:encoded><![CDATA[<h4>The hardest thing to give for free is your code. Why?!</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FU4teIjRowtTSU%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FU4teIjRowtTSU%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FU4teIjRowtTSU%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/9427820ead9037c5f67f879feae708d1/href">https://medium.com/media/9427820ead9037c5f67f879feae708d1/href</a></iframe><p>About two years ago, I started putting pieces of code on my <a href="https://github.com/VladimirWrites">GitHub page</a>. And soon I have noticed that nobody was looking at it. My profile was dead. At that point, I realized that there is no need for me to pay for <a href="https://github.com/blog/2164-introducing-unlimited-private-repositories">private repositories</a> 😄. And also, that people don’t want my code, not even for free.</p><p>And why was that?! I was clueless! But now, from this perspective, it’s pretty obvious. I had a horrible README and messy incomprehensible (even for me) code of an application that had very limited applicability. My code didn’t solve any problems that developers were facing and was hard to understand, so why would anyone use it?</p><p>You may be convinced that you are making it open-source for the community, but don’t fool yourself, you are selling your project. Maybe you are not asking for money, but you are not doing it for free either. Some do it for ⭐️🌟⭐️, some do it for fame, some do it to get a job at Google. All of us have different reasons, but we still have one common goal: to get people to use our code.</p><p>So if you want to get those users, you need to sell them your code. And to do that you need to approach it in the same way as you would if you were selling any other product. Make a valuable, quality product, place it in a nice-looking package, promote it, and make constant improvements to it. Easy! Right?!</p><p>It needs to bring some value to users, otherwise there is no reason for someone to use it. It may seem obvious, but this is the main reason behind most of the dead repos on GitHub. If you have a great, stable app, with fancy animations, and beautiful design, and you make it open-source, it may seem to you that you just made a contribution to the community. But if your app has unreadable code, or is hard to modify, or has a very specific use-case that’s not applicable to a lot of users; well, in that case, no one will use it.</p><p>None of us writes perfect code, but that’s not an excuse to write bad code. Code that you put into your open-source project should be the best that you were able to write at that point in time. Putting someone else’s code in your project brings huge risk, so your code needs to be pristine. That way, it will boost confidence in your product, and people will more likely contribute to it.</p><p>If you have a finished product, now it’s time to place it in a nice package, wrap it in a most beautiful wrapping paper that you have and tie the fanciest bow around it, or in our case you need to write a good README. This step will bring you the most value. README will be a <a href="https://en.wikipedia.org/wiki/Landing_page">landing page</a> for your product, so that’s the place where you sell it. That will be the first thing that people will see, and you have to make sure that it’s not the last. Make them stay.</p><p>The following step would be marketing, the arch enemy of every software developer. But in this case you have to do it, you have to be that marketing guy 🤢. I know, I know … but it’s not that hard. Show your product to people, promote your library/app as much as you can, and wherever you can. And that’s it.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl0IylR4JqKHLjaP60%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl0IylR4JqKHLjaP60%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl0IylR4JqKHLjaP60%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/c24b42b9203e71984f6861ba15dfbaf3/href">https://medium.com/media/c24b42b9203e71984f6861ba15dfbaf3/href</a></iframe><p>The final step would be to support it. Keep your project up-to-date, stable, fix bugs as fast as possible, listen to the community, and implement most requested features.</p><p>This is not some magical recipe, but following these steps should greatly improve your chance of having a successful product.</p><p>These are things that I have learned from my own mistakes. One thing that I still don’t know how to do is how to bring contribution to my projects. If you are an Android developer, and you would like to contribute to open-source, but are not sure where to start, check out my super cool <a href="https://github.com/VladimirWrites/Lemniscate"><em>Lemniscate</em></a><em> library</em>. It doesn’t have to be much, find a better name for one variable and I will be grateful.</p><p><em>Thanks for reading! If you enjoyed this story, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to leave a comment </em>💬<em> below.<br>Have feedback? Let’s be friends </em><a href="https://twitter.com/VladimirWrites"><em>on Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7916b7f47a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Firebase Dev Summit 2017  Amsterdam]]></title>
            <link>https://medium.com/@VladimirWrites/firebase-dev-summit-2017-amsterdam-464c6479126d?source=rss-d5bfb69f8b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/464c6479126d</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[conference]]></category>
            <category><![CDATA[summit]]></category>
            <dc:creator><![CDATA[Vladimir Jovanović]]></dc:creator>
            <pubDate>Sat, 04 Nov 2017 06:29:23 GMT</pubDate>
            <atom:updated>2018-04-11T07:50:22.797Z</atom:updated>
            <content:encoded><![CDATA[<h3><a href="https://firebase.google.com/dev-summit-17/">Firebase Dev Summit 2017</a> Amsterdam</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*OZUD0cZfYp3Ey7E0MnxsoQ.gif" /></figure><p>After spending a great weekend in Amsterdam and an even better Monday in picturesque towns of Volendam, Zaanse Schans, and Haarlem, on Tuesday I attended the Firebase Summit held at the magnificent concert hall named <a href="https://www.muziekgebouw.nl/informatie/english/">Muziekgebouw aan ‘t IJ</a>.</p><p>At the entrance I was greeted by the Firebase team with a free 👕. Afterwards, together with other Firebasers™, I had delicious breakfast 🥐🧀🍪 and some pitch-black ☕ (there was no milk 😞). While mingling with other people and strolling through the crowd, I was amazed by diversity of this year’s Firebase Summit. There were people from all over Europe, with all kinds of backgrounds, and all kinds of problems that Firebase was helping them to solve.</p><p>A bit later, doors of the mesmerizing Auditorium opened and the keynote began.</p><h3>Vladimir Jovanović on Twitter</h3><p>FirebaseSummit begins 🤩</p><p>What we could expect from this year’s summit was presented to us by <a href="https://medium.com/u/c2bf0f650f51">Sam Ramji</a>, Francis Ma, and <a href="https://medium.com/u/f9995e50edbc">Kristen Johnson</a>. There were a lot of new things that we were going to hear more about that day; Firebase Prediction, Firebase Crashlytics, Redesign of the console, new A/B testing framework, and much more.</p><p>The day was filled with great sessions, interesting ideas, and general positiveness 🙌. In my opinion, the highlight of the summit was the session “<em>Actionable insights with Firebase Predictions</em>” held by <a href="https://medium.com/u/323644fc16c8">Jumana Al Hashal</a> and Subir Jhanb. I had a great time being a lab 🐁 and choosing between 🇩🇰, 🇩🇲, 🇩🇴, 🐑, 🐘, 🦅.</p><h3>Vladimir Jovanović on Twitter</h3><p>Great talk about Firebase Predictions 7️⃣ 🇩🇰 🐘 by @objectivejay &amp;amp; @subirj at #FirebaseSummit 🔥</p><p>Firebase Predictions was by far the biggest announcement of the summit. This talk just scratched the surface of this topic and excited one’s imagination when it comes to all the new and undiscovered things that can be done using this powerful tool.</p><p>There were some great things to do between the sessions. You could go to the #AskFirebase lounge and speak with people who were behind all this Firebase magic. There, I had the opportunity to speak with Kat Fang and Jon Mensing about problems and new features of Firebase Android SDK as well as about the future of Firebase in general. Another way to kill the time between the sessions was to play <a href="https://appship3000.com/">AppShip3000</a>.</p><p>Of course, you could go crazy in the photo booth.</p><h3>Firebase Dev Summit on Twitter</h3><p>We&#39;re live at #FirebaseSummit in Amsterdam!</p><p>After the closing notes, there was a crazy party that I had to miss in order to catch my bus 😭. I hope that the next Firebase Summit will be at least as good as this one, and I also hope that I would be able to stay for the party next year.</p><h3>Vladimir Jovanović on Twitter</h3><p>Thank you @Firebase team for great day in beautiful Amsterdam at #FirebaseSummit</p><p>If you are interested to see in detail what happened at the Firebase Summit 2017, recordings of all the sessions can be found in this <a href="https://www.youtube.com/playlist?list=PLl-K7zZEsYLlTSrObc8GxDLarH7tF9WeW">playlist</a>.</p><p><em>Thanks for reading! If you enjoyed this story, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to leave a comment </em>💬<em> below.<br>Have feedback? Let’s be friends </em><a href="https://twitter.com/VladimirWrites"><em>on Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=464c6479126d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PRObably the Language Of God]]></title>
            <link>https://medium.com/@VladimirWrites/prolog-ce2b68b1778a?source=rss-d5bfb69f8b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce2b68b1778a</guid>
            <category><![CDATA[prolog]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Vladimir Jovanović]]></dc:creator>
            <pubDate>Tue, 24 Oct 2017 05:55:29 GMT</pubDate>
            <atom:updated>2019-03-22T18:24:47.020Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*5WdZRFMF5s_15nOUAxEDbg.png" /><figcaption>SWI-Prolog logo</figcaption></figure><p>During my university days, when I was studying Mathematics and CS, software development was a refreshment of applied science in a sea of theoretical math. But then in my 4th semester came <a href="https://en.wikipedia.org/wiki/Prolog">Prolog</a>. For those who hadn’t heard of Prolog, it’s the most inapplicable programming language in the universe (at least that’s what I thought). Created in the early 1970s, it was one of the first <a href="https://en.wikipedia.org/wiki/Logic_programming">logic programming</a> languages. It’s the most mathematical thing in the world of computer science.</p><p>Seven years after my first encounter with Prolog, I found some old .pl files, I opened them and was amazed that at one point in my life I had understood and more surprisingly had written those lines. So I decided to take one week of my life, and check again if Prolog is worth learning in the 21st century. At that point, I created <a href="https://github.com/VladimirWrites/PrologSamples">GitHub repository</a>, downloaded <a href="http://www.swi-prolog.org/download/stable">Prolog compiler</a>, and started.</p><p>The main building blocks of Prolog code are facts and rules. A fact is something like an <a href="https://en.wikipedia.org/wiki/Axiom">axiom</a>, a statement that is taken to be true. Meanwhile, a rule is analogous to a theorem, and its truthiness can be derived from facts.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ddc80f51071b818349a77a62d4e7e1e/href">https://medium.com/media/3ddc80f51071b818349a77a62d4e7e1e/href</a></iframe><p>These are the examples of a fact and a rule. The next step would be to load a file containing facts and rules into Prolog and make queries on it. For this case, the examples of queries would be:</p><pre>?- guitarist(&quot;Saul Hudson&quot;).<br>true.</pre><pre>?- musician(&quot;Saul Hudson&quot;).<br>true.</pre><pre>?- guitarist(X).<br>X = &quot;Saul Hudson&quot;.</pre><p>As you can see, guitarist does not behave like a function. That’s because it’s not a function, it’s a relation. Prolog is a relational programming language. To better explain this, let’s take a look at the following example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7562b0bdc2a0233b24f7c633ad60220/href">https://medium.com/media/a7562b0bdc2a0233b24f7c633ad60220/href</a></iframe><p>factorial defines a relation between some natural numbers. What does that mean? The fact factorial(1,1). means that 1 is in relation factorial with 1. And what about the second line?! Well, it can be read like this: “Numbers N and R are in relation factorial if N&gt;1 and N1 is N-1 and N1 and R1 are in relation factorial and R is N*R1” 😧. Could that be expressed in an understandable way?! In practice, it means that if you query this set of rules, you can calculate factorial.</p><pre>?- factorial(5,R).<br>R = 120 .</pre><pre>?- factorial(1,R).<br>R = 1 .</pre><pre>?- factorial(20,R).<br>R = 2432902008176640000 .</pre><p>These are a couple of beginners examples of Prolog code. I hope this is sufficient to show you how Prolog works, and what it has to offer. If you find this interesting, and if you are curious enough to do something on your own, feel free to add it to the <a href="https://github.com/vlad1m1r990/PrologSamples">repository</a>.</p><p>So, should you learn Prolog? Well, it’s the 21st century, and you should be learning whatever you can find on the internet. But seriously, is it worth learning? I think it is. It’s a niche concept that never really took off, but it somehow feels fresh and modern. For you, it will probably be a totally new approach to software development, that will get you out of your comfort zone, and force you to think in a different way while giving you another perspective on how software can be written.</p><p><em>Thanks for reading! If you enjoyed this story, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to leave a comment </em>💬<em> below.<br>Have feedback? Let’s be friends </em><a href="https://twitter.com/VladimirWrites"><em>on Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce2b68b1778a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Variable looked at me and said: “Say my name!”]]></title>
            <link>https://medium.com/@VladimirWrites/pick-good-variable-name-f683f0905726?source=rss-d5bfb69f8b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f683f0905726</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[codesign]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Vladimir Jovanović]]></dc:creator>
            <pubDate>Tue, 17 Oct 2017 07:25:50 GMT</pubDate>
            <atom:updated>2018-04-11T07:48:09.560Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H789DsYnZjSp3GChn0e-hA.jpeg" /></figure><p>While I was learning basics of programming at my high school, I was being taught how to solve problems: sort an array, reverse a String, convert Roman numerals to Arabic, etc. It was never expected from me to write code that would be altered or checked by another person. Usually, it was enough for the code to work, and to return correct output for a given input.</p><p>Some years later my university days started. I studied Mathematics and CS, and on my first CS exam I did all tasks, I tested them, and they worked, so I was expecting my first A+. But I got a B. I ran to my Assistant Professor’s office to tell him that he had made a mistake.</p><blockquote>- I came to him, all confident, and said: “I saw the exam results, and I think you have made a mistake. I am sure that my code works as expected.”</blockquote><blockquote>- “Yes, it does,” he answered.</blockquote><blockquote>- “So why did I then get a B?”</blockquote><blockquote>- “Because it took me 60 minutes to see why it worked.”</blockquote><p>And why is that, you may ask?! Well, the longest variable’s name in my code had two characters in it, and its name was s1. At that point, I realised that from that day on, my code would be read by others, so I started commenting it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*LO8ENinrxsVeJq3h4_l3vA.gif" /></figure><p>As you can see, I learned some things the hard way, but you don’t have to.</p><p>Let’s start from the beginning. Why do we need a variable’s name longer than one character? Because, usually, code that you write professionally will be read by someone else, or worse, by you, one year later. Maybe while you are writing it, it’s all clear to you. But that isn’t because your code is clear and easy to understand, that’s because you have just written it.</p><p>Whenever you feel the urge to put a comment over your variable declaration, think about giving your variable a more descriptive name. The main problem with the comment that describes your variable is that it will be at one place in your code, and your variable will be at multiple locations. A developer that reads your code at a later point in time will need to constantly convert vn into variableName in his mind while trying to understand the code.</p><p>Do not expect that giving your variables longer names will automatically make your code better. Naming is hard, and it will take you much more time to find a decent name for your variable than to write a comment.</p><blockquote>“There are only two hard things in Computer Science: cache invalidation and naming things.” — Phil Karlton</blockquote><p>Some of the basic principles to follow when naming your variables are:</p><ul><li>Use pronounceable names for all variables. dayMonthYear is a much better name than ddmmyyyy.</li><li>The name should tell you what the object does, instead of how it does it.</li><li>Names should be meaningful within their context. name is a pretty good variable’s name inside class User.</li><li>Be consistent. Most words have synonyms. Pick one and use it throughout your project.</li><li>Use a name that is as short as possible, but descriptive enough. Use birthday instead of dateOnWhichUserIsBorn.</li><li>Don´t use negative logic for your variable’s name. Use isEnabled instead isNotEnabled.</li><li>Whenever you have two variables that differ just by number, refactor your code immediately.</li></ul><p>In some cases, variables can and should have a short name.</p><ul><li>If a variable represents a loop-count, its name should be i, or j for the inner loop.</li><li>In a function where arguments traditionally have a one-char-name.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5d842703272967b5cc69f0dba63eab0/href">https://medium.com/media/c5d842703272967b5cc69f0dba63eab0/href</a></iframe><ul><li>Sometimes it’s really hard to explain a variable’s purpose inside its name, and in that case, you need to write a comment.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cada0f63ccd9a1c1b8b48c4d983bfee0/href">https://medium.com/media/cada0f63ccd9a1c1b8b48c4d983bfee0/href</a></iframe><p>While you are writing your code, the most important thing to have in mind is that you are writing your code first and foremost for humans to understand, and secondly for a machine to interpret. Therefore, when your code works and does what it’s meant to do, spend a couple of minutes and make it easier for human beings to understand.</p><p><em>Thanks for reading! If you enjoyed this story, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to leave a comment </em>💬<em> below.<br>Have feedback? Let’s be friends </em><a href="https://twitter.com/VladimirWrites"><em>on Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f683f0905726" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling configuration changes using static references]]></title>
            <link>https://medium.com/@VladimirWrites/handling-configuration-changes-using-static-references-6f58779802c3?source=rss-d5bfb69f8b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f58779802c3</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[memory-management]]></category>
            <category><![CDATA[memory-leak]]></category>
            <dc:creator><![CDATA[Vladimir Jovanović]]></dc:creator>
            <pubDate>Mon, 09 Oct 2017 15:31:55 GMT</pubDate>
            <atom:updated>2019-03-03T14:52:00.623Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3otPoQqrl8oggqDKg0%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3otPoQqrl8oggqDKg0%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3otPoQqrl8oggqDKg0%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a855b74ba664a8f3d48bf9d6a03c4dd/href">https://medium.com/media/0a855b74ba664a8f3d48bf9d6a03c4dd/href</a></iframe><p>When writing about the preservation of data on configuration change, there are two cases to cover. First, if there is a fixed number of small objects that need to survive change, use onSaveInstanceState, and that’s it, end of story, problem solved. However, the real problem comes when you need to preserve big objects whose size is unknown. There are a couple of correct approaches to this problem depending on your requirements. But that isn’t what this text is going to be about. This text is going to be about one pretty popular and rather wrong approach. We all know it is a bad one, but not all know why. The internet is full of questions on this topic, and a couple of days ago I also got asked about it.</p><blockquote>What if you hold a static reference to the data in my Activity to preserve them on screen rotation? Why is that bad?</blockquote><p>“Don’t do that, it’s bad! Memory leaks! Danger! 🚨” was my first reaction. But then he/she said: “Yeah, yeah … I know, but I will be super careful, and I will hold only data, no Context, or anything that has reference to theContext. Is it still bad?” You can bet it is! But that got me thinking:</p><blockquote>“Why is it still bad?”</blockquote><p>Why is it bad to have a static reference to some data inside your Activity? I was thinking for some time and then 💡.turnOn(). It’s bad because of 🥁🥁🥁 <strong>memory leaks</strong>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FaVtdz7iNVPI1W%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FaVtdz7iNVPI1W%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FaVtdz7iNVPI1W%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="327" frameborder="0" scrolling="no"><a href="https://medium.com/media/75a156d083beedbdd9dc885ffc0c1f58/href">https://medium.com/media/75a156d083beedbdd9dc885ffc0c1f58/href</a></iframe><p>However, this is not your classical Java/Android memory leak that <a href="https://github.com/square/leakcanary/tree/master/leakcanary-android">Leakcanary</a> will warn you about. This leaked memory can still be accessed, and although it is not needed anymore, the OS can’t do GC on it. The main problem with having a static reference to an object inside an Activity is that it’s really hard to know when to release it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/520fb8c55e7f26e859c01f8323699871/href">https://medium.com/media/520fb8c55e7f26e859c01f8323699871/href</a></iframe><p>Think about it. You can’t do that onDestory(), because you need your data to survive a configuration change. Should you do it when the next Activity is opened? Maybe, but probably not, because you will need those objects when you come back to that Activity. So, when should you do it then? Well, you shouldn’t! Android should take care of it, and remove it from memory when there is no free memory left. But it can’t because you have static references to those objects. In the end, the OS will remove it from the memory in the only way it knows how, it will kill your application.</p><p>And at some point, on some device, that’s exactly what’s going to happen. You will get OutOfMemoryException, and your application will crash. Just to be clear, next step <strong>should not</strong> be adding android:largeHeap=&quot;true&quot; into your AndroidManifest.xml. It should be fixing your application. You can read more about proper handling of configuration changes here:</p><p><a href="https://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange">Handling Configuration Changes | Android Developers</a></p><p>To sum up, having static references to objects is really dangerous, and it’s even worst to do it inside the objects which have a lifecycle such asActivities, Fragments, Services etc. Please use your static variables responsibly.</p><p><em>Thanks for reading! If you enjoyed this story, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to leave a comment </em>💬<em> below.<br></em> <em>Have feedback? Let’s be friends </em><a href="https://twitter.com/VladimirWrites"><em>on Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f58779802c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Short methods FTW]]></title>
            <link>https://medium.com/@VladimirWrites/short-methods-ftw-36fcebe46820?source=rss-d5bfb69f8b5d------2</link>
            <guid isPermaLink="false">https://medium.com/p/36fcebe46820</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Vladimir Jovanović]]></dc:creator>
            <pubDate>Mon, 02 Oct 2017 05:32:00 GMT</pubDate>
            <atom:updated>2018-04-11T07:43:42.935Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lEFA9LXXUbGBMnJcEw6fAg.jpeg" /><figcaption><a href="https://medium.com/u/310952b2bc3e">Marc Mueller</a></figcaption></figure><p>Some 5 years ago, I got my first intern job in a small startup. We were building a computer vision prototype in Matlab, and my assignment was to write C/C++ code that was supposed to do different types of transformations on video frames. I wrote a 300-lines-long monstrosity of a method that was doing all kinds of transformations and calculations on a matrix. It worked, and I was happy. Then my boss came to me and said:</p><blockquote>Every method that you write should be less than 25 lines long.</blockquote><p>And I laughed, I laughed hard, right in his face. I was such a <a href="https://www.urbandictionary.com/define.php?term=plonker">plonker</a>!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FzI6X93e09lDag%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FzI6X93e09lDag%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FzI6X93e09lDag%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1b9cb399623c367df0e9f0704f78355/href">https://medium.com/media/c1b9cb399623c367df0e9f0704f78355/href</a></iframe><p>And let me tell you something, 25 lines make one big, long method. Actually, most should be much shorter, around 10 lines, maybe even less. 25 lines should be the upper limit. And why is that?! Well, here are some of the reasons:</p><ul><li>First of all, it fits easily on your screen, so it’s easy to read.</li><li>Its purpose can be expressed in one simple sentence, and that makes it (in most cases) easy to understand.</li><li>It doesn’t need comments, because <a href="https://en.wikipedia.org/wiki/Single_responsibility_principle">it does only one thing</a>, and that thing can be described within its name.</li><li>It’s easy to test.</li><li>And lastly, because <a href="https://en.wikipedia.org/wiki/Robert_Cecil_Martin">Uncle Bob</a> said so.</li></ul><blockquote><em>“The first rule of functions is that they should be small. The second rule of functions is that they should be smaller than that.” — </em>Robert C. Martin</blockquote><p>However, not all short methods are good. For example this one:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a3f4aaea39efd79f78206d889c6b0f55/href">https://medium.com/media/a3f4aaea39efd79f78206d889c6b0f55/href</a></iframe><p>But pretty much every long method is bad.</p><blockquote>Long method bodies are a classical <a href="https://en.wikipedia.org/wiki/Code_smell">code smell</a>: it’s not in itself a problem, but it’s an indication that there’s probably a problem there.</blockquote><blockquote><a href="https://softwareengineering.stackexchange.com/users/2234/joachim-sauer">Joachim Sauer</a> (has nothing to do with this <a href="https://en.wikipedia.org/wiki/Joachim_Sauer">Joachim Sauer</a>, I think <em>🤔</em>)</blockquote><p>One thing that’s mind-boggling is that the vast majority of developers knows that the long methods are bad, but very few actually follow this rule. Quite often, I see good developers writing huge methods because “It’s a UI” or “It’s in a test” or “It’s Java ✋”. And at first glance, it doesn’t look that bad. Code is well organised and each line logically follows the previous one. That’s because the developer who has just written that code has its context and understanding in his head, so he doesn’t need to get it from the code. When another developer tries to change that part of the code one year after it’s been written he/she is …</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F8JfMnpTXorVDy%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F8JfMnpTXorVDy%2Fgiphy.gif&amp;image=http%3A%2F%2Fmedia0.giphy.com%2Fmedia%2F8JfMnpTXorVDy%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="243" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b19172b2fb204edf04621124daae939/href">https://medium.com/media/8b19172b2fb204edf04621124daae939/href</a></iframe><p>going to fail. Why?</p><ol><li>Because there is no time to invest in proper analysis of that method. (New feature needs to be done by yesterday).</li><li>There are no tests to support refactoring. Not because it’s hard to cover a 100-lines-long method with tests (btw. it is hard), but because it’s much easier to split it into 10 methods, and write tests for each of them. Therefore, there is a good chance that that person didn’t even try to test it. And if he/she did, it’s likely that our developer would be making changes on 10 short methods.</li><li>Misleading comments are everywhere. First of all, there has to be at least a couple of comments in a long method (it’s really unprofessional to write a long incomprehensible method without comments 😄). And it’s quite probable that code has already been changed, but developers are really scared of changing other people’s comments, so comments will stay the same. They will be sitting there, telling you a story of some other badly written code.</li></ol><h4>So please, for the love of Uncle Bob, write your methods short.</h4><p><em>P.S. I promise that I will refactor long methods in </em><a href="https://github.com/VladimirWrites"><em>my projects on GitHub</em></a><em>. </em>🤞</p><p><em>Thanks for reading! If you enjoyed this story, please </em><strong><em>click the </em></strong>👏<strong><em> button</em></strong><em> </em><strong><em>and share </em></strong><em>to help others find it! Feel free to leave a comment </em>💬<em> below.<br></em> <em>Have feedback? Let’s be friends </em><a href="https://twitter.com/VladimirWrites"><em>on Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36fcebe46820" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>