最佳实践,对象设计 ASP.NET MVC
我有一个代码设计问题困扰了我一段时间,你看我正在重构我的网站 Cosplay丹麦,在这个网站上,cospalyers 可以上传他们穿着服装的照片。原始站点是用 php、Zend MVC 完成的,但我的重构是在 ASP.NET MVC 2 中完成的。
如果您使用该站点 http://www.cosplaydanmark.dk/Costumes/(您可以在左栏(Sprog)中切换到英语)
在这里您可以看到我们网站上所有动漫的列表以及图像,我们显示该动漫下的名称、有多少个不同的角色以及有多少个图像。
http://www.cosplaydanmark.dk/Costumes/Bleach
如果您点击某个动漫,将会您将获得给定动漫中包含图像的角色列表,这里我们显示角色名称、画廊数量和图像数量。
http://www.cosplaydanmark.dk/Costumes/Bleach/Ichigo_Kurosaki/
如果单击角色名称,您将获得给定动漫中给定角色下的图库列表。这里我们有一些关于画廊的信息,例如图像数量。
http://www.cosplaydanmark.dk/Costumes/Bleach/Ichigo_Kurosaki/Admi/< /a>
如果您单击图库,您会获得图库中的图像列表。
我的数据库目前看起来像这样。
数据库设计 http://sogaard. us/uploades/dbdesign.jpg
正如您可能想象的那样,有很多不同的查询来创建站点,在第一个站点上,我需要对“animes”表和每个结果进行选择,我需要对角色和画廊进行计数选择。
我的创建计划将是以下之一
对象计划 http:// sogaard.us/uploades/objectsetup.jpg
其中 IList 将是一个延迟加载列表。
但我无法决定最好的解决方案是什么,以及是否有更好的方法。我的首要任务是获得良好的性能,同时将功能和代码维护的损失降到最低。
我正在使用带有 linq to sql 存储库的服务模式。
我的设计不是绝对的,如果可以提高性能,我愿意改变它:D
我希望我已经足够好地描述了我的问题,让您能够理解我的意思,但请询问我是否遗漏了任何内容。
I have a code design question that have been torbeling me for a while, you see I’m doing a refactoring of my website Cosplay Denmark, a site where cospalyers can upload images of them self in their costumes. The original site was done in php, Zend MVC, but my refactoring is being done in ASP.NET MVC 2.
If you take the site http://www.cosplaydanmark.dk/Costumes/ (You can switch to English in the left column (Sprog))
Here you see a list of all the anime’s we have on the site with images, we show the name, how many different characters and how many images there are under this anime.
http://www.cosplaydanmark.dk/Costumes/Bleach
If you click on an anime will you get a list of characters within the given anime which we have images in, here do we show the character name, how many galleries and how many images.
http://www.cosplaydanmark.dk/Costumes/Bleach/Ichigo_Kurosaki/
If you click on the character name, will you get a list of the galleries under the given character in the given anime. Here we have some information about the gallery, such as image count.
http://www.cosplaydanmark.dk/Costumes/Bleach/Ichigo_Kurosaki/Admi/
Should you click the gallery do you get a list of the images in the gallery.
My database look like this at the moment.
Database Design http://sogaard.us/uploades/dbdesign.jpg
As you can might imagine there are a lot of different query’s to create the site, on the first site I need to do a select on the on the “animes” table and for each result, I need to do a count select on characters and galleries.
My plan to create this will be one of the following
Objects plan http://sogaard.us/uploades/objectsetup.jpg
Where the IList, would be a lazy load list.
But I can’t decide what would be the best solution for this would be, also if there is a better way of doing this. My priority is to have good performance with a minimum lose of features and code upkeep.
I’m using a service pattern with a linq to sql repository.
My design is not absolute, I’m willing to change it if it could increase performance :D
I hope that I have describe my question good enough for you to understand what I mean, but ask away if there are anything I have missed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我个人喜欢能够将 和 绑定到 ,
这样每个 和 都有一个animeId属性,该属性是外键,
这样我就可以执行一个简单的查询 getAllImagesByAnimeId
I personally like to be able to tie the and back to the
So that each and have an animeId property that is a foreign key back to
So that I can do a simple query getAllImagesByAnimeId