Hello,
when writing function libraries: what is the best approach to write function libraries?
I have Lib1, namespace Lib1 with a static Functions class
then Lib2, namespace Lib2, with a static Functions class
and in the application I would like to use functions from both classes, using
using Lib1
using Lib2
and not using
static using Lib1
static using Lib2
Wolfgang
functions in different libraries
functions in different libraries
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
functions in different libraries
Hi Wolfgang
Suggest you put the static functions in different namespaces.
Otherwise, if I understand correctly, things will always clash.
Terry
Suggest you put the static functions in different namespaces.
Otherwise, if I understand correctly, things will always clash.
Terry
functions in different libraries
Hi Terry,
yes, I had this always.
Wolfgang
yes, I had this always.
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: 50
- Joined: Fri Feb 16, 2018 7:52 am
functions in different libraries
Hi,
The normal thing to do is to always state the classname when using static methods.
NiceClassInLib1.NiceStaticMethod()
/Mathias
The normal thing to do is to always state the classname when using static methods.
NiceClassInLib1.NiceStaticMethod()
/Mathias
functions in different libraries
Hi Mathias,
yes, but I would let out the static class name... And in different libraries I need to specify different class names.
It would be a nice thing if for every library a static class couldbe defined that delivers the available functions.
Wolfgang
yes, but I would let out the static class name... And in different libraries I need to specify different class names.
It would be a nice thing if for every library a static class couldbe defined that delivers the available functions.
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: 50
- Joined: Fri Feb 16, 2018 7:52 am
functions in different libraries
If the functions are organized in different classes the namespace + classname + method name is the reference to the method. This is highly related to the old question about function naming.
ArrayHelper.Add()
IntegerHelper.Add()
In the example above the class name makes the code more readable and makes it possible to use shorter method names. What are the alternatives?
Helper.ArrayAdd()
Helper.IntegerAdd()
?
When using third party libraries sometimes class name collisions occur. In that case you have to use the namespace to refer to the correct class. This is similar to that problem.
/Mathias
ArrayHelper.Add()
IntegerHelper.Add()
In the example above the class name makes the code more readable and makes it possible to use shorter method names. What are the alternatives?
Helper.ArrayAdd()
Helper.IntegerAdd()
?
When using third party libraries sometimes class name collisions occur. In that case you have to use the namespace to refer to the correct class. This is similar to that problem.
/Mathias
functions in different libraries
I agree with Mathias.
Creating a namespace with its classes will avoid conflicts and also bugs!
Creating a namespace with its classes will avoid conflicts and also bugs!
functions in different libraries
Wolfgang,
You could use:
Static Myfunction()
Static Global MyProperty
Visible only to the Module. But not a class. Can implement difference behavior without all the renaming of common functions.
I get your desire to have a standard approach to library behavior. I think thats what you want at least.
Cheers,
Paul
You could use:
Static Myfunction()
Static Global MyProperty
Visible only to the Module. But not a class. Can implement difference behavior without all the renaming of common functions.
I get your desire to have a standard approach to library behavior. I think thats what you want at least.
Cheers,
Paul
functions in different libraries
Hi all,
using the own namespace for every library was always planned.
But I tought I could build a static "Functions" class in every library to have the static methods usable as functions in the dependent applications.
But since I use the Core dialect, probably I had to read the documentation first.
For the Vulcan and the VO dialect, the topic "Function class name" says:
"<AssemblyName>.Functions (DLLs)
<AssemblyName>.Exe.Functions (EXEs)
<AssemblyName>.Exe.$<ModuleName>$.Functions for static functions and globals"
whereas for the Core dialect:
"Functions
X$<ModuleName>$Functions for static functions and globals"
But I will make a static class in every lib, with a different name:
Lib1, namespace Lib1, static class Lib1Funcs
Lib2, namespace Lib2, static class Lib2Funcs
Strung functions for example will be in their own static class, but the problem may be that in the large VO functions library we have only to remember the function name. If the functionality is splitted over too many static classes, there is much more to write and much more to remember.
Wolfgang
using the own namespace for every library was always planned.
But I tought I could build a static "Functions" class in every library to have the static methods usable as functions in the dependent applications.
But since I use the Core dialect, probably I had to read the documentation first.
For the Vulcan and the VO dialect, the topic "Function class name" says:
"<AssemblyName>.Functions (DLLs)
<AssemblyName>.Exe.Functions (EXEs)
<AssemblyName>.Exe.$<ModuleName>$.Functions for static functions and globals"
whereas for the Core dialect:
"Functions
X$<ModuleName>$Functions for static functions and globals"
But I will make a static class in every lib, with a different name:
Lib1, namespace Lib1, static class Lib1Funcs
Lib2, namespace Lib2, static class Lib2Funcs
Strung functions for example will be in their own static class, but the problem may be that in the large VO functions library we have only to remember the function name. If the functionality is splitted over too many static classes, there is much more to write and much more to remember.
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