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

TOPIC: functions in different libraries

functions in different libraries 6 months 3 days ago #1

  • wriedmann
  • wriedmann's Avatar Topic Author
  • Away
  • Posts: 1406
  • Karma: 6
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
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.

functions in different libraries 6 months 3 days ago #2

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.

functions in different libraries 6 months 3 days ago #3

  • wriedmann
  • wriedmann's Avatar Topic Author
  • Away
  • Posts: 1406
  • Karma: 6
Hi Terry,

yes, I had this always.

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.

functions in different libraries 6 months 2 days ago #4

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.

functions in different libraries 6 months 2 days ago #5

  • wriedmann
  • wriedmann's Avatar Topic Author
  • Away
  • Posts: 1406
  • Karma: 6
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
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.

functions in different libraries 6 months 2 days ago #6

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.

functions in different libraries 6 months 2 days ago #7

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.

functions in different libraries 6 months 2 days ago #8

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.

functions in different libraries 6 months 2 days ago #9

  • wriedmann
  • wriedmann's Avatar Topic Author
  • Away
  • Posts: 1406
  • Karma: 6
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
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