Code Organization ... Really need advice

S

shapper

Hello,

Lately I have been working with ASP.NET MVC and C#.

I have been building a lot of code and I am struggling to find a good
way to organize it.

I am posting some of the code I have been building:

HTML Helpers
Create new HTML MVC Helpers.
These helpers are used on various projects I am working on.

Example: Html.ToolTip

Papers
Classes that wrap Model (Linq to SQL) classes to add extra
properties and functionality.

Example: PostPaper, TagPaper, ...

ViewData
Classes that contains objects to pass from View to Controller and
vice versa.
These classes are local to the project. But because of similarity I
might use similar in other projects.

Example: PostViewData might contain: List<Post>, Post,
BlogStatistics, ...

Extra Functionallity
Classes that I use to extend some System object functionality.

Example 1: PagedList extends List functionally.
Example 2: SlideShowPro (Contains methods that mantain XML files
for SlideShowPro Flas component)

Assets
Class that contains methods that retrieve some kind of data.

Example: GetCountries returns a SelectList for use in DropDownList
on my project.

I am having some problems with code organization in namespaces.

And, for example, should I add PagedList to a namespace and class of
my own or added it System.Collections.Extension ...

When should I keep something on my namespace or added it to a System
namespace?

Any suggestions would be great.

This is getting confusing.

Thanks,
Miguel
 
J

Jon Skeet [C# MVP]

When should I keep something on my namespace or added it to a System
namespace?

Never add to the System namespace or anything like it. Users will
expect classes in System to be provided by the framework.

The only possible exception for this (IMO) is when you're trying to
provide compatibility for an earlier framework version - e.g.
declaring the Func/Action delegates which are present in .NET 3.5, so
that a 2.0 project can use them and then have a painless upgrade (at
which point they should be removed).

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top