Personal third time programming: pair programming

Results team work
GitHub project address https://github.com/cl12312/PairProgramming.git
Teammate blog address https://www.cnblogs.com/q1281037172/
Job Link https://www.cnblogs.com/cherish599/p/11577268.html

A, psp table

PSP2.1 Personal Software Process Stages Estimated time consuming (minutes) The actual time-consuming (minutes)
Planning plan 30 20
Estimate Estimate how much time this task requires 700 800
Development Develop 600 700
Analysis Needs analysis (including learning new technologies 60 90
Design Spec Generate design documents 10 10
Design Review Design review (and colleagues reviewed the design documents) 10 10
Coding Standard Code specifications (development of appropriate norms for the current development) 10 10
Design Specific design 60 60
Coding Specific coding 300 500
Code Review Code Review 60 60
Test Test (self-test, modify the code, submit modifications) 180 180
Reporting report 180 180
Test Report testing report 90 100
Size Measurement Computing workload 15 15
Postmortem & Process Improvement Plan Later summarized, and process improvement plan 60 60
total 1665 2045

Second, the calculation of the design and implementation of the interface module

1, design ideas

  (1). The full coding is implemented by c #, students will edit all the information in the code, eliminating the need for operational connection to the database, but it will be some difficulties in later maintenance. We design are:

  • login interface
  • All student information display window
  • Achieve a form named
  • Game Form (dice)
graph LR A (the login screen) - a successful login -> C (load data) C -> D (random roll call) C -> E (crap) D -> E A-- Login failed -> B (exit)

  (2). The main idea of ​​the core code reference code is thinking teacher in the class mentioned, on this basis, plus the login screen and craps game window. Load data and random roll call link:

Create a class:

  • Base (used to simulate the database) by creating a list and entered, and joined student information, while adding student data when referring to the Entity class is instantiated.
  • The Entity (for added data instantiated) by constructing and has no argument constructor argument constructor to increase data instance made ready.
  • Dao (the number of rows and the configuration of the two functions obtain a list of lists of values)
  • WinformControlUse (main console) has three windows (login window, named window, craps game window)
    • Login window: Login simulation designed so only one login account password (Account: admin; password: 123), the password is correct then the pop-up window or remind named "password or account error";
    • Named window: progress bar randomly named function, loading data function, the progress bar is arranged schedule maximum length list length while each additional row of data plus one to progress length of the bar, loading the data using the list of values ​​loaded into DataGridView control, random naming system is a random list of less than or equal length data corresponding to the same time generating a data list of a data output line;
    • Game window: design is relatively simple, in accordance with the Show pictureBox seven pictures, images stored using 1-6 ImageList dice, when to start the game point displayed in the GIF format images pictureBox rotating dice, six randomly generated number corresponding to the display 1 -6;
graph LR A (student information) -> B (Entity) B-- instantiation -> C (Base) C -> D (Dao) D-- obtained value and the number of rows in the list -> E (WinformControlUse ) E -> F (random named) E -> G (load data) E -> H (game window open)
2, how to embody the principle of
  • (1) Design By Contract (Contract Design): Compact design is made according to certain conventions for a predetermined number of data, if the exceeding, the program will no longer run, for example, the input parameter requirements must be met certain conditions. How to reflect: Only enter the correct account number and password to open the roll call system;
  • (2) Information Hiding (information hiding): refers to information hiding in the design and determination module, such that the specific information (data or process) contained within a module, other modules do not need this information, it is inaccessible. How to reflect: the design of private and public two access rights, for example, some students will not get the information data in other classes;
  • (3) Interface Design (interface design): The name of the interface, inheritance relationships between functions, interfaces and interface design; good interface design can enhance code readability, ease of use, changeability. How to reflect: a result of the design ideas and no place to use interface, so there is no implementation of the interface design;
  • (4) Loose Coupling loose coupling: the software system structure between modules interconnected a measure of how tightly. The closer the contact between the modules, the stronger its coupling, independent module is worse. Module is coupled between high and low depending on the complexity of the interface between the modules, and the calling mode information transfer. How to reflect: roll call window and game window in the login window and switch each other in random can well reflect loosely coupled;

Third, code review

  1. Code Specification reference: C # code specification   2. Code peer review, the problems we found in the process of editing code, tried many methods, but failed begin with, so a lot of wasted time. But in the end we took a relatively simple method, the final completion of this work.

Fourth, Code Description

1. login code

//模拟登录界面
private void button1_Click(object sender, EventArgs e)
        {
            string name = this.textBox1.Text;
            string password = this.textBox2.Text;
            if(name.Equals("admin") && password .Equals ("123"))
            {
                MessageBox.Show("登录成功");
                this.Hide();
                welcome w = new welcome();
                w.Show();

            }
            else
            {
                MessageBox.Show("密码或账号错误!");
                this.textBox1.Clear();
                this.textBox2.Clear();

            }

        }
        //重置按钮
        private void button2_Click(object sender, EventArgs e)
        {
            this.textBox1.Clear();
            this.textBox2.Clear();
        }

2. random roll call interface

// 随机点名代码
 private void timerCallName_Tick(object sender, EventArgs e)
        {
            Random ra = new Random();
            int i = ra.Next(stuList.Count);
            lblName.Text = stuList[i].Name;
        }

3. Load Student Information Code

private void btnLoadStu_Click(object sender, EventArgs e)
        {          

            //获取学生数据源
            StudentDAO stuDao = new StudentDAO();
            stuList=stuDao.getAllStudents();

            //进度条设置
            int stuCounts = stuList.Count;//及时学生人数
            progressName.Maximum = stuCounts;
        

            //构造数据源
            DataTable dt = new DataTable();          
            dt.Columns.Add("stuID", Type.GetType("System.String"));
            dt.Columns.Add("stuName", Type.GetType("System.String"));
            
            //数据加载以进度条方式展现
            foreach (Student stu in stuList)
            {
                dt.Rows.Add(stu.Id,stu.Name);
                progressName.Value += 1;//一个学生,进度条加1;
                Thread.Sleep(500);                
            }            
            
            dgvStuList.DataSource = dt;

            setControlVisible();

        }

4. Code dice

private void button1_Click(object sender, EventArgs e)
        {
            pictureBox1.Image = Image.FromFile(@"C:/Users/chen123/Desktop/材料/timg.gif");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            pictureBox1.Image = null;
            Random rd = new Random();
            int i = rd.Next(0, 5);
            pictureBox1.Image = imageList1.Images[i];
        }

Here Insert Picture Description Here Insert Picture Description Here Insert Picture Description Here Insert Picture Description Here Insert Picture Description

V. Additional features

  We've added a craps game can be used to increase the fun in the classroom.

Sixth, display calculation module of the unit test

Test cases are the login screen change overnight

// 登录界面创建的单元测试
[TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Console.WriteLine("请输入账号");
            string name = Convert.ToString(Console.ReadLine());
            Console.WriteLine("请输入密码");
            string password = Convert.ToString(Console.ReadLine());
            if (name.Equals("admin") && password.Equals("123"))
            {
                Console.WriteLine ("登录成功");
                }
            else
            {
                Console.WriteLine("密码或账号错误!");
            }
             }

Test Results Here Insert Picture Description

Seven, to show the process of twinning

1. pairing process: Because the same as roommates in the bedroom, so we say good team, I am responsible for interface settings as well as random dice roll call function to achieve, is mainly responsible for his teammates interface landscaping and login interface to achieve; 2. twinning process: Here Insert Picture Description

Eight, harvest

The use of the database but have been thinking for a long time to install the database without success later on, try this but always encounter many problems with Excel and Notepad, for example, can not implement random roll call and the progress bar implementation. Waste a lot of time to find a lot of tutorials, and later his teammates say that we have much time we had to rush to learn from the example of the teacher added some small idea of ​​the end of the job. To sum up, do a lot of things can not always change course halfway and eventually often waste a lot of time, after writing a project when beginning to think clearly specific ideas and what needs to be used, so should be able to save a lot of time on the action.

Guess you like

Origin www.cnblogs.com/chen100/p/11614610.html