Passing a large number of parameters in 3 tier architecture in asp.net website project

StackOverflow https://stackoverflow.com/questions/13170920

  •  24-07-2021
  •  | 
  •  

Question

I have just started to implement application development using 3-tier architecture. Also I am following some good coding practices. In the application, I need to pass some large amount of data to save(around 20 parameters) the student details. But as Good programming practice says,"Do not pass more than 5 parameters in a function. if you have to pass more then use objects to pass data as a single entity".

How should I pass this large amount of data from presentation layer to the DAL?

Was it helpful?

Solution

Create a property class of student and use its object as parameter like

 [Serializable]
public class CStudentProps
{
    public String StudentID { get; set; }
    public String StudentName { get; set; }
    public String StudentEmailID { get; set; }
    public String Status { get; set; }
    ...
    ...
}

and create an instance of CStudentProps like this

CStudentProps student=new CStudentProps()
student.name="";
.....
.....

and then call the function

addStudent(CStudentProps  ob);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top