0

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?

4b0
  • 21,981
  • 30
  • 95
  • 142
vivek
  • 1,595
  • 2
  • 18
  • 35

1 Answers1

0

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);
शेखर
  • 17,412
  • 13
  • 61
  • 117
  • yes, I got the idea. And now it is working fine. I created another layer named business object (BO) and define the class there. also i added the reference of this class in all the layers and passed the class object from UI Layer to DA Layer. A lot of thanks. But i have one question in mind. What is the use of [serialize] here before the class declaration. I have not used this,but everything is working fine. I have no idea about serialize and have never used it before. – vivek Nov 09 '12 at 16:44
  • Serialization is used when you have to keep your object collection somewhere for the future use. There may be situation where you would like to keep your collection of student into view state and after some processing you want to fetch values form view state. In these situation you will need the serialize attribute of the class. – शेखर Nov 10 '12 at 08:17
  • Your can go through this link for better understanding of this http://stackoverflow.com/questions/5877808/when-should-i-use-serializable-in-c – शेखर Nov 10 '12 at 08:20