All Comments
TopTalkedBooks posted at August 20, 2017
TopTalkedBooks posted at August 20, 2017

I use Enums for anything that has multiple nonchanging "type" of something. i.e days of a week.

Why I don't use String in this case is because I can't do switch statement on the String and I can on Enum so for every day of a week I can do something specific.

I also use Enum when working with singleton pattern, Check the Effective Java book CH2(CHAPTER 2 CREATING AND DESTROYING OBJECTS), quote :

"While this approach has yet to be widely adopted, a single-element enum type is the best way to implement a singleton." not gonna paste code read the book it's excellent.

If I were you I'd firstly read Thinking in java chapter Enumerated Types. Then after that Effective Java chapter 6 and you should be good

TopTalkedBooks posted at August 20, 2017

This is an direct excerpt from the excellent book 'Thinking in Java' by Bruce Eckel.

[..] Should you use an interface or an abstract class?

Well, an interface gives you the benefits of an abstract class and the benefits of an interface, so if it’s possible to create your base class without any method definitions or member variables you should always prefer interfaces to abstract classes.

In fact, if you know something is going to be a base class, your first choice should be to make it an interface, and only if you’re forced to have method definitions or member variables should you change to an abstract class.

Top Books
We collected top books from hacker news, stack overflow, Reddit, which are recommended by amazing people.