fbpx

Auto-Implement Interfaces

More
2 years 1 month ago #1 by Frank Maraite
Auto-Implement Interfaces was created 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

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #2 by Chris Pyrgas
Replied by Chris Pyrgas on topic Auto-Implement Interfaces
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

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #3 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Auto-Implement Interfaces
Hi Chris,

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

Wolfgang

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #4 by Frank Maraite
Replied by Frank Maraite on topic Auto-Implement Interfaces
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
The following user(s) said Thank You: Otto Christiaanse

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #5 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Auto-Implement Interfaces
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

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #6 by Chris Pyrgas
Replied by Chris Pyrgas on topic Auto-Implement Interfaces
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

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago - 2 years 1 month ago #7 by Frank Maraite
Replied by Frank Maraite on topic Auto-Implement Interfaces
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
Last edit: 2 years 1 month ago by Robert van der Hulst.

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #8 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Auto-Implement Interfaces
Hi Chris,

thank you very much! Indeed this are personal preferences.

Wolfgang

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #9 by Frank Maraite
Replied by Frank Maraite on topic Auto-Implement Interfaces
I don't know how this weird formatting applied. I clicked 'Preview' before submit.

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago - 2 years 1 month ago #10 by Robert van der Hulst
Replied by Robert van der Hulst on topic Auto-Implement Interfaces
You hade 2 Quote markers in your message. The style sheet wants to center quotes

XSharp Development Team
The Netherlands
This email address is being protected from spambots. You need JavaScript enabled to view it.
Last edit: 2 years 1 month ago by Robert van der Hulst.

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #11 by Frank Maraite
Replied by Frank Maraite on topic Auto-Implement Interfaces
Wolfgang,

All those modifiers are there to document the intents of the design to the reader of the code and to let the compiler enforce these. So the subject of personal preference can only be: do I prefer clear design or do I prefer sloppy design. I prefer clear design.

BTW: Did you ever think about combining INTERFACE with ABSTRACT? This let's you create a base class that is incomplete and cannot be used directly, but still offers to implement a completly different inheritance chain.

just my 2ct's
Frank

Please Log in or Create an account to join the conversation.

More
2 years 1 month ago #12 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic Auto-Implement Interfaces
Hi Frank,

All those modifiers are there to document the intents of the design to the reader of the code and to let the compiler enforce these. So the subject of personal preference can only be: do I prefer clear design or do I prefer sloppy design. I prefer clear design.


I prefer to have documented the "virtual" on the method name, otherwise I could add it in the compiler options.
I don't think that the use of virtual or not is defining if design is clear or sloppy. I have clear ideas how my application design should be, but of course these ideas are very different from yours as I have a different thinking. And in programming there is not only one truth, but a lot of different styles, some more sloppy, some more clear, but not everyone suited to every programmer or application type.
So I prefer the use of dynamic objects to the generation or the writing of a LOT of code when it comes to models - and I'm sure that many people will not agree here. But I don't see any sense to write hundreds of properties for every possible model class - having to change them every time something in the table structure changes.

BTW: Did you ever think about combining INTERFACE with ABSTRACT? This let's you create a base class that is incomplete and cannot be used directly, but still offers to implement a completly different inheritance chain.


yes, of course. This makes sense, but is work in progress.

Wolfgang

Please Log in or Create an account to join the conversation.