Guys,
I demand on being counted, so the current score is not 3:1 but 3:1,5
BTW. thanks Chris
regards
Karl-Heinz
what is the preferred way - functions/static methods or extension methods
Moderator: wriedmann
-
- Posts: 774
- Joined: Wed May 17, 2017 8:50 am
- Location: Germany
what is the preferred way - functions/static methods or extension methods
Hi Karl-Heinz,
sorry, then the current score is 3,5 : 1,5.
You were half for extension methods on classes and against on basic datatypes.
Wolfgang
sorry, then the current score is 3,5 : 1,5.
You were half for extension methods on classes and against on basic datatypes.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
-
- Posts: 774
- Joined: Wed May 17, 2017 8:50 am
- Location: Germany
what is the preferred way - functions/static methods or extension methods
yes, of course 3,5:1,5
what is the preferred way - functions/static methods or extension methods
Guy,
that i see similiar, as long as you "extend" "your" class - but then, why not write the functionality as part of the class directly.
Wolfgang adds to existing, i.e. , "system classes/types" - here i'm with Chris, usually one knows more or less what to expect from e.g. a string object - and has to wonder, why on earth now there's new functionality; and not to forget: "where" is the definition?
Nothing really wrong with this, but make it a 3.5:2.25
that i see similiar, as long as you "extend" "your" class - but then, why not write the functionality as part of the class directly.
Wolfgang adds to existing, i.e. , "system classes/types" - here i'm with Chris, usually one knows more or less what to expect from e.g. a string object - and has to wonder, why on earth now there's new functionality; and not to forget: "where" is the definition?
Nothing really wrong with this, but make it a 3.5:2.25
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
what is the preferred way - functions/static methods or extension methods
Hi Karl,
An if I have to put one static class "Functions" or "Funcs" or whatever in the library: this one will be contain a lot of functions/static methods that are not related at all.
With extension methods, the source code can be much better organized - and it is less to write. And maybe the names could be shorter.
Wolfgang
this is also the question with all these functions.and has to wonder, why on earth now there's new functionality; and not to forget: "where" is the definition?
An if I have to put one static class "Functions" or "Funcs" or whatever in the library: this one will be contain a lot of functions/static methods that are not related at all.
With extension methods, the source code can be much better organized - and it is less to write. And maybe the names could be shorter.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
what is the preferred way - functions/static methods or extension methods
Wolfgang,
i don't quite see the difference, wethere you have a file/lib "MyFuncs", vs. "MyExtensions"
i don't quite see the difference, wethere you have a file/lib "MyFuncs", vs. "MyExtensions"
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
what is the preferred way - functions/static methods or extension methods
Hi Karl,
With extension methods code like this is possible:
and this works on every object.
Wolfgang
There is a class "StringExtensions", a class "ArrayExtensions", a class "ObjectExtensions" and so forth.i don't quite see the difference, wethere you have a file/lib "MyFuncs", vs. "MyExtensions"
With extension methods code like this is possible:
Code: Select all
if oObject:IsProperty( cPropertyName )
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
what is the preferred way - functions/static methods or extension methods
Extensions methods VS Functions for existing classes. Ex:String
LOCAL cString:="xTE12y45ST " as STRING
//Using Functions. The "Russian dolls" model
cString:= ToUpper(ExtractLetters(left(strTran(AllTrim(cString),"x","a"),6)))
//Using Extensions Methods. The "Chaining model"
String:=cString:Trim().Replace("x","a").Left(6).ExtractLetters().ToUpper()
Result: "ATEY"
Witch style/model do you prefer?
Guy
LOCAL cString:="xTE12y45ST " as STRING
//Using Functions. The "Russian dolls" model
cString:= ToUpper(ExtractLetters(left(strTran(AllTrim(cString),"x","a"),6)))
//Using Extensions Methods. The "Chaining model"
String:=cString:Trim().Replace("x","a").Left(6).ExtractLetters().ToUpper()
Result: "ATEY"
Witch style/model do you prefer?
Guy
what is the preferred way - functions/static methods or extension methods
Hi Guy,
IMHO such a "sausage" of code is very bad coding style - impossible to understand and impossible to debug, and error prone.
But with extension methods is is a lot easier to read than with the "russian dolls" model.
Wolfgang
IMHO such a "sausage" of code is very bad coding style - impossible to understand and impossible to debug, and error prone.
But with extension methods is is a lot easier to read than with the "russian dolls" model.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
what is the preferred way - functions/static methods or extension methods
Guys,
this results in left to right vs. right to left reading - to "like" is neither.
If i' d need that more than once, i'd write an access or a func, properly named
See my request to Robert for a switch to access Dataserverfields "cleaned"...
Karl
this results in left to right vs. right to left reading - to "like" is neither.
If i' d need that more than once, i'd write an access or a func, properly named
See my request to Robert for a switch to access Dataserverfields "cleaned"...
Karl
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)