Individual projects -WC.exe (Java implementation)

A, Github project Address: https://github.com/blanche789/wordCount/tree/master/src/main/java/com/blanche

Two, PSP form

PSP2.1

SUMMARY

Plans to complete the required time (min)

The actual time required for completion (min)

Planning

plan

  45 

40

 Estimate

It estimated that the task requires much time and planning generally work steps

45

40

Development

Develop

880

940

Analysis

Needs analysis (including learning new technologies)

60

90

Design Spec

Generate design documents

30

-

Design Review

Design review (and colleagues reviewed the design documents)

10

-

Coding Standard

Code specifications (development of appropriate norms for the current development)

40

40

Design

Specific design

60

80

Coding

Specific coding

400

500

Code Review

Code Review

30

30

is

Test (self-test, modify the code, submit modifications)

250

200

Reporting

report

450

450

Test Report

testing report

360

370

Size Measurement

Computing workload

30

-

Postmortem & Process

Improvement Plan

Later summarized, and process improvement plan

60

80

Summary

total

1375

       1430

Third, the problem-solving ideas description

1, a strange development needs: at the time just to get this topic, in general, is more abstract; because in the past development, are based on a graphical interface as the primary mode of interaction, but this is to be a command line control commands to interact, so that the entire development process architecture needs to change. In the past, are the first to write graphical interface, and then make the appropriate corresponding interactive interface; and command the face of development, it needs to be the main function as the center, when the incoming commands, calls the corresponding logic operations

2, architecture design: The project I'm still using the traditional MVC development model to develop, but the view of the supplement to the main function-oriented; this project for about three minutes, the main function for the layer ( the entry code), view as a layer (-s meet demand), service to one (logic processing various needs). Wherein the service layer to the main processing logic

3, provides the interface: Since this needs six (six instructions), which relates to the output of the statistical results are four requirements. So, I designed four service implementation class (implement) in the service layer, mainly to address the needs of four instructions. Since the method to achieve four classes are the same, so I designed an interface. Using Java polymorphic thought convenient to call the method through four call interface implementation class, to avoid redundancy code

4, the regular expression refresher: When I see the demand has lines of code, comment lines, blank line, I certainly understand the need for regular expressions to match a corresponding read to judge the string, so it is necessary regular expressions learning knowledge. Secondly string to match the need to determine which methods of String Java API has about regular expressions

5, enumerate: Since a plurality of instructions, if instructions are required to judge a call that the entity class, will increase the time complexity. So I will enumerate store eight instructions, instruction and then to bind the corresponding service through the Map, in dealing with logic, it is possible to obtain the corresponding service entity classes through the corresponding instruction through key-value way to reduce traversal

6, it's the file: Because it may be possible to file directory when the user input file, so making this judgment is more complex, needs to be handled differently depending on the input, in addition, we have to consider the need for additional recursive, which add up to several layers of logical difficulty is increased, where the need for the user to enter the name of the file is parsed in order to operate file

Fourth, the design and implementation process

1, a flowchart of:

2、流程图解析:当运行程序时,用户输入相应的指令(例:-c [fileName]),从而调用main函数,main首先会判断是否需要调用图形界面和是否需要进行递归,方便后续进行不同的操作。然后会根据文件名判断当前文件是否可读;若可读,则调用read函数,传递文件和指令进入这个函数,然后根据指令调用相对于的service对文件进行读操作,从而来对其进行相应的WordCount;若不可读,则会通过正则表达式判断文件名是否含有通配符,若符合条件,则获取其所在的目录,若可递归,则进行递归操作,若不可递归,则对该目录下的所有文件进行WordCount;

3、类的目录结构

 

4、测试

  4.1测试文件

  

  4.2测试结果

   

  4.3代码覆盖率

  

  4.4代码覆盖率细节

  

5、图形界面

  

四、总结

  本次的个人项目虽然是一个小型的练手项目,但是于我而言,它不仅仅是一个从0到1的过程

  在0到1的这个过程中,我融入了软件工程的思想,严格按照PSP表来对整个项目进行规划、架构,于我而言,这个过程是有些繁琐与陌生的,与以往一拿到需求就开发的过程是截然不同的,在这个过程中,我更加明白了前期进行规划的重要性,规划看似在浪费时间,但其实好的规划会让我们的开发达到事半功倍的结果

  除此之外,我在此次开发中,多次运用到测试代码,这减少了我在开发过程中处理异常的时间;每当我书写好一个函数或者遇到瓶颈的时候,我就会通过测试代码,来进行测试,从而解决自己的问题,我认为培养在开发中注重测试实例的能力是非常有效的

  其次是代码覆盖率,本次的代码覆盖率在类和方法上覆盖率基本达到了要求。但是在代码line的覆盖率上还是比较小,基于原因,还是因为加入了太多的判断条件,导致在测试的时候,不符合条件的代码未被调用,这也提示我在今后的开发过程中,尽量减少条件的判断来实现自己的需求,提高代码的覆盖率。

 

Guess you like

Origin www.cnblogs.com/blanchejay/p/11587819.html