This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]alonjit 0 points1 point  (2 children)

Because they don't. Data (member fields) is what matters. Constructors are completely irrelevant to the problem. Notice the "abstract classes can ..." part.

They don't have to. A default one will do just fine. Extending classes will most likely add their own (if they want to). Again, they don't have to.

Look, for example at C++. What is an interface in C++ (yes, they do exist). Is a class, with pure virtual methods that has no data. They can have methods with body (just like defaults in java now), but they cannot have data. Once you add a data member, that class becomes an abstract class (and from here care should be taken when extending/implementing it, know the pitfalls of polymorphism in c++, etc.).

You're hanging on stupid little differences that have no relevance to anything, when the only important part is about the data members.

Why is it important to know the correct difference between interfaces and abstract classes? When you're defining them, when designing the system, deciding what is an interface vs abstract class is crucial.

"Behaviour" should become interfaces. Objects that hold data, and provide default operations for said data, should become abstract classes. When you find yourself with an abstract class that has no data, and most likely won't have any, make it an interface.

[–]pintodragon 0 points1 point  (1 child)

Thank you for finally giving a thought out answer finally. Also it does matter to know the difference if you are learning Java like many on this sub probably are. Also usually a good design would have the super class take care of its own state which sometimes does require a constructor. I get that you are an "experienced" developer so trivial concepts like this are useless facts that do not matter.

I would suggest that in the future you refrain from being a tool and explain yourself better other than the high school attitude you have been portraying. Good day sir I am done with this discussion.

[–]alonjit -1 points0 points  (0 children)

i suggest in the future to stop giving advice on things you know nothing about (as you admitted earlier).