如何使用n层应用程序开发 [英] How to use n-tier application development

查看:65
本文介绍了如何使用n层应用程序开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是.net桌面应用程序开发人员.我使用c#和WPF.我使用SQL Server作为数据库.

I am a .net desktop app developer. I use c# and WPF. I used SQL Server as my database.

现在,我想学习电子,node.js,并想用HTML,CSS和Javascript进行编码.另外,由于上述所有内容都是开源的/免费的,因此我也将更改数据库.现在,我将使用MySQL.

Now I want to learn electron, node.js and would like to code in HTML, CSS and Javascript. Also, as everything mentioned above is open-source/free I would change my database as well. Now I will be using MySQL.

在.net中,我们正在使用n层应用程序开发.我知道n层应用程序开发不是特定于.net,因此我认为使用Atom作为开发工具的电子,node.js,HTML,CSS和Javascript都是可行的.

In .net we were using n-tier application development. I know that n-tier application development is not specific to .net, so I think it's possible with electron, node.js, HTML, CSS, Javascript using Atom as development tool.

在.net中,我的项目的结构如下:

In .net my projects were structured as:

MySolution
   |--Entities
   |    |--Student.cs
   |    |--Teacher.cs
   |--Repositories
   |    |--RepositoryBase.cs
   |    |--StudentRepository.cs
   |    |--TeacherRepository.cs
   |--WPFApp
   |    |--Window.xaml
   |    |--App.xaml
   |    |--App.config

上面提到的结构只是一个小演示.实际上,我们使用了WCF服务等等.对于一个桌面应用程序,我们一直有大约20个项目.

The above mentioned structure is just a small demo. In reality we used WCF services and much more. We always have had near about 20 projects for a single Desktop application.

我想在电子,node.js,HTML,CSS,Javascript和可能的jQuery中做同样的事情.谁能指导我有关他们如何在上述应用程序中使用n层应用程序开发的信息?如果可能的话,任何人都可以发布一个小型的工作演示吗?

I would like to do same in electron, node.js, HTML, CSS, Javascript and if possible jQuery. Can anyone please guide me about how do they use n-tier applicaiton development in above mentioned app?? If possible can anybody please post a small working demo??

推荐答案

我想我已经知道十年了,但是从未听说过被称为"n层",并且查找它. Node.js世界中最常见的多层模式是"MVC".我想您可能已经习惯于这种模式,您自己或.NET圈子中提到的MVVM模式.

I've known about it for 10 years, I'd imagine, but had never heard of it as being referred to as "n-tier" and had to look it up. The most common multi-tiered pattern in the Node.js world, is "MVC". I am guessing you're used to that pattern, yourself, or the MVVM pattern that I've seen mentioned in .NET circles.

无论如何,我只想做出这样的区分,以期希望改善您的搜索结果;在npmjs.org之类的地方,搜索"MVC"可能会比搜索"n-tier"更好.

Anyway, I only wanted to make that distinction in hopes of improving your search results; you will probably find better hits with searches for "MVC" than for "n-tier" in places like npmjs.org.

有几种可用的MVC框架,应该可以直接使用它们进行电子开发.骨干相当流行,是第一个想到的,但是也有很多很多其他人.

There are several MVC frameworks available and they should be drop-in ready for Electron development. Backbone is rather popular, and the first that comes to mind, but there are also many, many, others.

类似于您可能在.NET中使用的多项目结构,您会发现Node.js开发也通常细分为多个模块".假设要以开源形式提供项目,则将其构建为多个NPM模块并将其推入NPM.然后,您将在主项目中使用npm install xxxxx将其全部引入.

Analogous to the multi-project structures you're probably used to in .NET, you will find that Node.js development is, also, typically subdivided into multiple "modules". Assuming you want to offer your project as open-source, you will build it as multiple NPM modules and push each to NPM.. then you will use npm install xxxxx in your main project to bring them all in.

如果您不打算将模块作为开源发布,也可以研究npmjs.org的私有模块服务,或者像我们一样,使用"Sinopia"之类的解决方案托管您自己的模块.

If you are not planning to publish your modules as open source, you can also look into npmjs.org's private module service or, like us, host your own using a solution such as "Sinopia".

迁移到Node.js可能会让人有些不知所措,并且会有很多信息需要吞咽.如果我能提供两个在我的旅途中非常宝贵的建议,我会说:

Migrating to Node.js can be a bit overwhelming and there will be a lot of information to swallow. If I could offer two tips that have been invaluable in my own journey, I would say:

  1. 遵守Node.js及其社区,不要强迫自己遵守.
  2. 始终尝试避免编写代码.您认为可以编写的几乎所有通用的东西都可以在NPMjs.org上找到.实用程序库,框架等.学习其他人的代码很麻烦,但是却值得付出,特别是在开源版本得到良好支持和/或拥有庞大社区的情况下.

此外,在#1上更进一步.您可能会发现,在Node.js圈子中,NoSQL(尤其是MongoDB)通常比MySQL更受青睐.对于那些在SQL上长大的人来说,这是另一个弯腰,但是至少应该仔细考虑一下.

Also, to go one step further on #1 .. you will probably find that NoSQL (especially MongoDB) is often preferred over MySQL in the Node.js circles. Its another mind bender for those of us who grew up on SQL, but you should, at least, carefully consider it.

祝你好运

这篇关于如何使用n层应用程序开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆