Whats the correct code structure?

I am currenly still learning C# and use Visual Studio .Net 2003. However my company got a c# project and had to employ a contractor and i was suppose to help out when i could.
However he looked through some of the work i'd been doing over the last 4 months and said i was setting it all up incorrectly. I have never really coded anything for anyone other than myself and friends.

My code would all be together in 1 or 2 projects. However he said you shoould split it all up.

So you would have lots of Projects, one for classes, one for the interface etc etc

it would look somthing like: (where the name of the solution is 'solution'
solution
solution.classes
solution.interface
solution.etc

How would i call/create instance of a class which is located in the classes project.
I have tired adding a using solution.classes but it didn't work.


Also is this the correct method structure your code?

Kind Regards,
Rob

Comments


  • : it would look somthing like: (where the name of the solution is 'solution'
    : solution
    : solution.classes
    : solution.interface
    : solution.etc
    :

    I suggest this kind of system for namespaces:

    CompanyName.ProjectName.ModuleName

    Where ModuleName is the name of assembly, EXE or DLL.

    : How would i call/create instance of a class which is located in the classes project.
    : I have tired adding a using solution.classes but it didn't work.
    :

    You need to add reference to the class project. Right click the project which is using the class project, select Add Reference, select Projects-tab and double-click the project you want to reference. After this you can use classes like they are "normal" classes inside the current project.

    When deploying your project remember to distribute referenced DLLs also. Visual Studio's deploy project does this automatically (and one-click deployment also, I think).

    :
    : Also is this the correct method structure your code?
    :

    It really depends. If you have code which is shared among multiple EXEs, you might want to move that code to DLL assembly or you have to maintain the same code in many places which is sometimes really hard and frustrating. Same goes for other resources and stuff. But if you have a code which is used in just one place there's really no need to separate it to another assembly file.

    This is relatively easy when doing projects which doesn't use networking but when you start using remoting (or some other similar stuff; serializing objects over network) you need to have same classes in server and client and things can get really messy.
  • :
    : : it would look somthing like: (where the name of the solution is 'solution'
    : : solution
    : : solution.classes
    : : solution.interface
    : : solution.etc
    : :
    :
    : I suggest this kind of system for namespaces:
    :
    : CompanyName.ProjectName.ModuleName
    :
    : Where ModuleName is the name of assembly, EXE or DLL.
    :
    : : How would i call/create instance of a class which is located in the classes project.
    : : I have tired adding a using solution.classes but it didn't work.
    : :
    :
    : You need to add reference to the class project. Right click the project which is using the class project, select Add Reference, select Projects-tab and double-click the project you want to reference. After this you can use classes like they are "normal" classes inside the current project.
    :
    : When deploying your project remember to distribute referenced DLLs also. Visual Studio's deploy project does this automatically (and one-click deployment also, I think).
    :
    : :
    : : Also is this the correct method structure your code?
    : :
    :
    : It really depends. If you have code which is shared among multiple EXEs, you might want to move that code to DLL assembly or you have to maintain the same code in many places which is sometimes really hard and frustrating. Same goes for other resources and stuff. But if you have a code which is used in just one place there's really no need to separate it to another assembly file.
    :
    : This is relatively easy when doing projects which doesn't use networking but when you start using remoting (or some other similar stuff; serializing objects over network) you need to have same classes in server and client and things can get really messy.
    :

    Thanks for the reply really cleared a few issues up.

    I'm just wondering how to structure my major project. I aim to create a Fantasy Football Website in VS.NET c# with a MSDE database back end. I would just create one project and have it contain everything in it, .aspx, .ascx .html .cs everything would be in one project.

    Thanks anyway,

    *Ribbleton_
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories