NEVER WRITE CODE LIKE THIS | Top Common Mistakes by Java Developer Best Coding Practices Code Decode

preview_player
Показать описание
In this video of code decode we have covered top programming mistakes done by experienced java programmers and best coding practices also

Udemy Course of Code Decode on Microservice k8s AWS CICD link:

Course Description Video :

Not using Transparent and User-Friendly Naming Conventions
Before you get too deep into your project, make sure you give clear names to classes, interfaces, methods, and variables.

Remember, big software projects can have lots of different teams working on them. So, it's really important to agree on one way of naming things. That way, everyone is on the same page and it's not confusing.

Not using Transparent and User-Friendly Naming Conventions
Here are some simple guidelines for creating clear and easy-to-understand names in your code:

Classes: Use only nouns, and start their names with a capital letter.
Packages: Use all lowercase letters for package names.
Interfaces: start with a capital letter and capitalize each new word.
Variables: You can mix uppercase and lowercase letters in variable names.
Methods: Use verbs for method names and capitalize the first letter of each word.

Empty Catch Blocks

In Java, we use try-catch blocks to deal with problems that might happen in our code. We put the code that might cause issues inside the "try" block, and if something goes wrong, we use the "catch" block to handle it.

Imagine if something unexpected, like dividing by zero or not finding a file, happens in the "try" block. The "catch" block helps us manage these problems.

Now, it's technically possible to have an empty "catch" block, but it's a bad idea. An empty "catch" block doesn't tell us what went wrong in our code, which makes fixing bugs much harder. So, it's better to have a meaningful "catch" block that provides information about the problem.

Using String For String Manipulation

The main difference between StringBuilder/Buffer and regular String objects is that String objects cannot be changed once created (they're immutable), but StringBuilder/Buffer objects can be modified.

Now, there's a thing called the "String Constant Pool." When you create a String object, it takes up some memory in this pool. If you change the String, it creates a new memory space each time you make a change, which isn't efficient and wastes memory.

On the other hand, StringBuilder and StringBuffer objects are allocated memory in the computer's main storage area (HEAP) just once. When you modify the text in them, it changes within the same memory space, which is more memory-efficient and avoids waste.

Ignoring DRY & KISS Principle

DRY = Don’t Repeat Yourself
KISS = Keep It Simple Stupid
DRY is a basic principle of software development aimed at reducing repetition of information. The DRY principle is stated as, “Every piece of knowledge or logic must have a single, unambiguous representation within a system.”

Divide your code and logic into smaller reusable units and use that code by calling it where you want. Don’t write lengthy methods, but divide logic and try to use the existing piece in your method.

KISS is a design principle which states that designs and/or systems should be as simple as possible. Wherever possible, complexity should be avoided in a system — as simplicity guarantees the greatest levels of user acceptance and interaction.

Hibernate Interview Questions and Answers:

Spring Boot Interview Questions and Answers:

Subscriber and Follow Code Decode

#commoncodingmistake #codedecode #bestcodingpractices
Рекомендации по теме
Комментарии
Автор

#7:30 timestamp was for me. I wish if I could add you as reviewer on my pr in my company. Many more things to learn on being a software developer. Thanks!

akashsaha
Автор

Thanks for sharing nice content 😊looking forward for much more videos👍It is very helpful.

hanishchemuduru
Автор

We needs a second part mam. Please upload :)

PriyankaManeesh-ow
Автор

Please add more to this list. Very helpful video.

abhishekanand
Автор

Could you please continue on this content.. it's very helpful

saikanaparthy
Автор

That entry set tip is new to me, thank you madam

lunatichigh
Автор

please do java interview questions for 0-1yr experience, i cant find this kind of resource in yt, even if they r present they r very old...

Rajdweep
Автор

isn't the map search operation O(1) time complexity, if it isn't so, what is the point of the map over the array if it does a linear search for an element

please correct me if my understanding is wrong

Feedback Appreciated.

jskr
Автор

Please create second video.. Its very helpfull...

prathyushamovva
Автор

Please provide video on Spring WebFlux interview questions

pranawkaushal