Charing Code with multiple projects

  • Thread starter Thread starter Scott Townsend
  • Start date Start date
S

Scott Townsend

So I'm trying to Write a Backend to something and in testing I decided to
create a generic front end app that can simulate the passed in Data.

So I have 2 projects in my solution, though I'm finding that I've created
classes, structs, enums, constants that are going to be neede by both.

I don't want to have one project reference the other as they are not
'related' I want some 3rd project or something that I put all the stuff in.
Then I'm not sure what to put them in once they are in this 3rd Project.
CodeFile, Module, Class file, etc...

Okay, so this is a total noob Q, but I'm just used to the #INCLUDE and just
point to it and it all works. Seems like I cant define some things (i.e.
CONST) out of the Class scope, and I can only do that if its in a Module,
though the module does not seem to be seen by the other projects?

Okay, Maybe I need to go back to Pascal...

Thanks,
Scott<-=
 
Scott Townsend said:
So I'm trying to Write a Backend to something and in testing I
decided to create a generic front end app that can simulate the
passed in Data.

So I have 2 projects in my solution, though I'm finding that I've
created classes, structs, enums, constants that are going to be
neede by both.

I don't want to have one project reference the other as they are not
'related' I want some 3rd project or something that I put all the
stuff in. Then I'm not sure what to put them in once they are in
this 3rd Project. CodeFile, Module, Class file, etc...

Okay, so this is a total noob Q, but I'm just used to the #INCLUDE
and just point to it and it all works. Seems like I cant define some
things (i.e. CONST) out of the Class scope, and I can only do that
if its in a Module, though the module does not seem to be seen by
the other projects?

Okay, Maybe I need to go back to Pascal...

It's common practice to put the reusable code into a DLL and reference
it from any project you want.


Armin
 
Scott,

Simple create a library project, this will result in a DLL that you can
reference from everywhere you want.

Cor
 
What about Constants? Seems like they only are available either in a Module
or in a Class, If I want to use them in multiple classes I can put them in a
Module for the Project, but when I put them in a Module for another project,
they cant bee seen?

Thanks,
 
Scott,

Just try to forget constants while you are programming with OOP.

It is mostly a trashbin with all kind of constants which are never used. If
you really need them, then put them in a config.file.

Cor
 
What? You dont use Constants anymore??
So are you talking about the app.config?

How can I share those with Multiple Projects?

I'm developing a Client Server App that will share some common components
(Constants and Functions). I'd like to just have one file/Project with info
it it that both can share.
 
Scott Townsend said:
What about Constants? Seems like they only are available either in
a Module or in a Class, If I want to use them in multiple classes I
can put them in a Module for the Project, but when I put them in a
Module for another project, they cant bee seen?


What about an Enum? Can be outside a class.

Modules are rarely used because it's like putting all your files in the
root folder of your hard disc.


Armin
 
Scott Townsend said:
What about Constants? Seems like they only are available either in a
Module or in a Class, If I want to use them in multiple classes I can put
them in a Module for the Project, but when I put them in a Module for
another project, they cant bee seen?

Make sure the access modifier is set to 'Public'. The default modifier is
'Friend'.
 
Scott,

You can forever free to do what you want.

However DLL's with lot of constants only will grow, because you never know
if it is already used and you are creating everytime new versions of the
same DLL's. In other words, you create your own private DLL hell.

But on the other hand, creating config files and place those standard in
your projects will do the same, although then the problem is probably better
to keep in hand.

Cor
 
Back
Top