![]() |
VOOZH | about |
Joined Jul 2017
https://www.programmergate.com/
Senior software engineer with 5 years of experience in software design, development and integration. Author of www.programmergate.com blog which provides essential articles and tutorials about software engineering and java technology. ' Twitter: @houssein_terek
Stats
| Reputation: | 929 |
| Pageviews: | 2.0M |
| Articles: | 11 |
| Comments: | 14 |
Comments
Mar 23, 2018 · Hussein Terek
Check this http://programmergate.com/category/spring-boot/
Dec 14, 2017 · Hussein Terek
If you return a clone instance from getAge(), then the caller will be accessing a completely separate instance of Age.
Hence the age of Alex will not be affected.
Dec 14, 2017 · Hussein Terek
Seems to be interesting, would definitely check it.
Dec 14, 2017 · Hussein Terek
Immutable classes are beneficial in any environment as you stated.
Most developers tend to relate immutability directly to multi-threaded environments because they can clearly see its advantages.
However, i consider it as one of the common design principles which should be achieved in any long-live software application.
Dec 13, 2017 · Hussein Terek
Exactly, the main benefit of immutable classes is in multithreaded environments, where it's very costly to protect object state from concurrent modifications.
Nov 24, 2017 · Hussein Terek
myInt is a field, it represents the object state and always stored in the heap as i mentioned in the article.
Variables are different from fields, they are normally defined inside methods and store some data. Like when you say:
public void test(){
int myInt = 2;
}
Nov 24, 2017 · Hussein Terek
I didn't say it's different , you can pass static variables as method arguments noone can prevent you.
i am talking from best practices perspective, just wondering what's the point of passing it as method arguments if you already able to access it inside method scope. It's like passing an object and its fields together in method arguments. Hope you got my point
Nov 24, 2017 · Hussein Terek
Can you explain more please ?
Nov 24, 2017 · Hussein Terek
There is no specific handling for static variables when passed as method arguments, they are treated the same as normal variables.
my idea is why do you pass a PUBLIC static variable as method parameter if you're able to access it anyway through the class name, as if you pass an object along with its state in a method arguments this is nonsense too.
Sep 23, 2017 · Marcus Biel
Thanks Marcus.
I like how you explain "why overriding hashcode() alone doesn't force java to ignore memory addresses when comparing 2 objects". Good catch.
I'll definitely update my article to clarify this point.
Regarding my comment, I'm sorry if it looked bad to you, i just wanted to share my opinion and ask for your feedback.
I have no problem if you just delete it.
Sep 22, 2017 · Marcus Biel
If 2 objects are equal, they must have the same hash code.
If 2 objects have the same hash code, it doesn't mean that they are equal.
Overriding equals() alone will make your business fail when working with hashing data structures like: HashSet, HashMap, HashTable. ...
Overriding hashcode() alone doesn't force java to ignore memory addresses when comparing 2 objects.
Check this tutorial.
Jul 27, 2017 · Arun Pandey
Check this article to learn the most efficient way of structuring your web service application so that it's maintainable and open for future changes.
http://programmergate.com/web-service-project-structure/
User has been successfully modified
Failed to modify user
ADVERTISE
CONTRIBUTE ON DZONE
LEGAL
CONTACT US
Let's be friends: