fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Auto-Implement Interfaces

Auto-Implement Interfaces 2 years 4 months ago #1

  • Frank Maraite
  • Frank Maraite's Avatar Topic Author
  • Offline
  • Posts: 169
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.

Auto-Implement Interfaces 2 years 4 months ago #2

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.

Auto-Implement Interfaces 2 years 4 months ago #3

  • wriedmann
  • wriedmann's Avatar
  • Away
  • Posts: 1423
  • Karma: 6
Hi Chris,

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

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

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

Auto-Implement Interfaces 2 years 4 months ago #4

  • Frank Maraite
  • Frank Maraite's Avatar Topic Author
  • Offline
  • Posts: 169
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

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

Auto-Implement Interfaces 2 years 4 months ago #5

  • wriedmann
  • wriedmann's Avatar
  • Away
  • Posts: 1423
  • Karma: 6
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
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

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

Auto-Implement Interfaces 2 years 4 months ago #6

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.

Auto-Implement Interfaces 2 years 4 months ago #7

  • Frank Maraite
  • Frank Maraite's Avatar Topic Author
  • Offline
  • Posts: 169
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

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

Last edit: by robert.

Auto-Implement Interfaces 2 years 4 months ago #8

  • wriedmann
  • wriedmann's Avatar
  • Away
  • Posts: 1423
  • Karma: 6
Hi Chris,

thank you very much! Indeed this are personal preferences.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

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

Auto-Implement Interfaces 2 years 4 months ago #9

  • Frank Maraite
  • Frank Maraite's Avatar Topic Author
  • Offline
  • Posts: 169
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.

Auto-Implement Interfaces 2 years 4 months ago #10

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.

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

Last edit: by robert.

Auto-Implement Interfaces 2 years 4 months ago #11

  • Frank Maraite
  • Frank Maraite's Avatar Topic Author
  • Offline
  • Posts: 169
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.

Auto-Implement Interfaces 2 years 4 months ago #12

  • wriedmann
  • wriedmann's Avatar
  • Away
  • Posts: 1423
  • Karma: 6
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
Wolfgang Riedmann
Meran, South Tyrol, Italy
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

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

  • Page:
  • 1