CSSE 120 — Introduction to Software Development

Template (“boiler-plate”) to use for your Python functions and modules

Often WE (your instructors) supply either or both of:

This models a common real-life software development process in which the detailed specifications are part of the output from the design process and the person implementing the code starts with those detailed specifications.

But another common real-life software development process requires that YOU (the person implementing the software) supply:

In that case, you should use good practice in the form of your module and the detailed specifications of your functions. To that end:

Form to use for functions that YOU specify

Use this form to specify your function, filling in the information as appropriate to YOUR function. Here is a concrete example
def blah1(...):  # CHOOSE A FUNCTION NAME AND PARAMETER NAMES THAT MAKE SENSE,
                 # unless you are given the function name by your instructor/teammates.
    '''
        ** PUT HERE: WHAT THE FUNCTION DOES.  (NOT how it does it.) **

        In particular, describe what the function takes:

          a. If it gets input, describe what the user should input
             or (if from a file) what the file should contain.

          b. If it has parameters, describe what they should be.

        and describe what the function produces:

          a. If it prints something or writes to a file,
             describe what it prints/writes.

          b. If it returns a value, say "Returns ..." with a description
             of what it returns.

        Additionally, if the function mutates a parameter, say:
           "Mutates ..." with a description of what parameter(s) is mutated
           and what it is mutated into.
    '''
    # BODY of blah1
    # ...

def pizza(circle, numberOfSlices):
    '''
        Draws the given Circle, cut into a "pizza pie" with the given number of "slices".
        The GraphWin in which the circle is to be drawn should be a square
        about 20 pixels bigger than the diameter of the circle (so the circle takes up most of the window).
        
        See the "pizza" set of example pictures in the   PizzaAndOtherPictures.pdf   file
        included in this project.
    '''
    # ...
    # ...

Questions about the above form? Talk to your instructor or an assistant!

Template (“boiler-plate”) to use for modules that YOU create

Use the following template (“boiler-plate”) for modules that you create (“from scratch”)

'''
This module ** PUT HERE A BRIEF DESCRIPTION OF THE MODULE. **
One sentence is often enough.
   
@author: ** PUT YOUR NAME(s) HERE **, followed by a ** DATE WRITTEN ** (the month and year is adequate).
'''

# PUT HERE ANY IMPORT STATEMENTS YOU NEED for YOUR module

def blah1(...):  # CHOOSE A FUNCTION NAME AND PARAMETER NAMES THAT MAKE SENSE,
                 # unless you are given the function name by your instructor/teammates.
    '''
        ** PUT HERE: WHAT THE FUNCTION DOES, per the previous section.
    '''
    BODY of blah1


def blah2(...):  # CHOOSE A FUNCTION NAME AND PARAMETER NAMES THAT MAKE SENSE,
                 # unless you are given the function name by your instructor/teammates.
    '''
        ** PUT HERE: WHAT THE FUNCTION DOES, per the previous section.
    '''
    BODY of blah2

def blah3(...):  # CHOOSE A FUNCTION NAME AND PARAMETER NAMES THAT MAKE SENSE,
                 # unless you are given the function name by your instructor/teammates.
    '''
        ** PUT HERE: WHAT THE FUNCTION DOES, per the previous section.
    '''
    BODY of blah3

etc.

#----------------------------------------------------------------------
# main:  Tests the other functions in this module by calling them.
#----------------------------------------------------------------------
def main():
    ''' Tests the other functions in this module by calling them. '''
    # ** PUT HERE THE CALLS AS REQUIRED BY THE EXERCISE **
    # ** You can call the functions once, several times, or even no times
    # ** depending on what testing is needed.

#----------------------------------------------------------------------
# If this module is running at the top level
# (as opposed to being imported by another module),
# then run the body of this expression, which simply calls main.
#----------------------------------------------------------------------
if __name__ == '__main__':
    main()

Questions about the above template (“boiler-plate”)? Talk to your instructor or an assistant!