Java is a programming language that was initially developed for interactive television, but over time it has become widespread over everywhere software can be used. Designed with the notion of object-oriented programming, abolishing the complexities of other languages such as C or C++, garbage collection, and an architecturally agnostic virtual machine, Java created a new way of programming. Moreover, it has a gentle learning curve and appears to successfully adhere to its own moto - “Write once, run everywhere”, which is almost always true; but Java problems are still present. I’ll be addressing ten Java problems that I think are the most common mistakes.
Common Mistake #1:
Common Mistake #2:
Common Mistake #3: Forgetting to Free Resources
Common Mistake #4: Memory Leaks
Common Mistake #5: Excessive Garbage Allocation
Common Mistake #6: Using Null References without Need
Common Mistake #7: Ignoring Exceptions
Common Mistake #9: Breaking Contracts
Common Mistake #10: Using Raw Type Instead of a Parameterized One
Neglecting Existing Libraries It's definitely a mistake for Java Developers to ignore the innumerable amount of libraries written in Java. Before reinventing the wheel, try to search for available libraries - many of them have been polished over the years of their existence and are free to use. These could be logging libraries, like log back and Log4j, or network related libraries,...
Common Mistake #2:
Missing the ‘break’ Keyword in a Switch-Case Block
These Java issues can be very embarrassing, and sometimes remain undiscovered until run in production. Fall-through behavior in switch statements is often useful; however, missing a “break” keyword when such behavior is not desired can lead to disastrous results. If you have forgotten to put a “break” in “case 0” in the code example below, the program will write “Zero” followed by “One”, since the control flow inside here will go through the entire “switch” statement until it reaches a “break”.
These Java issues can be very embarrassing, and sometimes remain undiscovered until run in production. Fall-through behavior in switch statements is often useful; however, missing a “break” keyword when such behavior is not desired can lead to disastrous results. If you have forgotten to put a “break” in “case 0” in the code example below, the program will write “Zero” followed by “One”, since the control flow inside here will go through the entire “switch” statement until it reaches a “break”.
Common Mistake #3: Forgetting to Free Resources
Common Mistake #4: Memory Leaks
Common Mistake #5: Excessive Garbage Allocation
Common Mistake #6: Using Null References without Need
Common Mistake #7: Ignoring Exceptions
Common Mistake #9: Breaking Contracts
Common Mistake #10: Using Raw Type Instead of a Parameterized One
0 comments :
Post a Comment