Mario Casari
mcasari.bsky.social
Mario Casari
@mcasari.bsky.social
Software developer and blogger. Loves Science, Art, Literature, Cinema.

https://linktr.ee/mcasari

Web site: https://codingstrain.com
🟩Example:

public class MainClass {
private HeavyClass heavyObj;

//instead of creating it in the constructor
public HeavyClass getHeavyObj() {
if (heavyObj == null) {
heavyObj = new HeavyClass();
}
return heavyObj;
}
}
#Java #Performance
June 30, 2025 at 6:50 PM
For example:

public class Config {
...
public static String getConfigPath() {
return configPath;
}
}

The configuration path is shared globally, and changing it in one place could affect others.

#Java
June 14, 2025 at 4:04 PM
Is it North Corea?
June 8, 2025 at 1:36 PM
🧵2/2 If, for instance, we define a static list somewhere:

private static final List byteList = new ArrayList<>();

Some parts of the code may keep adding elements without removing them, eventually leading to memory exhaustion.

#Java #MemoryManagement
June 8, 2025 at 1:33 PM
It looks like a painting
June 7, 2025 at 5:39 PM