Page 1 of 2
Auto-Implement Interfaces
Posted: Sun Nov 20, 2016 6:30 pm
by Frank Maraite
Hi Chris,
just to late for the latest version. Today I found that right-click on an interface and then 'Implement "Iblabla" Interface members ...' still produces 'VIRTUAL' in front of the method name. 'VIRTUAL' was wrongly forced by vulcan, but is not needed in x# anymore.
PUBLIC CLASS YesNoToBooleanConverter IMPLEMENTS IValueConverter
right-click on IValueConverter gives
VIRTUAL METHOD Convert(value AS OBJECT, targetType AS System.Type, parameter AS OBJECT, culture AS System.Globalization.CultureInfo) AS OBJECT
RETURN NULL
VIRTUAL METHOD ConvertBack(value AS OBJECT, targetType AS System.Type, parameter AS OBJECT, culture AS System.Globalization.CultureInfo) AS OBJECT
RETURN NULL
VIRTUAL should be omitted here.
Frank
Auto-Implement Interfaces
Posted: Sun Nov 20, 2016 7:25 pm
by Chris
Thanks Frank, you are right of course.
I will leave it as it is for vulcan apps, but will change the code generation for x# ones. Very easy to fix of course, I will send you tomorrow a new dll to use.
Chris
Auto-Implement Interfaces
Posted: Mon Nov 21, 2016 7:09 am
by wriedmann
Hi Chris,
personally I like the "virtual" even in X#.
Wolfgang
Auto-Implement Interfaces
Posted: Mon Nov 21, 2016 7:45 am
by Frank Maraite
Wolfgang,
VIRTUAL only makes sense if you design a base class that can be inherited. And only for those members that are subject to be overridden. It is important at this point to do the design accordingly.
In most cases VIRTUAL is useless. It only slows down the program execution.
Frank
Auto-Implement Interfaces
Posted: Mon Nov 21, 2016 8:16 am
by wriedmann
Hi Frank,
yes, I know that, but nevertheless I prefer virtual methods and properties, and specially classes that are implementing interfaces normally are destined to be inherited.
Classes that should be "used" are then inherited from these, and overwrite the methods and properties only when needed.
This way I can define the default behavior in the parent classes and don't need to write code in every subclass.
I have precise ideas now about my systems are to be constructed (finally - after a lot of errors and changes).
Wolfgang
Auto-Implement Interfaces
Posted: Mon Nov 21, 2016 8:22 am
by Chris
Hi Wolfgang,
OK, will make the new behavior optional, with a preferences setting.
Frank, I think it all boils down to personal preferences. My personal view on this is that methods should be either sealed or virtual, never something in between. But I know some people will freak out by reading this
. Just a personal preference..
Chris
Auto-Implement Interfaces
Posted: Mon Nov 21, 2016 8:37 am
by Frank Maraite
Chris,
Chris wrote:My personal view on this is that methods should be either sealed or virtual, never something in between. But I know some people will freak out by reading this
.
you're absolutly right, both what it should be and how some people will react on. That's why I have sealed most of my classes. Did not show in this example however.
I also like to write those impicitly. I like to write "VIRTUAL" and "SEALED" more than deleting defaults. I like explict interface declaration:
SEALED PUBLIC CLASS YesNoToBooleanConverter IMPLEMENTS IValueConverter
METHOD IValueConverter.Convert(value AS OBJECT, targetType AS System.Type, parameter AS OBJECT, culture AS System.Globalization.CultureInfo) AS OBJECT
RETURN NULL
END CLASS
is how it should be. It's subject to permanent refactoring to change whenever I work on old code.
Frank
Auto-Implement Interfaces
Posted: Mon Nov 21, 2016 8:38 am
by wriedmann
Hi Chris,
thank you very much! Indeed this are personal preferences.
Wolfgang
Auto-Implement Interfaces
Posted: Mon Nov 21, 2016 8:39 am
by Frank Maraite
I don't know how this weird formatting applied. I clicked 'Preview' before submit.
Auto-Implement Interfaces
Posted: Mon Nov 21, 2016 9:04 am
by robert
You hade 2 Quote markers in your message. The style sheet wants to center quotes