Question


I am new to .net programming.
I am developing a windows application(C#), in which i am using Layered Architecture (3 layers [View layer, Business-logic layer and Data-access layer]). But am stuck between concept of View layer and BusinessLogic layer. E.g.

Let in my Form there are many DataGridVew control in same winform, and i have to do some manipulation on them that's why i created a common method for similar manipulation say GetRecordCount(..)

private int GetRecordCount(DatagridView dgv)
{
     //calculate record row count and return that.
}

My question is :: Where should i put GetRecordCount(..) method , in ViewLayer or BusinessLogic layer ?
If we put GetRecordCount(..) in BusinessLogic layer then is it good to pass win controls in BusinessLogic layer as argument for manipulation b'coz winform controls are the part of ViewLayer?

Was it helpful?

Solution

The business layer should only make decisions/calculations to support your business model. In my opinion the GetRecordCount should not be in the business layer. You should not by any way pass elements of the UI to the business model to manipulate them. The view/UI layer should handle all the displaying details, using the calculations/decisions of the business layer.

This specific calculation is a calculation only for display purposes and will not be used for any other purpose as it calculates the rows of a datagridview. If another method would return the total number of records included in the system, I would probably put it on the business layer. But in this case, the method should go to the UI layer.

Hope I helped!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top