anchitbhatia / Distributed-messaging-system

dsd-pub-sub-project-anchitbhatia created by GitHub Classroom
1 stars 0 forks source link

Generics vs Objects #3

Open adelgadocabrera opened 2 years ago

adelgadocabrera commented 2 years ago

I honestly don't know which one is a best practice. Personally, I feel like generics are more elegant but perhaps it is a topic we could ask in class.

So instead of using Object I would rather use a generic.

https://github.com/CS682-S22/dsd-pub-sub-project-anchitbhatia/blob/1cdf79e83816160c8ea636020afb70f7988ad19b/src/main/java/utils/Helper.java#L41

anchitbhatia commented 2 years ago

Yes generics would have been more elegant. But i am wondering if there are any performance benefit that one has over the other? I need to research for a quick comparison between using Object class and using Generics.

adelgadocabrera commented 2 years ago

I have never used Object and tbh, I don't think there is going to be any performance diff (I might be surprised) I think it is just more elegant because it is informing the developer about dynamically typed class.