<?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>DEV Community: TEJAS-PORWAL</title>
    <description>The latest articles on DEV Community by TEJAS-PORWAL (@tejasporwal).</description>
    <link>https://dev.to/tejasporwal</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%2F1132482%2Ff98dc89a-6f21-4c2f-baea-d38a40a5ec2a.jpeg</url>
      <title>DEV Community: TEJAS-PORWAL</title>
      <link>https://dev.to/tejasporwal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tejasporwal"/>
    <language>en</language>
    <item>
      <title>Java Unleashed: Tips for Success and Traps to Avoid</title>
      <dc:creator>TEJAS-PORWAL</dc:creator>
      <pubDate>Mon, 06 May 2024 18:47:05 +0000</pubDate>
      <link>https://dev.to/tejasporwal/java-unleashed-tips-for-success-and-traps-to-avoid-1kn1</link>
      <guid>https://dev.to/tejasporwal/java-unleashed-tips-for-success-and-traps-to-avoid-1kn1</guid>
      <description>&lt;p&gt;Welcome back, dear Readers!😀. Welcome to the world of Java, where innovation meets reliability, and every line of code holds the potential to shape the digital landscape. Whether you're a seasoned developer navigating the intricacies of Java's ecosystem or an eager learner taking your first steps into the realm of object-oriented programming, this blog is your guide to mastering Java's nuances, pitfalls, and possibilities. Join us on a journey through the Java Unleashed: Tips for Success and Traps to Avoid, where we'll explore the secrets to writing elegant, efficient code and sidestep the common pitfalls that lurk beneath the surface.&lt;br&gt;
So Let's get started and see them One by One.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't Concatenate many Strings&lt;/strong&gt;&lt;br&gt;
In Java, you can easily merge a few strings into one by using the concatenation operator or the plus sign.&lt;/p&gt;

&lt;p&gt;It's easy, quick, and can be freely used when you only have a few strings to concatenate.&lt;/p&gt;

&lt;p&gt;However, you may run into serious performance problems when you start concatenating too many strings. Let's see a example to demostrate that&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwapp67jpoxc6p1kbt7t8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwapp67jpoxc6p1kbt7t8.png" alt="Practice-1" width="800" height="597"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One way to solve this issue is to use &lt;em&gt;StringBuilder&lt;/em&gt; or &lt;em&gt;StringBuffer&lt;/em&gt; from where we can leverage an inbuilt method 'append' to perform this operation. Here I'm using &lt;em&gt;StringBuffer&lt;/em&gt; which is also a &lt;em&gt;threadsafe&lt;/em&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldcw7dtra5bl2hhi3o09.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldcw7dtra5bl2hhi3o09.png" alt="Output" width="800" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;em&gt;the time spent may vary here depending on your system performance.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Pick the right datatype for ID&lt;/strong&gt;&lt;br&gt;
Stop picking &lt;em&gt;int&lt;/em&gt; or &lt;em&gt;Integer&lt;/em&gt; to store &lt;em&gt;Id&lt;/em&gt;. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;first of all there is a conceptual problem as _Integers _are numeric datatype they should be used to represent numbers and perform operation on them in a mathematical sense. Now if you think about identifiers do they make sense as mathematical numbers? No right.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also an Identifier may contains leading zeroes which may be useful to represent something meaningful and using int or Integer will not help to retain those leading zeroes as they will be trimmed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So what's the solution to this problem well you can always go with String as first choice to represent Id. And also to provide the solution to this java provides an UUID(universally unique identifier) class (java.util.UUID) which helps to generate a 36 characters long unique number.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4t1p9hcyo1rnt1zo1ti3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4t1p9hcyo1rnt1zo1ti3.png" alt="Identifier" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Keep your API clean&lt;/strong&gt;&lt;br&gt;
Make sure your methods and classes aren’t too long. While there’s no strict rule regarding the exact number of lines or words for a class, it’s advisable to maintain a focused and cohesive structure. When it comes to methods, it’s generally suggested to aim for around 10 to 20 lines of code per method. If a method gets longer, it might be better to split it into smaller, more manageable parts.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Make use of Otional Class in java&lt;/strong&gt;&lt;br&gt;
Every Java Programmer is familiar with NullPointerException. It can crash your code. And it is very hard to avoid it without using too many null checks. So, to overcome this, Java 8 has introduced a new class Optional in java.util package. It can help in writing a neat code without using too many null checks. By using Optional, we can specify alternate values to return or alternate code to run. This makes the code more readable because the facts which were hidden are now visible to the developer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkuvdr86w3nqgmykb3n0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkuvdr86w3nqgmykb3n0.png" alt="Optional Class example" width="800" height="123"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Use @ &lt;em&gt;Override&lt;/em&gt; and @ &lt;em&gt;deprecated&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
In Java, annotations are the metadata that we used to provide information to the compiler. Here, the @ _Override _annotation specifies the compiler that the method after this annotation overrides the method of the superclass.&lt;/p&gt;

&lt;p&gt;It is not mandatory to use @ &lt;em&gt;Override&lt;/em&gt;. However, when we use this, the method should follow all the rules of overriding. Otherwise, the compiler will generate an error.&lt;br&gt;
&lt;em&gt;Rules&lt;/em&gt; -&amp;gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Both the superclass and the subclass must have the same method name, the same return type and the same parameter list.&lt;/li&gt;
&lt;li&gt;We cannot override the method declared as final and static.&lt;/li&gt;
&lt;li&gt;We should always override abstract methods of the superclass.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzcpwyvjg1sphtjqqnow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzcpwyvjg1sphtjqqnow.png" alt="@Override" width="800" height="151"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly, if we don't feel the need to use an existing API we should always use @ &lt;em&gt;deprecated&lt;/em&gt; which warns other that this API is deprecate and should not be used further for any purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faygt5nasj4qfin8pzbro.png" alt="@Deprecated" width="762" height="162"&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Program to _Interface _where appropriate&lt;/strong&gt;&lt;br&gt;
Always if a matching interface type id available, declare things like parameters, return values, variables and fields using that interface type. Let's see a small example to demonstrate that.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzzzxkbs60onptrs63lh.png" alt="Using Interfaces" width="800" height="217"&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Make use of Generics in java&lt;/strong&gt;&lt;br&gt;
Generics is one of the most useful feature that java offers. So exactly is Generics in java well the answer to that is simple and easy to understand. Generics are parameterized types. The idea is to allow type (Integer, String, … etc., and user-defined types) to be a parameter to methods, classes, and interfaces. Using Generics, it is possible to create classes that work with different data types. Let's visualize that with an example here&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vgkll279yatnm1jdin9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vgkll279yatnm1jdin9.png" alt="Generics example" width="800" height="606"&gt;&lt;/a&gt;&lt;br&gt;
Generics also offers few &lt;em&gt;Type&lt;/em&gt; parameter which can be picked up based on your requirements&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;T - Type&lt;/li&gt;
&lt;li&gt;E - Element&lt;/li&gt;
&lt;li&gt;K - Key&lt;/li&gt;
&lt;li&gt;N - Number&lt;/li&gt;
&lt;li&gt;V - Value&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are some benefits to keep in mind if you intend to use them&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Type Safety&lt;br&gt;
Code Reusability&lt;br&gt;
Elimination of Type Casting&lt;br&gt;
Improved Readability and Maintainability&lt;br&gt;
Enhanced Performance&lt;br&gt;
Stronger Abstraction&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;BONUS TIP&lt;/em&gt;&lt;br&gt;
what are view on the below given statement are these One and the same or Not?🤔&lt;/p&gt;

&lt;p&gt;&lt;em&gt;NOT A GOOD PRACTICE&lt;/em&gt; &lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjksolt6p8e4726c5ab9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjksolt6p8e4726c5ab9.png" alt="Not GOOD" width="800" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A BETTER WAY&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fipfvdcxmmw75nhkv6jny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fipfvdcxmmw75nhkv6jny.png" alt="Image description" width="800" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;well both the statement has the same meaning but in&lt;br&gt;
the first statement we directly compares the result of whatFruit.getFruitType() with the enum constant FRUITS.APPLE using the equals() method. This approach can potentially lead to a NullPointerException if whatFruit.getFruitType() returns null because calling equals() on null would throw an exception.&lt;/p&gt;

&lt;p&gt;And in the second approach we see that it reverses the comparison, checking if the enum constant FRUITS.BANANA is equal to the result of whatFruit.getFruitType(). This approach is safer because it avoids potential NullPointerException. Even if whatFruit.getFruitType() returns null, the comparison will not throw an exception because FRUITS.BANANA is not null.And also make it thread-safe.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;To Summarize adhering to best practices in Java is essential for writing clean, maintainable, and efficient code. By following the principles outlined in this article, you can enhance the readability, reliability, and scalability of your Java applications. I hope you can incorporate these best practices into your Java development workflow, you can elevate the quality of your code and become a more proficient Java developer.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's it for this blog see you all next time with something new. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Java Unleashed: Tips for Success and Traps to Avoid</title>
      <dc:creator>TEJAS-PORWAL</dc:creator>
      <pubDate>Mon, 06 May 2024 18:47:05 +0000</pubDate>
      <link>https://dev.to/tejasporwal/java-unleashed-tips-for-success-and-traps-to-avoid-2if0</link>
      <guid>https://dev.to/tejasporwal/java-unleashed-tips-for-success-and-traps-to-avoid-2if0</guid>
      <description>&lt;p&gt;Welcome back, dear Readers!😀. Welcome to the world of Java, where innovation meets reliability, and every line of code holds the potential to shape the digital landscape. Whether you're a seasoned developer navigating the intricacies of Java's ecosystem or an eager learner taking your first steps into the realm of object-oriented programming, this blog is your guide to mastering Java's nuances, pitfalls, and possibilities. Join us on a journey through the Java Unleashed: Tips for Success and Traps to Avoid, where we'll explore the secrets to writing elegant, efficient code and sidestep the common pitfalls that lurk beneath the surface.&lt;br&gt;
So Let's get started and see them One by One.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't Concatenate many Strings&lt;/strong&gt;&lt;br&gt;
In Java, you can easily merge a few strings into one by using the concatenation operator or the plus sign.&lt;/p&gt;

&lt;p&gt;It's easy, quick, and can be freely used when you only have a few strings to concatenate.&lt;/p&gt;

&lt;p&gt;However, you may run into serious performance problems when you start concatenating too many strings. Let's see a example to demostrate that&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwapp67jpoxc6p1kbt7t8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwapp67jpoxc6p1kbt7t8.png" alt="Practice-1" width="800" height="597"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One way to solve this issue is to use &lt;em&gt;StringBuilder&lt;/em&gt; or &lt;em&gt;StringBuffer&lt;/em&gt; from where we can leverage an inbuilt method 'append' to perform this operation. Here I'm using &lt;em&gt;StringBuffer&lt;/em&gt; which is also a &lt;em&gt;threadsafe&lt;/em&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Output&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldcw7dtra5bl2hhi3o09.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldcw7dtra5bl2hhi3o09.png" alt="Output" width="800" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;em&gt;the time spent may vary here depending on your system performance.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Pick the right datatype for ID&lt;/strong&gt;&lt;br&gt;
Stop picking &lt;em&gt;int&lt;/em&gt; or &lt;em&gt;Integer&lt;/em&gt; to store &lt;em&gt;Id&lt;/em&gt;. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;first of all there is a conceptual problem as &lt;em&gt;Integers&lt;/em&gt; are numeric datatype they should be used to represent numbers and perform operation on them in a mathematical sense. Now if you think about identifiers do they make sense as mathematical numbers? No right.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Also an Identifier may contains leading zeroes which may be useful to represent something meaningful and using int or Integer will not help to retain those leading zeroes as they will be trimmed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So what's the solution to this problem well you can always go with String as first choice to represent Id. And also to provide the solution to this java provides an UUID(universally unique identifier) class (java.util.UUID) which helps to generate a 36 characters long unique number.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4t1p9hcyo1rnt1zo1ti3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4t1p9hcyo1rnt1zo1ti3.png" alt="Identifier" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Keep your API clean&lt;/strong&gt;&lt;br&gt;
Make sure your methods and classes aren’t too long. While there’s no strict rule regarding the exact number of lines or words for a class, it’s advisable to maintain a focused and cohesive structure. When it comes to methods, it’s generally suggested to aim for around 10 to 20 lines of code per method. If a method gets longer, it might be better to split it into smaller, more manageable parts.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Make use of Otional Class in java&lt;/strong&gt;&lt;br&gt;
Every Java Programmer is familiar with NullPointerException. It can crash your code. And it is very hard to avoid it without using too many null checks. So, to overcome this, Java 8 has introduced a new class Optional in java.util package. It can help in writing a neat code without using too many null checks. By using Optional, we can specify alternate values to return or alternate code to run. This makes the code more readable because the facts which were hidden are now visible to the developer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkuvdr86w3nqgmykb3n0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffkuvdr86w3nqgmykb3n0.png" alt="Optional Class example" width="800" height="123"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Use @ &lt;em&gt;Override&lt;/em&gt; and @ &lt;em&gt;deprecated&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
In Java, annotations are the metadata that we used to provide information to the compiler. Here, the @ &lt;em&gt;Override&lt;/em&gt; annotation specifies the compiler that the method after this annotation overrides the method of the superclass.&lt;/p&gt;

&lt;p&gt;It is not mandatory to use @ &lt;em&gt;Override&lt;/em&gt;. However, when we use this, the method should follow all the rules of overriding. Otherwise, the compiler will generate an error.&lt;br&gt;
&lt;em&gt;Rules&lt;/em&gt; -&amp;gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Both the superclass and the subclass must have the same method name, the same return type and the same parameter list.&lt;/li&gt;
&lt;li&gt;We cannot override the method declared as final and static.&lt;/li&gt;
&lt;li&gt;We should always override abstract methods of the superclass.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzcpwyvjg1sphtjqqnow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzcpwyvjg1sphtjqqnow.png" alt="@Override" width="800" height="151"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similarly, if we don't feel the need to use an existing API we should always use @ &lt;em&gt;deprecated&lt;/em&gt; which warns other that this API is deprecate and should not be used further for any purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faygt5nasj4qfin8pzbro.png" alt="@Deprecated" width="762" height="162"&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Program to &lt;em&gt;Interface&lt;/em&gt; where appropriate&lt;/strong&gt;&lt;br&gt;
Always if a matching interface type id available, declare things like parameters, return values, variables and fields using that interface type. Let's see a small example to demonstrate that.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzzzxkbs60onptrs63lh.png" alt="Using Interfaces" width="800" height="217"&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Make use of Generics in java&lt;/strong&gt;&lt;br&gt;
Generics is one of the most useful feature that java offers. So what exactly is Generics in java well the answer to that is simple and easy to understand. Generics are parameterized types. The idea is to allow type (Integer, String, … etc., and user-defined types) to be a parameter to methods, classes, and interfaces. Using Generics, it is possible to create classes that work with different data types. Let's visualize that with an example here&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vgkll279yatnm1jdin9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0vgkll279yatnm1jdin9.png" alt="Generics example" width="800" height="606"&gt;&lt;/a&gt;&lt;br&gt;
Generics also offers few &lt;em&gt;Type&lt;/em&gt; parameter which can be picked up based on your requirements&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;T - Type&lt;/li&gt;
&lt;li&gt;E - Element&lt;/li&gt;
&lt;li&gt;K - Key&lt;/li&gt;
&lt;li&gt;N - Number&lt;/li&gt;
&lt;li&gt;V - Value&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are some benefits to keep in mind if you intend to use them&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Type Safety&lt;br&gt;
Code Reusability&lt;br&gt;
Elimination of Type Casting&lt;br&gt;
Improved Readability and Maintainability&lt;br&gt;
Enhanced Performance&lt;br&gt;
Stronger Abstraction&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;BONUS TIP&lt;/em&gt;&lt;br&gt;
what are view on the below given statement are these One and the same or Not?🤔&lt;/p&gt;

&lt;p&gt;&lt;em&gt;NOT A GOOD PRACTICE&lt;/em&gt; &lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjksolt6p8e4726c5ab9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftjksolt6p8e4726c5ab9.png" alt="Not GOOD" width="800" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;A BETTER WAY&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fipfvdcxmmw75nhkv6jny.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fipfvdcxmmw75nhkv6jny.png" alt="Image description" width="800" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;well both the statement has the same meaning but in&lt;br&gt;
the first statement we directly compares the result of whatFruit.getFruitType() with the enum constant FRUITS.APPLE using the equals() method. This approach can potentially lead to a NullPointerException if whatFruit.getFruitType() returns null because calling equals() on null would throw an exception.&lt;/p&gt;

&lt;p&gt;And in the second approach we see that it reverses the comparison, checking if the enum constant FRUITS.BANANA is equal to the result of whatFruit.getFruitType(). This approach is safer because it avoids potential NullPointerException. Even if whatFruit.getFruitType() returns null, the comparison will not throw an exception because FRUITS.BANANA is not null.And also make it thread-safe.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;To Summarize adhering to best practices in Java is essential for writing clean, maintainable, and efficient code. By following the principles outlined in this article, you can enhance the readability, reliability, and scalability of your Java applications. I hope you can incorporate these best practices into your Java development workflow, you can elevate the quality of your code and become a more proficient Java developer.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here is the link to my github Repo to check out detailed example on each key points here and some extra info. Do check this out&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://github.com/TEJAS-PORWAL/Java_goodPractice"&gt;https://github.com/TEJAS-PORWAL/Java_goodPractice&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's it for this blog see you all next time with something new. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Code Chronicles: My Journey as a Developer - Reflections on the Past Few Months</title>
      <dc:creator>TEJAS-PORWAL</dc:creator>
      <pubDate>Thu, 11 Apr 2024 18:50:03 +0000</pubDate>
      <link>https://dev.to/tejasporwal/code-chronicles-my-journey-as-a-developer-reflections-on-the-past-few-months-406j</link>
      <guid>https://dev.to/tejasporwal/code-chronicles-my-journey-as-a-developer-reflections-on-the-past-few-months-406j</guid>
      <description>&lt;p&gt;Welcome back, dear readers! It's been quite a journey over the past couple of months for me. As we settle into a new chapter, it's time to reflect on the lessons learned, the challenges faced, and the growth experienced. Let me share my learning experience of my corporate journey till now.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learned a lot about system design and it's importance in product-based company. Hence selecting a appropiate design pattern helps you to keep your work top-notch and avoid any negative feedback over your code-review. 
Design patterns are powerful tools for building flexible, maintainable, and scalable software systems. Whether we are designing a simple application or a complex enterprise system, the knowledge of design patterns will undoubtedly be invaluable in our journey as a software developer. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F95t1m2nhmb7wjao82ist.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F95t1m2nhmb7wjao82ist.jpg" alt="Image description" width="800" height="441"&gt;&lt;/a&gt;&lt;br&gt;
Till now got a chance to cover all the &lt;strong&gt;Creational-Design&lt;/strong&gt; pattern,&lt;br&gt;
also from &lt;strong&gt;Structural-Design&lt;/strong&gt; pattern only used Facade pattern. &lt;br&gt;
And few of them from the &lt;strong&gt;Behavioural-Design&lt;/strong&gt; pattern. Will try to unveil in-depth about all the Design-pattern in next blog.&lt;/p&gt;



&lt;p&gt;Also working in java gave me a chance to explore the features of java which definitely did took, some time for me to get hands-on in the early stage but once I got the hang of it are now definitely coming handy and make my code more readable and easily understandable.&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Lambdas and Functional Interfaces&lt;/li&gt;
&lt;li&gt;Streams API&lt;/li&gt;
&lt;li&gt;Optional Class&lt;/li&gt;
&lt;li&gt;Using Generic Classes&lt;/li&gt;
&lt;li&gt;Using Tuples&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Illustration of code before I use above java features&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void main(String[] args) {
        List&amp;lt;String&amp;gt; nameList = Arrays.asList("Tejas", "Sammer", "Aditya", "Saurabh");
        List&amp;lt;String&amp;gt; convertedNameList = new ArrayList&amp;lt;&amp;gt;();
        for(String name : nameList){
            if(name.startsWith("S")){
                convertedNameList.add(name.toLowerCase());
            }
        }
        System.out.println(convertedNameList);
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;strong&gt;A Better and Efficient way of writing above code&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List&amp;lt;String&amp;gt; nameList = Arrays.asList("Tejas", "Sammer", "Aditya", "Saurabh");
Optional&amp;lt;String&amp;gt; convertedNameOpt =  nameList.stream().filter(name -&amp;gt; name.startsWith("S")).map(String::toLowerCase).reduce((s1, s2) -&amp;gt; s1 + ", " + s2);
        System.out.println(convertedNameOpt);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;As a developer working in product-based company Code-review becomes a usual part of your day-to-day life. And writing cleaner code becomes your by default responsibilty. There few techniques which I picked up over the past few months:&lt;/p&gt;

&lt;blockquote&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Gaurd-Clause Technique&lt;/li&gt;
&lt;li&gt;Select appropiate data-structure depending upon the requirement&lt;/li&gt;
&lt;li&gt;Avoid unecessary deep-nesting loops&lt;/li&gt;
&lt;li&gt;Use multi-line descriptive comments to make you API decriptive and easily understandable.&lt;/li&gt;
&lt;li&gt;Make sure your code is idented and readable.&lt;/li&gt;
&lt;li&gt;Always declare a understandable variable-name and avoid abbreviation.&lt;/li&gt;
&lt;li&gt;Maintain Modularity in your code.&lt;/li&gt;
&lt;li&gt;Make you code Compact and avoid using uncessary variable declaration.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Well I was using &lt;em&gt;git&lt;/em&gt; before entering the corporate world but not at the full-potential &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understanding the &lt;em&gt;git-workflow&lt;/em&gt; is very important and chosing the correct one is your responsibilty. &lt;/li&gt;
&lt;li&gt;Making use of rebasing instead of merging&lt;/li&gt;
&lt;li&gt;Importance of correct &lt;em&gt;base-of&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;How to avoid and resolve &lt;em&gt;merge-conflict&lt;/em&gt; in files.&lt;/li&gt;
&lt;li&gt;Using a &lt;em&gt;feature-branch&lt;/em&gt; for develpoment&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Lastly as working for Infor, I developed the understanding for the &lt;em&gt;Supply-Chain Management&lt;/em&gt; system(Shipment-Planning, Shipment-Orders, Transport-Planning, Transport-Order, Shipment-Visibility and more) which is definitely something new and very-interesting to learn. &lt;/p&gt;




&lt;p&gt;Thanks for reading this blog and Let's meet again in next blog with something new and interesting.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My Understanding of the DEV-Tools!</title>
      <dc:creator>TEJAS-PORWAL</dc:creator>
      <pubDate>Thu, 03 Aug 2023 18:20:02 +0000</pubDate>
      <link>https://dev.to/tejasporwal/my-understanding-of-the-dev-tools-c2f</link>
      <guid>https://dev.to/tejasporwal/my-understanding-of-the-dev-tools-c2f</guid>
      <description>&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  What are browser developer tools🤔?
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
Basically dev-tool is nothing but the in-Built tools provided by the browser for the wide range of action on the web-page, from inspecting currently-loaded HTML, CSS and JavaScript to showing which assets the page has requested and how long it takes to load a page and optimize the pages cache and memory😯.&lt;/p&gt;

&lt;p&gt;So, how to pull-up the dev-tools?&lt;br&gt;
Well, it's simple you need to click =&amp;gt;&lt;br&gt;
   windows: Ctrl + Shift + I || F12&lt;br&gt;
   mac: Option + Shift + ⌘ + I || F12&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
_DOM-Manipulation:_&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D5mMD4vx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yacmad7lehd9s7a55wx3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D5mMD4vx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yacmad7lehd9s7a55wx3.png" alt="Image description" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;well DOM-manipulation becomes very easy and siplified with the use of dev-tool and you can easily modify and update the code live on the web-page for the better options.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--81q6Qx18--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26p73jq694qmo2gfcu2l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--81q6Qx18--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26p73jq694qmo2gfcu2l.png" alt="Image description" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Delete Node (sometimes Delete Element). Deletes the current element.&lt;/li&gt;
&lt;li&gt;Edit as HTML (sometimes Add attribute/Edit text). Lets you change the HTML and see the results on the fly. Very useful for debugging and testing.&lt;/li&gt;
&lt;li&gt;:hover/:active/:focus. Forces element states to be toggled on, so you can see what their styling would look like.&lt;/li&gt;
&lt;li&gt;Copy/Copy as HTML. Copy the currently selected HTML.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well DOM-manipulation is not the only feature you get from the dev-tools, you can also make alteration in your CSS code. Which comes very handy for testing the design and UI. &lt;/p&gt;

&lt;p&gt;devTool also provide you a easy and compatible view of your page on different device such as mobile devices, tablets or a wide-screen device, with the help of these design feature you can make alternation and manage your responsive design easily.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;_JavaScript Console:_&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;console.log('hello') is one of the most famous and executed statement in the javascript console which can be viewed in the console option from the dev-tools window.&lt;br&gt;
The console window allows you to access all the javascipt object and function for the test purpose and see for yourself what it return on the page. This comes in-handy at various times and help you to fix a logic for the javascript debugger and check for the breakpoints.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Secrect-Tips:&lt;/code&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"You can use '&lt;a href="https://chrome.google.com/webstore/detail/save-all-resources/abpdnfjocnmdomablahdcfnoggeeiedb"&gt;save all resouces&lt;/a&gt;' extension available on chrome to download the code of a webpage and use it to learn and view the code and understand the factoring of the code."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's all for this Blog. I'll leave the responsibility of exploring the other features of the dev-tool on you.&lt;/p&gt;

&lt;p&gt;KEEP EXPLORING AND KEEP TRYING🙌... untill next time😁.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
