Personal third job: Pair Programming

Github repository project addresses Fork: https://github.com/Wamnario/PairProgramming.git

PSP2.1 Personal Software Process Stages Estimated time consuming (minutes)
Planning plan 30
Estimate Estimate how much time this task requires 30
Development Develop 90
Analysis demand analysis 60
Design Spec Generate design documents 60
Design Review Design Review 30
Coding Standard Code Specification 60
Design Specific design 60
Coding Specific coding 90
Code Review Code Review 60
Test test 30
Reporting report 60
Test Report testing report 30
Size Measurement Computing workload 30
Postmortem & Process Improvement Plan Later summarized, and process improvement plan 60
Sum total 780

programming

Forms Designer

A good program starting with the beauty of the interface. Created WinForm rational use after ToolBox in the tool design. There are all the student's name, student number is stored, will use the DataGridView . Followed randomly selected students to function, only need a "random sample" of Button can be. After randomly drawn to students, students can perform transaction processing, such as whether he is absent, so there should be "absent" button. To remember the student absences. Forms Designer to design this part to Partner.

Code design

Just get the project in mind about something, because in the past there had been a technology company under the name of the institution tuition assistant, we have seen their roll call system. I know about the function, but the software will be easier. Teachers also have released relevant information in Banqun this assignment, the classroom and also to show, so it was not difficult to practice them.

The code is designed to use a three-layer design, respectively, the presentation layer (user interface layer), business logic, data access layer. There is also a library entity. There are five categories, form class to achieve human-computer interaction. The project will total there is a relationship between the six function calls, function and function. The key function can draw a flowchart. My key point is to use a unique algorithm to generate random numbers drawn in the form of a point-to students, it will be more simple.

Information Hiding in principle

Information hiding principle is the basis of structured design and object-oriented programming, object-oriented package will come from this principle. In order to implement this principle, classes and classes are accessed through interfaces.

Design by Contract principles

Design by Contract, so that each element of a software-based mutual obligations and responsibilities to cooperate with each other. As in the function call, the number of parameters or if the wrong type is not invoked. You can call if they meet the requirements of the program to further follow the steps. As if to complete the contract.

Interface Design Principles

Interface isolation, the client does not depend on unwanted interfaces. In code design, the dependency class and class are based on a minimum interface.

Loose Coupling principle

In this project the program, between classes provider / service requestor mode wedge interface realized service by about, is consistent with the typical loose coupling principle.

Code Review

代码规范: Https://gist.github.com/zhuqling/a2700703d088b8746f0c#file-csharp-language-code-standard-style-md
we use the Camel case format. First check the name meets the requirements. We use a face to face manner review code review.

yz:这个chosedstuin是不是不符合代码规范啊?

yw: There is little change chosedStuInfo better.

yz:这个学生姓名显示的字体大小不太合适,不美观。

yw: change change change.

yz:这个记录缺勤按钮在随机点到之前也可以点击啊,点了会怎么样?

yw: You try too?

yz:点了...列表第一个同学被记录了一次缺勤

yw: that he was very miserable ...

yz:我点错了,给同学误记录了一次缺勤,怎么办,能撤回吗?

yw: wow, no Hey!

Code review results is the discovery of a bug and place two unreasonable and a code that does not conform to the rules.

1.chosedstuin does not meet specifications.
2. If you do not click on random draw people click on absenteeism, the school No. 1 student absences will be recorded once.
3. absences can only remember, if I remember correctly that can not be changed back.

Code Testing

Construction code to test the idea that, in the Unit Test , create an instance of form1 Form, call the function of form1.

The form1 first load

Call form1 function, a randomly selected student.

Call form1 function, remember this student absences.

This assertion of the number of student absences 1.

Call form1 function, cancel the record of the student's absences.

The number of absences assertion that the student is zero.

Part of the code

    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Form1 form1 = new Form1();
            form1.unitest_formLoad();
            form1.unitest_rdChoseStu();
            form1.unitest_Absence();
            int tmp = form1.preAssert();
            Assert.AreEqual(1, tmp);
            form1.unitest_cancelAbsence();
            tmp = form1.preAssert();
            Assert.AreEqual(0, tmp);
        }
    }

Code coverage

Code Description

        private void Form1_Load(object sender, EventArgs e)
        {
            progressName.Step = 1;
            progressName.Minimum = 0;
            StudentDAO stuDao = new StudentDAO();
            stuList = stuDao.getAllStudents();
            DataTable dt = new DataTable();
            dt.Columns.Add("stuID", Type.GetType("System.String"));
            dt.Columns.Add("stuName", Type.GetType("System.String"));
            dt.Columns.Add("缺勤此次数");
            progressName.Maximum = stuList.Count;
            foreach (Student stu in stuList)
            {
                dt.Rows.Add(stu.Id, stu.Name, stu.TimeAbence);
                progressName.PerformStep();
            }
            dataGridView1.DataSource = dt;
            dataGridView1.Columns[2].Width = 120;
        }//Load the data of the students while loading the windows form.
         //Initialize the progressbar and make it work properly.

        private void Rdchose_Click(object sender, EventArgs e)
        {
            cancelAbsence.Enabled = false;
            Random rd = new Random();
            tmp = rd.Next(1, 84);
            Thread.Sleep(1);
            chosedStuInfo.Text = "学号:" + stuList[tmp].Id +" "+"姓名:"+stuList[tmp].Name;
            absence.Enabled = true;
        }//perform a random roll call.

        private void absence_Click(object sender, EventArgs e)
        {
            stuList[tmp].TimeAbence++;
            int TimeAbsenceTmp1 = Convert.ToInt32(this.dataGridView1.Rows[tmp].Cells[2].Value);
            this.dataGridView1.Rows[tmp].Cells[2].Value = TimeAbsenceTmp1 + 1;
            cancelAbsence.Enabled = true;
            absence.Enabled = false;
        }//Record an absence for this chosed student.

        private void cancelabsence_Click(object sender, EventArgs e)
        {
            stuList[tmp].TimeAbence--;
            int TimeAbsenceTmp2 = Convert.ToInt32(this.dataGridView1.Rows[tmp].Cells[2].Value);
            this.dataGridView1.Rows[tmp].Cells[2].Value = TimeAbsenceTmp2 - 1;
            absence.Enabled = true;
            cancelAbsence.Enabled = false;
        }//Cancel the absence record for this chosed student if he was recorded an absence just now.

PSP table

PSP2.1 Personal Software Process Stages The actual time-consuming (minutes)
Planning plan 15
Estimate Estimate how much time this task requires 20
Development Develop 90
Analysis demand analysis 80
Design Spec Generate design documents 50
Design Review Design Review 30
Coding Standard Code Specification 70
Design Specific design 60
Coding Specific coding 60
Code Review Code Review 50
Test test 50
Reporting report 60
Test Report testing report 40
Size Measurement Computing workload 30
Postmortem & Process Improvement Plan Later summarized, and process improvement plan 80
Sum total 785

Additional features

Record student absences, show the number of student absences.
Cancel the second recording student absences.

Guess you like

Origin www.cnblogs.com/unmario/p/11600954.html