Skip to main content

Timeline for Interface with virtual keyword

Current License: CC BY-SA 3.0

16 events
when toggle format what by license comment
Jan 12, 2015 at 7:54 comment added Monalisa Das @AmatorVitae : please elaborate this line "when extending interfaces, it's possible to add methods already declared by a parent because the methods haven't been defined by the implementation yet, so there's no defined function to override"
Jan 11, 2015 at 5:09 comment added Andrii Muzychuk it seems interface has virtual by default, wether you put it or not. Will know. Thanks.
Jan 9, 2015 at 14:23 history edited Scott Pelak CC BY-SA 3.0
added 19 characters in body
Jan 9, 2015 at 14:21 comment added Scott Pelak Using this isn't necessary, but I love it. For me, it helps me differentiate between instance and static methods + by writing it, it reinforces the method is an instance method for my class. It gets more useful as code gets more complex.
Jan 9, 2015 at 9:45 comment added Monalisa Das One more thing I would like to add on you have used this.instanceVariableName inside an instance method using this inside instance method is optional. It makes code unnecessary lengthy :)
Jan 9, 2015 at 9:37 comment added Monalisa Das I found two contradictory explanation from your end. 1.virtual keyword shows that interface can be extended. You are not able to extend interface (or a class) if it isn't defined with virtual keyword. 2. concerning interfaces, the virtual keyword doesn't really do anything. Please be specific with your answer!
Jan 9, 2015 at 9:35 comment added Monalisa Das I find your explanation misleading!!!Your explanation - " When extending an interface, I can re-declare a method from a parent without using override". We never use override keyword while implementing interface's method! It will give you compile error.The reason being if we are implementing the interface then it is must to override. We use it in context of extending a class where overriding the inherited method is optional. Please correct if I've misunderstood your explanation.
Jan 8, 2015 at 15:11 history edited Scott Pelak CC BY-SA 3.0
added 830 characters in body
Jan 8, 2015 at 15:05 comment added Scott Pelak Yes, concerning interfaces, the virtual keyword doesn't really do anything. If I remove virtual from the Cleanable interface, everything still complies. When extending an interface, I can re-declare a method from a parent without using override because there is no method to override yet.
Jan 8, 2015 at 15:02 history edited Scott Pelak CC BY-SA 3.0
addition
Jan 8, 2015 at 13:53 comment added Monalisa Das "Declaring a class or interface virtual allows the class or interface to be extended." This sounds good in case of class but interface are meant to be overridden as they are 100 % abstract class. It serves no purpose if can not be overridden. Cleanable interface in your above code can be overridden even if I declare it without any virtual keyword
Jan 7, 2015 at 15:38 history edited Scott Pelak CC BY-SA 3.0
deleted 8 characters in body
Jan 7, 2015 at 15:33 comment added Scott Pelak the code's cleaned up and compiles
Jan 7, 2015 at 15:32 history edited Scott Pelak CC BY-SA 3.0
added 56 characters in body
Jan 7, 2015 at 13:39 comment added Monalisa Das your code has many syntax errors! so have to correct it first and then understand it!!
Jan 6, 2015 at 18:16 history answered Scott Pelak CC BY-SA 3.0