<p>I apologize for asking such a generalized question, but it's something that can prove challenging for me. My team is about to embark on a large project that will hopefully drag together all of the random one-off codebases that have evolved through the years. Given that this project will cover standardizing logical entities across the company ("Customer", "Employee"), small tasks, large tasks that control the small tasks, and utility services, I'm struggling to figure out the best way to structure the namespaces and code structure.</p>

<p>Though I guess I'm not giving you enough specifics to go on, <strong>do you have any resources or advice on how to approach splitting your domains up logically</strong>? In case it helps, most of this functionality will be revealed via web services, and we're a <strong>Microsoft</strong> shop with all the latest gizmos and gadgets.</p>

<ul>
<li>I'm debating one massive solution with subprojects to make references easier, but will that make it too unwieldy? </li>
<li>Should I wrap up legacy application functionality, or leave that completely agnostic in the namespace (making an <code>OurCRMProduct.Customer</code> class versus a generic <code>Customer</code> class, for instance)? </li>
<li>Should each service/project have its own <code>BAL</code> and <code>DAL</code>, or should that be an entirely separate assembly that everything references? </li>
</ul>

<p>I don't have experience with organizing such far-reaching projects, only one-offs, so I'm looking for any guidance I can get.</p>

[{'answer_id': 12247, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 5, 'selected': True, 'text': "<p>There's a million ways to skin a cat.  However, the simplest one is always the best.  Which way is the simplest for you?  Depends on your requirements.  But there are some general rules of thumb I follow.</p>\n\n<p>First, reduce the overall number of projects as much as possible.  When you compile twenty times a day, that extra minute adds up.  </p>\n\n<p>If your app is designed for extensibility, consider splitting your assemblies along the lines of design vs. implementation.  Place your interfaces and base classes in a public assembly.  Create an assembly for your company's implementations of these classes.  </p>\n\n<p>For large applications, keep your UI logic and business logic separate.  </p>\n\n<p>SIMPLIFY your solution.  If it looks too complex, it probably is.  Combine, reduce.</p>\n"}, {'answer_id': 12248, 'author': 'Rob Cooper', 'author_id': 832, 'author_profile': 'https://Stackoverflow.com/users/832', 'pm_score': 2, 'selected': False, 'text': '<p>I recently experienced the exact same at work. Lots of ad-hoc code that needed to be structured and organised.</p>\n\n<p>Its real hard at first, since there is so much. I think the best advice I could give is to just <strong>invest time in it</strong> on the wind down on a Friday afternoon, for a couple of weeks I would just pick an app/chunk of code, examine what was there, think about what we could make generic, copy it, put it into the new library wherever I thought it should be. Once I had all the code within an application migrated, I would then work on refactoring the application to work from the common framework.. This sometimes caused problems that needed to be fixed, but so long as your thorough it shouldn\'t be too big a deal.</p>\n\n<p>Piece by piece, thats the only way to do it.</p>\n\n<p>In terms of structure, I tried to kind of mimic the MS namespacing since for the most part its pretty logical (e.g. <em>Company.Data</em> , <em>Company.Web</em> , <em>Company.Web.UI</em> and so on.</p>\n\n<p>One of the major benefits is probably the amount of code dupe removed. Yeah a little refactoring was required in the apps, but the code base is a lot leaner, and in many ways "smarter".</p>\n\n<p>Another thing I noticed is that I would often have problems trying to figure out <em>where</em> to put stuff (in terms of namespacing) since I wasn\'t sure what it belonged to. Now this <strong>really</strong> concerned me, I viewed it as such a bad smell. Since the re-org everything now falls in to space much more nicely. And with the (now very small amount) of application specfic code, they get put into <em>Company.Applications.ApplicationName</em> This helps me really think about business objects a lot more since I dont want too much within this namespace, so I come up with more flexible designs.</p>\n\n<p>Sorry for the long post.. It\'s kind of rambling!</p>\n'}, {'answer_id': 12249, 'author': 'Keith', 'author_id': 905, 'author_profile': 'https://Stackoverflow.com/users/905', 'pm_score': 0, 'selected': False, 'text': "<p>Large solutions with lots of projects can be quite slow to compile, but are easier to manage together.</p>\n\n<p>I often have Unit test assemblies in the same solution as the ones they're testing, as you tend to make changes to them together.</p>\n"}, {'answer_id': 12253, 'author': 'Jedi Master Spooky', 'author_id': 1154, 'author_profile': 'https://Stackoverflow.com/users/1154', 'pm_score': 2, 'selected': False, 'text': '<p>We name the assemblies in .NET the following way Company.Project.XXXX.YYYY where XXXX is Project and YYYYY is subproject, for example:</p>\n\n<ul>\n<li>LCP.AdmCom.Common</li>\n<li>LCP.AdmCom.BusinessObjects</li>\n<li>LCP.AdmCom.Common.Dal</li>\n</ul>\n\n<p>We take this from a book call <a href="https://rads.stackoverflow.com/amzn/click/com/0321545613" rel="nofollow noreferrer" rel="nofollow noreferrer">Framework Design Guidelines</a>  by Krzysztof Cwalina (Author), Brad Abrams (Author)</p>\n'}, {'answer_id': 12258, 'author': 'Dale Ragan', 'author_id': 1117, 'author_profile': 'https://Stackoverflow.com/users/1117', 'pm_score': 2, 'selected': False, 'text': '<p>For large projects the approach I like to take is to have one Domain namespace for my business objects and then use Data Transfer Objects (DTO\'s) in my layers where storage and retrieval of the business object is needed.  A DTO is a simple object that doesn\'t contain any business logic.</p>\n\n<p>Here is a link that explains a DTO:</p>\n\n<p><a href="http://martinfowler.com/eaaCatalog/dataTransferObject.html" rel="nofollow noreferrer">http://martinfowler.com/eaaCatalog/dataTransferObject.html</a></p>\n'}, {'answer_id': 12267, 'author': 'Seibar', 'author_id': 357, 'author_profile': 'https://Stackoverflow.com/users/357', 'pm_score': 3, 'selected': False, 'text': "<p>My advice, having embarked on a similar undertaking, is to not agonize over the name spaces..</p>\n\n<p>Just start developing with a few important loose guidelines, because however you start out, your project is organic, and you <em>will</em> end up reorganizing the name spaces and classes over time.</p>\n\n<p>Don't waste time talking too much about your project. Just do it.</p>\n"}]
['https://Stackoverflow.com/questions/12243', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1212/']