470 reputation
310
bio website handcraftedgames.com
location United Kingdom
age
visits member for 3 years, 2 months
seen Jul 24 at 12:45

Rabidly inventive game designer & developer.


Aug
6
accepted Why do interfaces require methods over members?
Aug
6
comment Why do interfaces require methods over members?
I must say, thinking about this further, I don't really agree about multiple inheritance. Because what I'm really asking about is whether a representation of data members in interfaces is possible, not whether you can use data members to construct interfaces (which is essentially a C++ abstract class). There is a key difference there.
Aug
6
comment Why do interfaces require methods over members?
Re C++, touché. However, actually there are interfaces in dynamic languages, JS and Python being two that immediately spring to mind. Whether a proponent of statically-typed languages would call these "interfaces", is a whole other discussion that I see no point in getting into. Personally I show little preference for either side of that fence, using as I do a broad range of languages to different purposes.
Aug
6
comment Why do interfaces require methods over members?
Members was meant to refer to "member fields" as opposed to "member functions" which I refer to simply as methods. I'm not sure from which language (if any) I picked up this convention. So given what I'd written, I see your answer, but I guess a comment under my question to clarify would have been more constructive.
Aug
6
revised Why do interfaces require methods over members?
added 6 characters in body
Aug
6
revised Why do interfaces require methods over members?
added 14 characters in body
Aug
6
comment Why do interfaces require methods over members?
OK to use the proper Java terminology, yes, "member fields". Thanks for pointing that out.
Aug
6
comment Why do interfaces require methods over members?
What does that prove? Does that one example prove you will never need simple/direct access to members? No. The point is, it is silly to have wrap members in getters / setters as part of the interface, if the language itself could deal with that automatically.
Aug
6
revised Why do interfaces require methods over members?
deleted 309 characters in body
Aug
6
revised Why do interfaces require methods over members?
Large expansion of the question to clarify that I mean "in a theoretical language"
Aug
6
comment Why do interfaces require methods over members?
OK -- wait a minute. After further thought, please see my edit to the question.
Aug
6
revised Why do interfaces require methods over members?
Large expansion of the question to clarify that I mean "in a theoretical language"
Aug
6
comment Why do interfaces require methods over members?
"Code to an interface, not an implementation"... Right. Sometimes we know these things latently but it takes someone to reason them out as you have done, to really solidify the concepts once again.
Aug
6
comment Why do interfaces require methods over members?
Good answer. I tend to favour composition almost entirely in the sort of tasks I undertake these days. I personally don't believe in the separate treatment of abstract classes and interfaces in certain languages, as others on this board have stated, although there are reasons for this, generally these reasons are due to fundamental language limitations (such as mentioned in my comment on ratchet freak's answer).
Aug
6
awarded  Commentator
Aug
6
comment Why do interfaces require methods over members?
This doesn't answer the question. The question is WHY did they do it that way? Had you ever considered not writing getters and setters for every variable, and still being able to fulfill an interface? That would save time!
Aug
6
comment Why do interfaces require methods over members?
Thanks for coming to reply, it was actually your response on that very topic that got me to ask this question :) But the question remains, "-WHY- did they only allow methods?" The point of interfaces is not to specify methods, that's cyclical logic. The point of interfaces is to ensure that some base degree of functionality is fulfilled. Members can make up part of that functionality. So why not allow them to participate in the interface fulfillment?
Aug
6
answered How do you stop yourself from bringing work home?
Aug
6
comment How do you stop yourself from bringing work home?
I don't think his age has any bearing on answering the question which is "How do YOU...?" I nearly gave this -1 for being familiar and condescending.
Aug
6
awarded  Student