How should I pass data between classes and application layers?

后端 未结 8 1859
太阳男子
太阳男子 2021-01-30 07:16

For example, if I am creating a 3 layer application (data / business / UI) and the data layer is grabbing single or multiple records. Do I convert everything from data layer in

8条回答
  •  不知归路
    2021-01-30 07:44

    I strongly suggest that you do it with objects. Some other way suggests that only interfaces are publics while your implementations are internal, and you expose your methods through a factory of your object, then couple your factories with a façade to finally have a single and unique entry point to your library. Then, only data objects goes through your façade, so you always know what to expect inside as outside your façade.

    This way, any UI could call your library's façade, and the only thing that would remain to code is your UI.

    Here's a link which I find personally very interesting that explains in summary the different design patterns: GoF .NET Design Patterns for C# and VBNET.

    If you'd rather a code sample illustrating what I'm stating, please feel free to ask.

提交回复
热议问题