简体   繁体   English

如何在ASP.NET MVC中为项目编写一个好的核心架构

[英]How to write a good core architecture for a project in ASP.NET MVC

I'm going to have to write a big system in January with ASP.NET MVC3 / C#, and need to know how to write a system that will WORK . 我将不得不在1月份用ASP.NET MVC3 / C#编写一个大系统,并且需要知道如何编写一个可以工作的系统。 I do have a bit of experience with ASP.NET MVC and C# but would not call myself an expert. 我对ASP.NET MVC和C#有一些经验,但不会称自己为专家。 It needs to be extensible so that I can extend it later with new features. 它需要是可扩展的,以便我可以稍后使用新功能扩展它。 How would one go about this? 怎么会这样呢? Is there books that explains this topic in detail or should I use trial and error? 是否有书籍可以详细解释这个主题,还是应该使用反复试验?

In short I need to know good design practice in my code thats extend-able for the future. 简而言之,我需要在我的代码中了解良好的设计实践,以便将来扩展。

Regards RaVen 关心RaVen

The System will be a community portal with forums ratings etc. Cant say more than that << Company Policy>>, The forums I can manage because of plenty open source options... But the rest is up to me. 该系统将是一个社区门户网站,有论坛评级等。不能说比“公司政策”,我可以管理的论坛因为有充足的开源选项...但其余的由我决定。

SOLID == Great Success SOLID ==伟大的成功

Follow SOLID principles in any project and you'll do well. 在任何项目中遵循SOLID原则,你都会做得很好。

With regards to core infrastructure/architechure, SharpArchitecture is a good place to start. 关于核心基础设施/架构,SharpArchitecture是一个很好的起点。 It is by no means the perfect solution...BUT they give you a good framework to play with and you can have a working system quickly while learning the concepts that work and don't work over time. 它绝不是完美的解决方案......但是它们为您提供了一个良好的框架,您可以快速拥有一个工作系统,同时学习有效的概念并且不会长时间工作。 Take a look and see what you think. 看一看,看看你的想法。 It uses NHibernate, Castle and MVC. 它使用NHibernate,Castle和MVC。

Test Driven development will ensure quality for your project. 测试驱动开发将确保您的项目的质量。 Be strict with yourself, red green refractor. 严格要求自己,红绿折射器。 One of MVCs strengths is that it's easier to test. MVC的优势之一是它更容易测试。

Professional ASP.NET MVC 2 is a good starting point, though, I would assume that they'll come out with an MVC 3 edition as well. 专业的ASP.NET MVC 2是一个很好的起点,但我认为他们也会推出MVC 3版本。 The NerdDinner tutorial contains a lot of ideas on how to structure your application. NerdDinner教程包含很多关于如何构建应用程序的想法。

Basic advice: work with the MVC architecture, not against it. 基本建议:使用MVC架构,而不是反对它。 Understand your application, especially your data model, and layer that onto your application structure. 了解您的应用程序,尤其是您的数据模型,并将其分层到您的应用程序结构中。 Typically you'll have a controller per model, but not always. 通常,每个型号都有一个控制器,但并非总是如此。

If you want more detailed advice, you'll need to be more specific about your project. 如果您需要更详细的建议,则需要更具体地了解您的项目。 I'd suggest coming up with specific questions about various details of your design as you have them, rather than a single question covering the whole project. 我建议你提出有关设计的各种细节的具体问题,而不是一个涵盖整个项目的问题。 The latter probably won't get the kind of response you desire. 后者可能不会得到你想要的那种反应。

you can use my "awesome" demo as a start 你可以用我的“真棒”演示作为开始

http://awesome.codeplex.com http://awesome.codeplex.com

If it's going to have to be extensible, make sure you write tests. 如果它必须是可扩展的,请确保编写测试。 You'll save yourself sleepless nights in the long run when you fix something, but ended up breaking the entire system. 从长远来看,当你修复某些东西时,你会为自己节省不眠之夜,但最终会破坏整个系统。

As far as how to make things "WORK" - that depends on your ability. 至于如何使事情“工作” - 这取决于你的能力。 Read, and look to improve things, but don't get caught in premature optimization or it will leave you dead in the water. 阅读,并寻求改进的东西,但不要陷入过早优化或它会让你死在水中。

Based upon your edit and your abilities, it might be wiser to select an open source CMS written in ASP.NET MVC and support it. 根据您的编辑和能力,选择用ASP.NET MVC编写并支持它的开源CMS可能更明智。 Your skills are good enough, it sounds like, to learn how to write modules and be part of a larger community. 你的技能足够好,听起来像学习如何编写模块并成为更大社区的一部分。 You do not sound like you really want to write the whole thing because you are timid about your skills, deadlines, etc. Whilst learning the ins and outs of a well written piece of software, one day you may choose to write your own or contribute to a core piece of the software. 你听起来并不是真的想写整篇文章,因为你对自己的技能,截止日期等都很怯懦。在学习一篇写得很好的软件的细节的同时,有一天你可以选择自己编写或贡献到软件的核心部分。 There are several to choose from see my comment above under your question. 有几个可供选择,请参阅我上面的评论。

edit: I also think this will allow you to just start and not worry about every design paradigm people will throw at you for success. 编辑:我也认为这将让你刚刚开始,而不用担心人们会为你取得成功的每一个设计范例。

WhoCanHelpMe is a nice reference application. WhoCanHelpMe是一个很好的参考应用程序。 It's built upon S#arp Architecture which is a good starting point for an MVC-application using domain driven design. 它建立在S#arp架构之上,这是使用域驱动设计的MVC应用程序的良好起点。 That will also help you on the way with wiring IoC and db-stuff. 这也将帮助您在连接IoC和db-stuff时使用。

Remember that not every example and framework will fit your requirements, so do as jFar said, think SOLID and make your own decisions based on principals. 请记住,并非每个示例和框架都符合您的要求,正如jFar所说的那样,考虑SOLID并根据主体做出自己的决定。

You should also look into MEF for extensibility. 您还应该查看MEF的可扩展性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM