分层应用,属于哪里? [英] Layered Application, what belongs where?

查看:59
本文介绍了分层应用,属于哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,



我正在处理我的第一个分层应用程序。我有3个标准图层,演示文稿,业务逻辑和数据访问。我还有一个共享层,它包含一些属性,助手类等,还包括我的实际业务对象,因此可以在所有层中使用它们。



我使用简单的文本文件作为数据库,没有SQL数据库等,只需要读入和写出完整的文件。我的数据访问层知道如何将我的Business Objects映射到文件并返回。我的业务逻辑层通过接口使用数据访问层转发加载/保存功能并应用一些规则。表示层由我的表单组成,并使用业务逻辑层来获取我的BO并填充控件。这听起来对你们好吗?



我也不确定在哪里放些东西:



1.用户可以从本地源访问文件,也可以通过文件服务器访问文件。基本上我暂时下载文件,然后将其加载到我的程序中。 FTP访问应该在哪个层?我的BOManager会提供SaveLocal / LoadLocal和SaveOnline / LoadOnline方法并使用我的FTPClient类。或者我应该创建2个几个Manager类?或者FTP访问属于我的数据访问层?我知道我可能在考虑这个问题,但是,我想尽早学习正确的方法。



2.必须有一些信息用户是否已经指定了文件名和位置,因此我的程序可以在第一次保存后使用这些信息。我会将这些内容放入我的业务逻辑层或UI中吗?



3.我的BO持有我想用不同单位输出的值。例如,我有一个温度值。用户可以选择是否要使用°F或°C。在内部,我总是希望将它存储为开尔文。我会把Logic转换成这些值?



4.我正在使用一些.ini文件来设置我的程序。读/写它们是否也算作数据访问?我应该创建几个类来管理几个不同的结构化.ini文件,还是只创建一个?



请原谅我糟糕的英语和解释技巧...希望有人可以帮助我。

Hey guys,

I am working on my first layered application right now. I have the 3 standard Layers, Presentation, Business Logic and Data Access. Also I have a Shared Layer, which consists of some Attributes, Helper classes and the like and also my actual Business Objects so they can be used through all Layers.

I am using simple textfiles as database, no SQL Database or the like, and only need to read in and write out full files. My Data Access Layer knows how to map my Business Objects to a file and back. My Business Logic Layer forwards Load/Save functionality by using the Data Access Layer through Interfaces and applies some rules. The Presentation Layer consists of my Forms and uses the Business Logic Layer to get my BOs and populate controls. Does this sound right to you guys?

Also I am not really sure where to put some stuff:

1. The User can access a file from a Local source, or alternatively through a file server. Basically I am downloading the file temporary and then load it into my program. What Layer should that FTP access happen in? Would my BOManager offer SaveLocal/LoadLocal and SaveOnline/LoadOnline methods and use my FTPClient class. Or should I create 2 several Manager classes? Or would FTP access belong into my Data Access Layer? I know I maybe am thinking too much on this, but well, want to learn the right ways as early as possible.

2. There has to be some information around whether the User has already specified a file name and location, so my program can use those Information after the first save. Would I put such stuff into my Business Logic Layer or UI?

3. My BOs hold values which I want to output with different units. For example I have a temperature value. The user will have the option whether he wants to use °F or °C. Internally I always want to store it as Kelvin. Where would I put the Logic to convert those values?

4. I am working with some .ini files to setup my program. Does reading/writing them also count as Data Access? Should I create several classes for managing several different structured .ini files, or just one?

Excuse my bad english and explanation skills please... Hope someone can help me.

推荐答案

选择负责人。



作为温度的一个例子:业务非常明确。它只想要开尔文。但是,只需让用户选择他/她更喜欢在前端输入值的单位。这也清楚地表明前端负责为业务层提供正确的数据,因此必须将其从任何一个转换为开尔文。



对于FTP,我个人不会让业务对FTP等特定技术或任何传输文件的方法负责。今天它是FTP,明天别的东西。业务层应该只关心业务问题而不是特定技术实现。在这种情况下,最大的问题是,您的企业真的关心FTP吗?



祝你好运!
Choose who is responsible.

As an example on temperature: The business is very clear about it. It only wants Kelvin. But, just let the user choose the unit he/she prefers to enter values in the front-end. This also makes very clear that the front-end is responsible for providing the business layer with the correct data and therefor must convert it from whatever into Kelvin.

For FTP, I personally wouldn't make business responsible for specific technology like FTP or whatever method of transporting files. Today it is FTP, tomorrow something else. The business layer should only worry about business matters and not about specific technology implementations. In this case the big question would be, does your business really care about FTP?

Good luck!


这篇关于分层应用,属于哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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