16 pair programming for the soft-working network

Source: Internet
Author: User

1, Code Cloud Project address knot pair project code cloud address pair programming teammates
School Number name respective project address
201621123013 Hou Jingning Https://www.cnblogs.com/kyrie/p/9754498.html
201621123011 Chen Yu https://www.cnblogs.com/eshy/
Code Cloud Record

2. PSP Form
PSP2.1 Personal Development Process Estimated time-consuming (minutes) actual time consuming
Planning Plan 30 35
· Estimate Identify requirements and other relevant factors and estimate the time cost for each phase 40 50
Development Development 350 430
· Analysis Demand analysis (including learning new technologies) 150 180
· Design Spec Creating a design Document 30 30
· Design Review Design Review 40 50
· Coding Standard Code specification 25 30
· Design Specific design 30 30
· Coding Specific code 150 180
· Code Review Code review 20 20
· Test Test (self-test, modify code, commit changes) 20 30
Reporting Report 75 90
· Test report 30 40
· Computational effort 50 50
· and propose Process Improvement plan 25 25
3. An overview of the solution of the problem 3.1, the choice of programming language: Java, HTML and CSS (for Web-based GUI pages) 3.2, development tools and environment: Eclipse3.3, solving ideas

After discussions with my small partners, I decided to make improvements in the code of my previous personal project. First of all to seize this knot pair programming project and the last individual project, to add two features, 能统计文件夹中指定长度的词组的词频 and 能输出用户指定的前n多的单词 ,
After the things in the background to solve, began to consider with the front end (simple page) combined, after thinking, decided to use Java Servlet technology, but because it did not relate to this, or spent a lot of time to understand, in the front and back-end integration spend the most time, is not familiar with Java servlet technology, resulting in the development process encountered a lot of problems.

In fact, the basic idea is to pass the data to the background for processing through the form in the JSP file, and invoke the Java Code implementation function.

4, design implementation process 4.1, related classes and functions of the design

Defines a charcount class, based on the previously defined three methods, methods (to implement word ordering), methods (Implementation of sortMap wordCount frequency statistics), Output methods (Implementation of write-text file processing), the addition of two methods. This time the pair programming project adds two functions, namely the sortMap1 method (can output the user to specify the first n many words), also has the lenWordCount method (can count the word frequency of the phrase of the specified length in the folder). And in this project, we've improved the problem of not being able to make case-by-case distinctions, which will be explained later in the unit test!

5, Code description (code snippet) Here we explain the new functionality of the code (the previous code is no longer explained) 5.1, the first page of the form (other pages form similar)
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" Utf-8 "%> <! DOCTYPE html>

This is a simple form as the home page, where the data entered here is passed to the servlet file for background processing.

5.2. Dopost method
protected void DoPost (HttpServletRequest req, HttpServletResponse resp) throws Servletexception, IOException            {Resp.setcontenttype ("text/html;charset=utf-8");            PrintWriter out = Resp.getwriter ();            Read in TXT file Scanner input = new Scanner (system.in);                        String pathname = req.getparameter ("txt");            int charcount=0;            int linecount=0; InputStreamReader r = new InputStreamReader (new FileInputStream (pathname)); Create an input stream object reader BufferedReader br = new BufferedReader (r);  Create an object that turns the contents of the file into a language that the computer can read list<string> List = new arraylist<string> ();            Store word String readLine = null;                while ((ReadLine = Br.readline ()) = null) {charcount + = Readline.length ();//The number of characters is the length of the character, regardless of the kanji if (Readline.isempty ()) {//This line is empty, is an invalid row} else {Linecount++;}                Read one line at a time, plus 1 string[] wordsarrays = Readline.split ("\\s*[^0-9a-za-z]+") for each row of rows read; Separated by a space and non-alphanumeric symbol, at least 4 English letters, followed by an alphanumeric symbol for (String word:wordsarrays) {if (Word.matches ("[                    a-za-z]{4,}[a-za-z0-9]* ")) {List.add (Word.tolowercase ()); }}} r.close ();//Close file map<string, integer>  Wordscount = new treemap<string,integer> ();            Store word count information, key value is the word, value is the number of words out.println ("

After submitting the data on the front end, because the previous submission is post, the method is overridden in the servlet doPost() to jump to another page (that is, display character statistics)

5.3. SortMap1 method
Former K-more words public static void SortMap1 (map<string,integer> oldmap,int k,httpservletrequest req, httpservletrespons E resp) throws ioexception{arraylist<map.entry<string,integer>> list = new Arraylist<map.entry<s        Tring,integer>> (Oldmap.entryset ()); Collections.sort (list,new comparator<map.entry<string,integer>> () {@Override public int Compare (map.entry<string, integer> O1, map.entry<string, integer> O2) {if (o1.getvalue () = = O2                . GetValue ()) {return O1.getkey (). CompareTo (O2.getkey ());//The word frequency is the same, by dictionary}  Return O2.getvalue ()-O1.getvalue ();        Descending order}});        Resp.setcontenttype ("Text/html;charset=utf-8");        PrintWriter out = Resp.getwriter (); if (List.size () >=k) {//The number of words is greater than or equal to K, the output frequency is before the K for (int i = 0; i<k; i++) {out.println (List.get (i   ). GetKey () + ":" +list.get (i). GetValue ());         }}else {for (int i = 0; I<list.size (); i++) {//The number of words is less than k, the output is all out.println (LIS T.get (i). GetKey () + ":" +list.get (i). GetValue ());//key value to one by one}}}

This method is to output the first k words, the implementation of this function is relatively simple, because the function based on the previous sortmap to do a little modification can be used, but if carefully observed, will find out why SORTMAP1
function parameters will be more than two HttpServletRequest req, HttpServletResponse resp , need to use PrintWriter out = resp.getWriter(); it is actually used to give out function, the data output to the page (in fact, is also helpless, because the dopost inside the RESP is not a global variable, resulting in the sortMap1 inside the data can only output to the console)
The other way.

6, Unit test test Cases (part) 6.1, improved to achieve case

6.2. View the first 3 words

6.3. View the first 10 words (more than the total number of words)

6.4. View words of a specified length

Code Coverage Testing

7. Pair programming experience pair programming photo (documentary)

Personal experience:

First of all, although it is possible that this pair of programming project is not very good, but I would like to say that this should be I experienced a relatively successful cooperative programming, the whole process down, we are very chat, get along with that must be very happy. At first we all studied each other's personal project code last week, after discussion, unanimously decided to use my code. The whole project down, some issues of discussion and resolution, personal feeling is 1+1>2, two people thinking and thinking on a channel above, this feeling is pretty great. We unanimously decided that the GUI with Web-based web design, using servlet technology to complete the project, we have a clear division of labor, front-end and the background is still very good combination. In fact, the whole knot to the project process I think teammates give me the most important is a kind of inspiration, we are in the process of dealing with problems often get into some difficulties, this time your teammates will be able to help you! And in this cooperation to feel very deep. Finally, I personally feel that if your teammates and you are on a channel, the communication is very harmonious, mutual promotion of each other, this I think 1+1>2 can be clearly reflected.

16 pair programming for the soft-working network

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.