fbpx

functions in different libraries

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
4 months 3 days ago #1 by Wolfgang Riedmann
functions in different libraries was created by Wolfgang Riedmann
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

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

More
4 months 3 days ago #2 by Terry Bourne
Replied by Terry Bourne on topic 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

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

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
4 months 3 days ago #3 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic functions in different libraries
Hi Terry,

yes, I had this always.

Wolfgang

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

More
4 months 3 days ago #4 by Mathias Håkansson
Replied by Mathias Håkansson on topic functions in different libraries
Hi,

The normal thing to do is to always state the classname when using static methods.

NiceClassInLib1.NiceStaticMethod()

/Mathias

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

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
4 months 3 days ago #5 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic 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

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

More
4 months 3 days ago #6 by Mathias Håkansson
Replied by Mathias Håkansson on topic 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

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

More
4 months 3 days ago #7 by Jamal
Replied by Jamal on topic functions in different libraries
I agree with Mathias.

Creating a namespace with its classes will avoid conflicts and also bugs!

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

More
4 months 3 days ago #8 by Paul Bartlett
Replied by Paul Bartlett on topic 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

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

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
4 months 2 days ago #9 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic 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

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