<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: André Jacques</title>
    <description>The latest articles on Forem by André Jacques (@havarem).</description>
    <link>https://forem.com/havarem</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F65461%2F9e1d4b16-440a-4d98-ba42-51092f863463.jpeg</url>
      <title>Forem: André Jacques</title>
      <link>https://forem.com/havarem</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/havarem"/>
    <language>en</language>
    <item>
      <title>Boss vs Motivator</title>
      <dc:creator>André Jacques</dc:creator>
      <pubDate>Sun, 14 Apr 2019 05:49:25 +0000</pubDate>
      <link>https://forem.com/havarem/boss-vs-motivator-3kea</link>
      <guid>https://forem.com/havarem/boss-vs-motivator-3kea</guid>
      <description>&lt;h1&gt;
  
  
  My take about leadership
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Disclaimer
&lt;/h2&gt;

&lt;p&gt;I want to start this article by saying this is only my opinion and it is not, in any way, enforceable to other kinds of people. I want to emphasize that I'm talking about competent leaders.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;Let's say we have a team of five or six members, working on different projects throughout the year. It doesn't matter if that team is agile or not, what matter is that someone will be holding &lt;em&gt;The Leadership&lt;/em&gt;, meaning that he or she will steer the team in the same direction. I have encountered two types of those people, the &lt;em&gt;Boss&lt;/em&gt; and the &lt;em&gt;Motivator&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commonalities
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;Boss&lt;/em&gt; and the &lt;em&gt;Motivator&lt;/em&gt; usually shared some traits as such:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;they both value the opinion of an expert strongly;&lt;/li&gt;
    &lt;li&gt;they both receive great respect from their peers;&lt;/li&gt;
    &lt;li&gt;they both take decision they believe are for the best interest for the project success.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Distinction
&lt;/h2&gt;

&lt;p&gt;The difference is basically how those leaders take decisions.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Boss&lt;/em&gt; will usually weigh in the pros and cons and take a decision by him or herself and may do so over expert opinion. With a &lt;em&gt;boss&lt;/em&gt;, you know where you are going.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Motivator&lt;/em&gt; will usually take expert opinions first, or at least the opinion of concern members of the team. With a &lt;em&gt;motivator&lt;/em&gt;, you have a bigger voice.&lt;/p&gt;

&lt;p&gt;(&lt;em&gt;NOTE&lt;/em&gt;: &lt;em&gt;usually&lt;/em&gt; doesn't mean &lt;em&gt;always&lt;/em&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Boss
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What I like
&lt;/h3&gt;

&lt;p&gt;I generally enjoy working with &lt;em&gt;bosses&lt;/em&gt; when they have a lot of experience, counting in tens of years. At that point, they generally have a very well-tuned vision of how a project should go down to. They know the drill, the pitfall and know how to explain why some opinions have been left out. I must say that in my career, I might have worked under two or three great bosses, out of a dozen.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I don't like
&lt;/h3&gt;

&lt;p&gt;The main drawback I have with &lt;em&gt;bosses&lt;/em&gt; are when they are managing a kind of project they never had before. I once had a 30-years of experience in C++ developing different tools, being sent on a Web application in PHP using an MVC Framework. I kid you not when I say it took a month to explain to that guy that memory management is not really a thing in PHP at that point and also that CSS is not really the forte of software engineers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivator
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What I like
&lt;/h3&gt;

&lt;p&gt;I generally enjoy working with &lt;em&gt;motivators&lt;/em&gt; when they first have some experience in at least half the concept needed for the project. Those I really love working with were those who put a lot of hours in order to fetch up the most important information on the domain they have little knowledge. They are dynamic, meaning that they can try something (prototype), and if it does not work, go the other way. I usually feel more part of a team, with a voice that is being heard.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I don't like
&lt;/h3&gt;

&lt;p&gt;At some point, a &lt;em&gt;motivator&lt;/em&gt; needs to take decisions, and sometimes they need to be made against the majority. This is where the line between a good &lt;em&gt;motivator&lt;/em&gt; and a bad one is: their ability to make that call. I had so many of these people that literally, in a span of three months, start to point A, went to point B, to come back to point A without even noticing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What kind am I?
&lt;/h2&gt;

&lt;p&gt;My career span over 10 years, so I like to think about me as a &lt;em&gt;motivator&lt;/em&gt;. I had many projects where I was the manager and really liked to listen to what people had come up with, making propositions to fill the gaps between two concepts, and see the final product working has expected. I do believe a &lt;em&gt;boss&lt;/em&gt; would have made the same job faster, but since only the experience will get you there, better be a good motivator.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are you?
&lt;/h2&gt;

&lt;p&gt;I would like to see what you think, what kind of &lt;em&gt;good&lt;/em&gt; leader you have encountered, but the most important is how do you see yourself?&lt;/p&gt;

</description>
      <category>management</category>
      <category>teamwork</category>
    </item>
    <item>
      <title>Override `equals` method in Java</title>
      <dc:creator>André Jacques</dc:creator>
      <pubDate>Tue, 10 Apr 2018 20:28:43 +0000</pubDate>
      <link>https://forem.com/havarem/override-equals-method-in-java-2b3j</link>
      <guid>https://forem.com/havarem/override-equals-method-in-java-2b3j</guid>
      <description>&lt;p&gt;The &lt;code&gt;==&lt;/code&gt; operator is a false friend in Java. It works properly only on primitive and will make you cry if you used it on any other referenced &lt;code&gt;Object&lt;/code&gt;, for the most part.&lt;/p&gt;

&lt;h2&gt;
  
  
  The basic
&lt;/h2&gt;

&lt;p&gt;As a rule of thumb, every &lt;code&gt;equals&lt;/code&gt; method should start like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt; &lt;span class="nc"&gt;ClassName&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// custom logic here&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;em&gt;ClassName&lt;/em&gt; should be replaced by whatever type your class is. After that, I usually apply one of the following solutions.&lt;/p&gt;

&lt;h3&gt;
  
  
  The class as only one relevant field
&lt;/h3&gt;

&lt;p&gt;In the case that the class has only one relevant field, I will return automatically either the &lt;code&gt;==&lt;/code&gt; operation (for primitive) or the &lt;code&gt;equals&lt;/code&gt; of the field.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;fullname&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="nc"&gt;Person&lt;/span&gt; &lt;span class="n"&gt;converted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fullname&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;converted&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fullname&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The class as many relevant fields
&lt;/h3&gt;

&lt;p&gt;I usually have two options here.&lt;/p&gt;

&lt;h4&gt;
  
  
  The &lt;code&gt;toString()&lt;/code&gt; contains all the relevant field
&lt;/h4&gt;

&lt;p&gt;There is no need to add complexity in a class if something can help you with your code. There is no need to test for &lt;code&gt;instanceof&lt;/code&gt; since &lt;code&gt;toString&lt;/code&gt; is defined everywhere, and no need to cast for the same reason.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstname&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;lastname&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;firstname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lastname&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is not mandatory to be the &lt;code&gt;toString&lt;/code&gt;. Sometimes other methods do the same job. You need to keep in mind that other methods will require to test for and cast the object before comparing.&lt;/p&gt;

&lt;h4&gt;
  
  
  There is no method to help
&lt;/h4&gt;

&lt;p&gt;In that situation, I will usually cascade &lt;code&gt;if&lt;/code&gt; until the last relevant field.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstname&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;lastname&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt; &lt;span class="n"&gt;dob&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt; &lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="nc"&gt;Person&lt;/span&gt; &lt;span class="n"&gt;converted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Person&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;firstname&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;converted&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;firstname&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(!(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lastname&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;converted&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lastname&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;dob&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;converted&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;dob&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I know that I could probably do something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;firstname&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;converted&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;firstname&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lastname&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;converted&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lastname&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;dob&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;converted&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;dob&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I don't really like this because it is mainly hard to read. I know that Java will probably optimize the bytecode with these kinds of statement, nevertheless, I believe that in most cases, it won't really matter.&lt;/p&gt;

&lt;p&gt;Don't forget that, to be able to use &lt;code&gt;HashMap&lt;/code&gt; and stuff, you also need to override the &lt;code&gt;hashcode&lt;/code&gt;. Here are the main rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If 2 instances are equal, then both &lt;code&gt;hashcode&lt;/code&gt; MUST BE equal;&lt;/li&gt;
&lt;li&gt;If 2 instances are not equal, then both &lt;code&gt;hashcode&lt;/code&gt; SHOULD NOT BE equal.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A good &lt;code&gt;hashcode&lt;/code&gt; algorithm that lives up to the second rule will make the use of &lt;code&gt;HashMap&lt;/code&gt; and &lt;code&gt;HashSet&lt;/code&gt; more efficient.&lt;/p&gt;

</description>
      <category>java</category>
    </item>
  </channel>
</rss>
