DAL / BLL和客户端/服务器:应在客户端使用BLL或DAL对象为presentation?或者,也许另一个层(数据传输对象?) [英] DAL/BLL and Client/Server: Should the client use BLL or DAL objects for presentation? Or maybe another layer (data transfer object?)

查看:149
本文介绍了DAL / BLL和客户端/服务器:应在客户端使用BLL或DAL对象为presentation?或者,也许另一个层(数据传输对象?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个客户机/服务器系统。该服务器有一个DAL / BLL设计。该客户端负责presenting的数据对象,并提供对话和向导,允许用户更新这些对象(即添加/编辑用户)。

I'm writing a client/server system. The server has a DAL/BLL design. The client is responsible for presenting the data objects and providing dialogs and wizard to allow the user to update these objects (i.e. adding/editing a user).

起初我还以为我只是做出DAL对象都有一个通用的数据提供者对象,使他们能够通过在客户端和服务器中使用。例如,当正在使用的服务器的数据对象,该数据库是数据提供者;当数据对象正在使用由客户机,服务器的数据提供

Initially I thought I'll just make the DAL objects have a universal data provider object so they can be used by the client as well as the server. For instance, when the data object is being used by the server, the database is the data provider; when the data object is being used by the client, the server is the data provider.

因此​​,一个对象被以presentation层改变了,例如用户:用户自>的setName(弗雷德),然后提交它像这样用户可>提交(),提交方法调用数据提供者的提交方法,然后连接codeS的对象,并将其发送到服务器。然后,服务器装饰它与业务层对象,并从那里进行的。

So an object gets changed at the presentation layer, for example a "user": user->setName("Fred"), and then commits it like this user->commit(), the commit method calls the data provider's commit method, which then encodes the object and sends it to the server. The server then "decorates" it with the business layer object and carries on from there.

目前,我有这个工作为原型,与该被使用在客户端和服务器的共享项目定义的DAL对象。服务器然后注入它的数据提供者(使用数据库),并在客户端注入,使用该服务器的数据提供者。

I currently have this working as a prototype, with the DAL objects defined in a shared project that gets used by both the client and the server. The server then injects it's data provider (which uses the database), and the client injects a data provider that uses the server.

我想知道如果这似乎是一个合理的做法?我一直在想,如果我需要另一个层,而不是直接暴露给客户端的DAL对象。或许一个数据对象转院层,它会给我3层:数据访问对象,业务逻辑对象和数据传输对象

I'm wondering if this seems like a reasonable approach? I keep wondering if I need another layer rather than having the DAL objects exposed directly to the client. Maybe a data tranfer object layer, which would give me 3 layers: Data access objects, business logic objects, and data transfer objects.

感谢。

推荐答案

这不是一个好主意,露出内在的对象喜欢使用的对象/返回购买DAL。较好地保持从客户端隐藏所有内部对象,并拥有一套完整的客户端服务器通信对象。这可能是一些额外的工作一个对象转换为另反而会使升级系统更容易的情况下,服务器和客户端不一起升级。

It is not a good idea exposing 'inner objects' like objects used/returned buy the DAL. Better keep all inner objects hidden from the client and have a complete set of objects for client-server communication. It might be some extra work converting one object to another but will make upgrading the system much easier in case server and client don't upgrade together.

这篇关于DAL / BLL和客户端/服务器:应在客户端使用BLL或DAL对象为presentation?或者,也许另一个层(数据传输对象?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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