Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you organize C# code in to files?

In C#, the questions of what types to create, what members they should have, and what namespaces should hold them, are questions of OO design. They are not the questions I'm interested in here.

Instead, I want to ask how you store these in disk artifacts. Here are some example rules:

  • Put all of an assembly's types in a single source file. One friend who did this said "files are an archiac code organization tool; today I use classview and Collapse to Definitions to browse my code".

  • Put all your code in one assembly. Makes deployment & versioning simpler.

  • Directory structure reflects namespace structure.

  • Each namespace gets its own assembly.

  • Each type goes in its own assembly. (Listed as an extreme example.)

  • Each type gets its own source file.

  • Each member gets its own file; each type gets its own directory. (Listed as an extreme example.)

like image 726
Jay Bazuzi Avatar asked Dec 01 '08 21:12

Jay Bazuzi


People also ask

What are the two main ways a file can be organized in C?

Writing to a file (fprintf or fputs)

What is file structure C?

A FILE is a type of structure typedef as FILE. It is considered as opaque data type as its implementation is hidden. We don't know what constitutes the type, we only use pointer to the type and library knows the internal of the type and can use the data. Definition of FILE is in stdio although it is system specific.


1 Answers

Whatever you do, just PLEASE do it consistently. I don't believe there is any one single answer (though there are a few wrong ones). But just make sure you stay true to your form as this will be the key for your successor(s) to find things easily.

like image 139
chadmyers Avatar answered Sep 20 '22 18:09

chadmyers