创建将由桌面应用程序和网站使用的对象模型时,我应该考虑哪些特殊注意事项?
我正在 C#.Net 中编写一个工具,该工具将用于生成用户可以浏览的内容目录。最初我正在创建一个基于 WinForms 的界面,但将来我也希望能够创建一个基于 Web 的界面。因此,我一直小心地将接口概括为目录,以便它不依赖于特定的 UI。
我唯一的 Web 开发经验是在 90 年代初创建自己的 HTML 网站,并且我编写了一些 ASP(不是 ASP.NET)。现在,有了 ASP.NET,我似乎能够利用现有的 C#.Net 对象模型来创建 Web 基础界面。但除了简单的 hello world 示例之外,我确实没有使用 ASP.NET 做过任何事情。
在设计对象模型时是否应该考虑任何特殊事项,以便稍后我可以为其创建 Web 界面?
I'm writing a tool in C#.Net that will be used to generate Catalogs of content which users can browse. Initially I am creating a WinForms based interface, but in the future I'd like to be able to create a web based interface as well. So I've been careful to generalize the interface to a Catalog so that it does not depend on a specific UI.
My only experience with web development has been creating my own HTML website back in the early 90's, and I've done a little ASP (not ASP.NET). Now with ASP.NET it seems that I should be able to leverage my existing C#.Net object model, to create a web base interface. But I really hasn't done anything with ASP.NET beyond a simple hello world example.
Are there any special considerations I should make in designing my object model so that later I can create a web interface to it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是需要遵循的几件事:
是单独的项目(您需要
无论如何都要分享它
不同的项目)并确保
您不添加特定的
对它的引用(例如,不要
添加 System.Web、WinForms、WPF 等)-
这将自动避免任何
不需要的依赖项。
Here are few things to follow:
is separate project (that you need
to do anyway to share it among
different projects) and make sure
that you do not add specific
references to it (for example, don't
add System.Web, WinForms, WPF etc) -
this will automatically avoid any
unwanted dependencies.
其实不应该有那么大的区别。
请小心不要在实体类中放置过多的“智能”。这是我在 Windows 应用程序中经常看到的模式。不要在项目中要为 Web 应用程序重用的部分中引用特定于 Windows 窗体开发的控件。
存储库模式适用于 Windows 和 Web 应用程序,因为您通常希望针对多个用户的性能以不同方式优化 Web 应用程序。
There really shouldn't be that big a difference.
Be careful about placing too much “intelligence” in your entity classes. That’s a pattern I’ve seen often in Windows apps. Don't make references to controls that are specific to Windows Forms development in the parts of your project that you want to reuse for the web application.
Repository patterns work well with both Windows and Web applications, because you often want to optimize the web apps differently for performance with multiple users.
您的要求可以通过多层架构来处理:
http://en.wikipedia.org/wiki/多层架构
Your requirement can be handled with a multi-tier architecture:
http://en.wikipedia.org/wiki/Multitier_architecture