VOOZH about

URL: https://dzone.com/users/2874406/mariancostea.html

⇱ Constantin Marian - DZone Member


Constantin Marian

Senior Java Developer

Chisinau, MD

Joined Sep 2016

https://www.linkedin.com/in/constantin-marian

Stats

Reputation: 385
Pageviews: 397.5K
Articles: 2
Comments: 8

Articles

Java Memory Management
This deep dive into Java memory management will enhance your knowledge of how the heap works, reference types, and garbage collection.
Updated February 19, 2021
· 363,348 Views · 185 Likes
Making an Exception-Handling Mechanism
Follow one dev's thoughts on how you should handle exceptions, ranging from dealing with your catch blocks to using try-with-resources to avoiding using them at all.
October 20, 2016
· 34,182 Views · 43 Likes

Comments

Java Memory Management

Sep 02, 2021 · Constantin Marian

Article is based on JDK 8 mainly

Java Memory Management

Jan 20, 2021 · Constantin Marian

Agree, the numbers are just examples, but definitely to make it close to reality I will adjust as you suggest. Thanks

Java Memory Management

Nov 30, 2018 · Constantin Marian

It depends on GC type. F.e. G1C brings this application pause to minimum, however there are phases when GC runs that still need a full application pause. Please see the "Garbage collector types" in this article

Java Memory Management

Mar 03, 2018 · Constantin Marian

When first GC happens, objects are moved into survivor (S0) space, and when GC happens the second time objects from young gen that survive, are moved already to second survivor (S1) space. At this point also those who survive GC from S0, are also moved to S1 memory space. Hope that I answered your question.

Java Memory Management

Jan 13, 2018 · Constantin Marian

Hi,
In the article itself you can find examples of strong, weak and soft references, and how to create those. Static is a bit something else. When you have a static variable , this means it belongs to the class, and you reference to it with the class name. This variable is shared among all created objects (instances) of that class.

Making an Exception-Handling Mechanism

Oct 21, 2016 · Constantin Marian

That's arguable! This is not an anti-pattern. The problem you mentioned is more like not having duplicate exception handlers. But you can handle the exception partially, and then rethrow it, or rethrow a wrapped exception.

Making an Exception-Handling Mechanism

Oct 21, 2016 · Constantin Marian

It's indeed a good practice to wrap the low level exceptions into your custom exception, but ony if it's the case. Sometimes you may want to throw different types of exceptions, because you want to give the possibility to the caller to handle them different. e.g. A service is calling DAO's method for deleting an object, and could be that the object doesn't exist anymore in the database, but also could be that the object is locked for an update. In this case, you might need to throw different type of exceptions. In this way, you let the service layer to decide what to do next, simply return a nice message or trigger a retry action.

Making an Exception-Handling Mechanism

Oct 21, 2016 · Constantin Marian

SQLExceptions and IO exceptions are low level exceptions. If you want to handle that type of exceptions at a higher level, the best way to do this is to wrap your low level exception into a custom exception. A high level API doesn't need to know the reason why an SQL or IO exception was raised. Only you want to see in a higher level API is an explicit message, containing the reason of what went wrong. So, don't hesitate to catch low level exceptions, get the useful info from them (log them as well if it's the case) , wrap them into a higher level exceptions with a meaningful message, and retrow them

User has been successfully modified

Failed to modify user

Let's be friends: