locked
How should WinForm controls talk to my Business Layer? RRS feed

  • Question

  • I have an app that's layered and I understand how all that should work; however, is it bad practice to pass control references to the Business layer?

    I'm not doing that currently but wondered what people's thoughts are on the subject.

    As of now, let's say I have a datagrid on a form which is bound to a list that's returned from the Business logic. I call a class in my business logic which in turn calls some business logic helper files, then the business logic calls a data layer class and some data layer helper classes.

    I guess I want to keep my GUI pieces as uncluttered as possible, but passing a control reference to the business layer kinda breaks the "loosely coupled" theory doesn't it?

    Any input is greatly appreciated.

    Thanks folks...

    tj

    Saturday, November 13, 2010 5:13 PM

All replies

  • Take a look at the Model View Presenter and Model View View-Model patterns

     


    gimme some slamming techno!!!!
    Saturday, November 13, 2010 11:27 PM
  • I would also recommend this book:

    Microsoft .NET: Architecting Applications for the Enterprise (PRO-Developer)


    gimme some slamming techno!!!!
    Saturday, November 13, 2010 11:37 PM
  • So, I guess there is no easy answer to my question.

    Thanks for your time, Blair.

    tj

    Sunday, November 14, 2010 12:38 AM
  • You are right in a way. .  there is no short answer.

    MVP/MV-VM are the Microsoft recommended approaches. And the topic is masterfully covered by people more articulate than me.

    One thing to consider. .  rarely do I find that the business model translates to the presentation directly (Model Impedence.)

    I typically bind my gui to a presentation model.

    My presenter will use a mapper pattern to transform the presentation model into the business model which is then used by a controller to pass on to the service layer


    gimme some slamming techno!!!!
    Sunday, November 14, 2010 1:15 AM
  • " is it bad practice to pass control references to the Business layer?"

    Yes,

    Although you might pass a control reference to some other layer if you're using inversion of control.  Not sure how practical IoC is with Winforms though.

    Monday, November 15, 2010 11:56 AM