« first day (4108 days earlier)      last day (832 days later) » 

12:00 AM
We all like praise, but a hike in our pay is the best kind of ways. (source)
 
 
5 hours later…
5:24 AM
Thanks @Wietlol, Got the idea
@Wietlol Not really clear about this 'shouldn't catch exception thing', can you explain it again
 
 
3 hours later…
8:16 AM
you shouldnt catch the exception
if your config cannot be read, for whatever reason, you return null
now, the code using the returned value has to do a null check to see if the config was read successfully
and if it wasnt, will probably throw an exception because it cant do what you wanted it to do
so, why hide the meaningful exception by throwing a more generic exception if you can just let the meaningful exception be thrown further up the stack?
also, if the value is null, is it because there is an error or because the value was optional and null is a perfectly fine return value?
when you catch an exception, you either
- rethrow an exception
- try the same operation using a different way
- log the error (and this better be at some root of your application, like the main function, a controller or an event listener)
 
8:58 AM
wow, never thought that way thanks @Wietlol.
 
 
2 hours later…
10:41 AM
The main drawback with this code is that you loose type information of the returned value, although you do pass this as an input. It is not actually using correctly the generic features of java.

public <T> T getJsonStringToDTO(String dTOJson, Class<T> classType) {
T intentDto = null;
try {
intentDto = Obj.readValue(dTOJson, classType);
} catch (IOException e) {
LOGGER.error("Unexpected error while converting intent config json to intent config dto:", e);
}
return intentDto;
}


You could use something like that to make use of the class type.
 
 
3 hours later…
2:06 PM
posted on January 21, 2022

archive - contact - sexy exciting merchandise - search - about ← previousJanuary 21st, 2022nextJanuary 21st, 2022: The video game adaptation of my (and Bill S.'s) book TO BE OR NOT TO BE is out on Switch! Music! Narration! Multiple playable characters! Plus now you can play it / read it on the go! You probably should!– Ryan

 
2:33 PM
Yeah makes sense, thanks @SpyrosK
 
Can I ask you a question regarding memory-consumption?
 
What is it
 
 
2 hours later…
4:57 PM
@Zoe I should make Oak say this. :D
 
Zoe
5:29 PM
Yes please :p
 
 
2 hours later…
7:27 PM
Hi, whats the difference between
public abstract <T> Animal<T> constructSomething();
and
public abstract Animal<?> constructSomething();

And, Are they both same? If so, which one is preferred?
 
 
2 hours later…
8:59 PM
in the first case, you have an additional parameter, which is the T type
you can specify that you want an Animal<Cat> for example by calling factory.<Cat>constructSomething()
usually, this T type is paired by some other parameters
such as a Class<T> or a List<T> or just a T
 

« first day (4108 days earlier)      last day (832 days later) »