Flow arrangements for software development (as an example in Python language)

2009-05-31  来源:本站原创  分类:Development  人气:473 

Python language in the following example to illustrate the flow of software development arrangements

For software development, implementation function of the preparation of the development of software code is only a small part of the whole story but also a lot of its content, the following lists specific to the design, coding, static code analysis, testing, tuning the four-step for

1) Design

This involves system design, implementation design, of course, it relates to architecture, related to mode

2) encoding

Is to use the editor to write code, specifically in different languages have different compiler, like the python, there pydev + eclipse, pyscripters and so on, c + + there is visual c + +, slickedit and so on.

Pydev assumptions we use to write the test code is as follows:

#!/usr/bin/env python

"""
A simple test
"""

import os
import sys

def myprint(start):
    """Print the numbers"""

    for item in range(10):
        print 'item=', start * 10 + item

def mysum(first, second):
    """Get the sum of a and b"""

    return first + second

def main():
    """The main function"""

    for i in range(10):
        myprint(i)

if __name__ == '__main__':
    print 'OS: ', os.name
    print 'Arguments: ', sys.argv

    main()

3) static code analysis

After preparation of the code, it is necessary to carry out static code analysis, including coding norms, static analysis of code logic. python code static analysis in pylint, c + + code has a very well-known code analysis tool pc-lint

4) The code must be written to unit testing, python code can use the standard library unittest it provided for testing, c + + can be used to test google test framework.

The following is the preparation of the unit above test.py test code:

import unittest
import test

class TestTest(unittest.TestCase):
    """Test Cases"""
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def testmyprint(self):
        test.myprint(1)

    def testmysum(self):
        self.assertEquals(test.mysum(10, 20),30,'mysum')

Code in order to support more automated unit testing, module testing (mainly the __init__ file) Add the following code

def suite():
    """
    Return the test suite
    it should in Module File __init__
    """

    tests = ['testmyprint','testmysum']
    return unittest.TestSuite(map(TestTest, tests))

And on top of a python file, assumed to be testAll.py file add the following code:

import unittest

import testTest

suite1 = testTest.suite()

suite = unittest.TestSuite()
suite.addTest(suite1)

if __name__ == '__main__':
    unittest.TextTestRunner(verbosity=2).run(suite)

This assumption is the introduction of modules testTest, can also introduce other different modules, so that all of the test case will have to include the

Finally, type in the command-line python testAll.py be able to test all of the test case of the

D: \ Works \ Eclipse \ FirstPython \ test> python testAll.py
testmyprint (testTest.TestTest) ... item = 10
item = 11
item = 12
item = 13
item = 14
item = 15
item = 16
item = 17
item = 18
item = 19
ok
testmysum (testTest.TestTest) ... ok

-------------------------------------------------- --------------------
Ran 2 tests in 0.016s

OK

5) the adoption of unit testing, then basically there is nothing on the question, but does not necessarily guarantee that the code is to write the best, all we need for some tuning so that we use python's profiler to analyze the performance of procedures

First of all, after the implementation of our python-m cProfile test.py-o test.out

Test.py is to obtain the results of the implementation of the performance and the results output to file test.out

Pstats then use to obtain the performance data test.out, you can use the following code to resolve data:

"""Get and analyze the cProfile output file """

import pstats
import sys

if len(sys.argv) != 2:
    print '%s <profile_out_file>' % __file__
    sys.exit()
else:
    FILENAME = sys.argv[1]

PROFILE = pstats.Stats(FILENAME)
PROFILE.sort_stats('time').print_stats()

This can be seen with by the execution time of function call

The following are the results of analytical data

Thu Apr 02 20:39:03 2009 test.out

26 function calls in 0.012 CPU seconds

Ordered by: internal time

ncalls tottime percall cumtime percall filename: lineno (function)
10 0.011 0.001 0.011 0.001 test.py: 10 (myprint)
1 0.001 0.001 0.012 0.012 (execfile)
1 0.000 0.000 0.011 0.011 test.py: 5 (<module>)
1 0.000 0.000 0.011 0.011 test.py: 16 (main)
11 0.000 0.000 0.000 0.000 (range)
1 0.000 0.000 0.012 0.012 <string>: 1 (<module>)
1 0.000 0.000 0.000 0.000 (method 'disable' of '_lsprof.Profiler' objects)
Finally, in the confirmation process to run correctly, and be able to meet the performance requirements will be submitted to the code version control server go, such as SVN, this completed a process of software development for the next cycle it!

Good luck, huh, huh

相关文章
  • Flow arrangements for software development (as an example in Python language) 2009-05-31

    Python language in the following example to illustrate the flow of software development arrangements For software development, implementation function of the preparation of the development of software code is only a small part of the whole story but

  • Software Development Flow Chart 2011-03-25

    Their understanding of the software development process

  • Project Management System (software): software development projects. Research 2009-10-13

    Project Management System and Project Management Software slightly different; the former is generally customized, including the industry, or for a certain area, or even specific customer needs; which is generally more common in nature, or only the pr

  • Experience on software development 2010-02-22

    Year seldom log, more to the project development and research experience and knowledge of others. Development of 4 years to do, give me an overall feeling is pain and happiness with. I believe many of my friends and I like to solve a difficult proble

  • <2008 IBM Rational Software Development Summit Forum> small mind 2008-09-15

    I always wanted to write some summary for the exchange and notes, then did not pick up a pen, to participate in this activity to a feeling of a small mind open head, Oh! In fact, participated in "2008 IBM Rational Software Development Summit Forum&qu

  • Software Development Methods 2009-03-31

    Waterfall Development Method: This is an ideal state of development. All under the level based on job level. Once on the job level, the problems could not be delivered to the next level of working hours, the whole team are parked in it yes. Spiral de

  • Software Development Process (CMMI / RUP / XP / MSF) are with non-? 2009-05-05

    Often see and hear everyone in the process of argument Agile, RUP and CMM software development process which better or what the process well, have their own reasons, the controversy was in fact ...... joy, there is no perfect process, there is no bet

  • Chapter II of the process of software development 2009-07-29

    First, the software design documents Some commonly used list of software design documents: 1) the structure of the document Overall design of the software described in the document, including all software, as well as a description of the main part of

  • Software development management best practices - on build and continuous integration 2009-09-11

    XP approach to software development as on building a best practice management; agile software development is also to ensure continued integrated software as a matter of principle the success of the project. Coincidentally, 2003 China's software ( 600

  • Agile Software Development (principle. Pattern and practice of 2009-09-11

    Keywords: Agile software development practice of the principle of model "Agile Software Development (principle, pattern and practice)" (United States) Robert C. Martin translation of the Hui Meng Yan trial Notes Notes Excerpt: Eleven The first p

  • Management of software development experience 2009-10-20

    From the graduation date, the size of the project done something, there are a lot of the joy of success, many failures. This year, due to work, I Software In his capacity as project leaders participated in the access network to develop a unified netw

  • Software development team 2009-11-11

    Will bring together a group of people, this is the beginning. Let a group of people to be together, this is progress. A group of people to work together so that it was successful. -Lou Holtz, American football coach As early as in the lives of the Gr

  • The process of software development stage 6 2009-11-11

    The process of software development stage 6 Plan Of the problem to be solved by a general definition, including the understanding of user requirements and reality, from a technical, economic and social factors, such as three aspects of research and d

  • Java software development competency model thinking (Original) 2010-03-20

    Software development, from requirements, design, coding, testing, maintenance of a development process. From the project engineering point of view, demand is mainly to communicate with customers about needs, within the needs analysis and propose feas

  • Telecom Software Development Flex will bring change? 2010-03-01

    If you are a programmer telecommunications industry, famous topology tools TWaver You must be familiar; but if you mention TWaver think of a Swing component package, you no doubt already out of. After ten years of development, TWaver look is no longe

  • Development of software development team management 2010-05-10

    Background: In the increasingly large scale software development and refinement, how to manage a team, how to lead their team to success, to adapt to various types of complex software development projects, has increasingly become a very technical con

  • The risk of software development projects 2010-06-02

    Participated in the project made people know that a project development process will encounter many difficulties, many things will affect the risk of failure of a software development project took place in a series of events or the possibility of adv

  • Our team of SaaS software development: applied to group collaboration and process management tasks 2010-06-21

    Task coordination and workflow management SaaS software: push-off on-line task, welcome to free trial! Experience Address: http://www.yun-kee.cn , log application, please click on the "mission push-off application log" can log in using the follo

  • Software development process should be prepared in 13 categories document 2010-07-09

    In the software development process, should be required by software developers to write 13 class documentation, documentation requirements are targeted, precision, clarity, integrity, flexibility, traceability! 1, the feasibility study report Shows t

  • Software development process should be prepared in 13 class documentation 2010-07-09

    In the software development process, should be required by software developers to write 13 class documentation, documentation requirements are targeted, precision, clarity, integrity, flexibility, traceability! 1, the feasibility study report Shows t