Open glatiuden opened 3 years ago
Hi,
All abstract, default, and static methods in an interface are implicitly public, so you can omit the public modifier.
So I would say either +
or leave it empty, but not ~
So I would say either
+
or leave it empty, but not~
I agree, protected doesn't make any sense since interfaces are API contracts. Though with that said, it is possible to have private methods within an interface with its own set of rules, see here if interested. But those private interface methods shouldn't be represented anyway, since it affects the high level views that UML diagrams are supposed to show, hence leaving it empty should be unambiguous that the interface methods stated are all public.
So I would say either
+
or leave it empty, but not~
But those private methods shouldn't be represented anyway, since it affects the high level views that UML diagrams are supposed to show, hence leaving it empty should be unambiguous that the interface methods stated are all public.
I do see private methods/variables appearing in some of the textbook's UML examples though, not sure if it is an actual concern?
I do see private methods/variables appearing in some of the textbook's UML examples though, not sure if it is an actual concern?
We can probably discuss the relevant examples? At least from what I can gather, the private interface methods seems to be more relevant for implementation rather than with the public contract aspect of the interface.
I do see private methods/variables appearing in some of the textbook's UML examples though, not sure if it is an actual concern?
We can probably discuss the relevant examples? At least from what I can gather, the private interface methods seems to be more relevant for implementation rather than with the public contract aspect of the interface.
Oh you are referring only to private methods in the context of the interface, then I have no examples. Class wise private methods and variables do appear to be included in UML.
Hi! I was attempting the practice exam part 2 earlier on and noticed that the
update()
method in theWatcher
interface is set as public (+
). I understand that interface methods doesn't allow access modifiers, so I'm a bit confused with the solution. Is it fine if I declare it as~
or leave it empty instead? Thank you!
Hi, I was just wondering if someone could explain why there an update(int) method for UiWidget? I know it inherits from ProgressWatcher which in turn implements Watcher (which is where I assume to method comes from) but do we have to write all the methods that are inherited from? thanks
but do we have to write all the methods that are inherited from?
There is no special treatment for inherited methods. They are optional to show, just like regular methods.
@damithc, got it, thanks prof
Hi! I was attempting the practice exam part 2 earlier on and noticed that the
update()
method in theWatcher
interface is set as public (+
). I understand that interface methods doesn't allow access modifiers, so I'm a bit confused with the solution. Is it fine if I declare it as~
or leave it empty instead? Thank you!