Auto-Implement Interfaces

This forum is meant for questions and discussions about the X# language and tools
Frank Maraite
Posts: 178
Joined: Sat Dec 05, 2015 10:44 am
Location: Germany

Auto-Implement Interfaces

Post 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
User avatar
Chris
Posts: 4913
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Auto-Implement Interfaces

Post 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
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Auto-Implement Interfaces

Post by wriedmann »

Hi Chris,

personally I like the "virtual" even in X#.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Frank Maraite
Posts: 178
Joined: Sat Dec 05, 2015 10:44 am
Location: Germany

Auto-Implement Interfaces

Post 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
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Auto-Implement Interfaces

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4913
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Auto-Implement Interfaces

Post 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
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Frank Maraite
Posts: 178
Joined: Sat Dec 05, 2015 10:44 am
Location: Germany

Auto-Implement Interfaces

Post 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
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Auto-Implement Interfaces

Post by wriedmann »

Hi Chris,

thank you very much! Indeed this are personal preferences.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Frank Maraite
Posts: 178
Joined: Sat Dec 05, 2015 10:44 am
Location: Germany

Auto-Implement Interfaces

Post by Frank Maraite »

I don't know how this weird formatting applied. I clicked 'Preview' before submit.
User avatar
robert
Posts: 4522
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Auto-Implement Interfaces

Post by robert »

You hade 2 Quote markers in your message. The style sheet wants to center quotes
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply