Interface Design Flashcards

Design functions that work together.

1
Q

mainloop

A

This tells the window to wait for the user to do something.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Method

A

Similar to a function but with different syntax, used to request.

bob.fd(100)

.fd is an argument.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

for statement (for loop)

A

Like a function definition, it has a header ending with a colon, followed by an indention and body. The body contains any number of statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

loop

A

The flow of execution runs through the body and then loops back to the top.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

encapsulation

A

Wrapping a piece of code into a function, attaching a name to the code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Generalization

A

Adding a parameter to a function to make it more general.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Keyword argument

A

Arguments that include parameter names as “keywords”

polygon(bob, n=7, length=70)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Interface

A

A summary of how a function is used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Refactoring

A

Rearranging a program to improve interfaces and facilitate code re-use.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Development Plan

A

A process for writing programs. One way is “encapsulation and generalization”:

  1. Write a small program with no definitions.
  2. Identify a coherent piece of it, encapsulate it in a function.
  3. Generalize the function by adding parameters.
  4. Refactor repeating or similar code into new general functions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Docstring

A

String at the beginning of a function explaining the interface. Use triple quotes “””

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Preconditions

A

Conditions that must be true before the function starts executing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Postconditions

A

Conditions that include the intended effect of the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly