构建结构良好的服务层
首先,我想说,我已经有一段时间没有深入了解目前的细节了。最近,我非常关注 SharePoint 世界,并且我的整个思维过程在相当长的一段时间内都集中在那里。我很高兴再次创建数据库,编写“较低级别”代码来处理数据访问,等等。
我正在开发一个非常简单的 Web 应用程序,并借此机会重新熟悉我用来构建项目和各个代码层的方式。例如,上次我从头开始构建一些基本的东西时,我可能已经创建了类似的东西:
- MyProject/
-- Domain/
--- Impl/
---- Person
-- Model/
--- IPersonRepository
--- Impl/
---- PersonRepository : IPersonRepository
-- Services
--- IPersonService
--- Impl/
---- PersonService : IPersonService
这将是我实际工作的项目,然后在 ASP.NET 项目中引用。我的方法深受我从 CodeCampServer 项目中看到的启发,因为当时 ASP.NET MVC 还很新,它是我能找到的唯一一个正在积极开发的开放项目,并且由可靠的人员开发。
当涉及到您正在处理的一般问题时,您将采用什么方式来构建您的项目和代码?当然,各种问题都会对此产生限制,但假设这是一个基本问题,没有影响代码结构和布局的特定需求。
First, I want to say that it has been awhile since I've gotten into the kind of detail I am at currently. Lately, I've been very much in the SharePoint world and my entire thought process was focused there for quite some time. I'm very glad to be creating databases again, writing "lower level" code to deal with data access, and so forth.
I'm working on a very simple web application and taking the opportunity to reacquaint myself with the way I used to structure my projects and various layers of code. For instance, I might have created something like this the last time I went about building something basic from scratch:
- MyProject/
-- Domain/
--- Impl/
---- Person
-- Model/
--- IPersonRepository
--- Impl/
---- PersonRepository : IPersonRepository
-- Services
--- IPersonService
--- Impl/
---- PersonService : IPersonService
That would have been the project I did the real work in, and then referenced in the ASP.NET project. My approach was very much inspired by what I saw from the CodeCampServer project as at that time ASP.NET MVC was still very new and it was the only open project I could find actively being developed, and by solid people at that.
What ways are you going about structuring your projects and code, when it comes to a general problem you're working on? Certainly various problems can put constraints on this, but assume it's a basic problem without specific needs that affect the structure and layout of your code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论