ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.

9
ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition

Transcript of ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.

Page 1: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.

ENEE150 – 0102ANDREW GOFFIN

Functional Decomposition

Page 2: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.

Why use functions?

Code ReuseSplitting Up FunctionalityReadabilityEase of testingSeparating use and implementation

Goffin – ENEE150

Page 3: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.

Choosing Functions

Top down design Look at high level description and split up the

functions from thereBottom up design

Building up from basic functionsTypically use top down, and look for

Repeated modules Hierarchy Logical units

Goffin – ENEE150

Page 4: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.

Declaring Functions

Function prototype

Function implementation

Function prototypes allow freedom of where you put your implementations in the program

Implementation has return type, name, and input variables

Goffin – ENEE150

Page 5: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.

Code Example – Robot Control

Goffin – ENEE150

Page 6: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.

Multiple Modules

Can split code up into multiple .c filesWhen compiling, just type:

gcc <file1> <file2> … <filen> Will still compile to one a.out file

Goffin – ENEE150

Page 7: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.

Project 1 - Chess

Note that queen is just a bishop and a rook put together

King is a queen that only moves one space

Goffin – ENEE150

Page 8: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.

Project 1 - Chess

Mainly just implementing move checksMUST use functions listed, but you can (and

are encouraged to) create more

Goffin – ENEE150

Page 9: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.

Project 1 - Chess

Pawn and general game logic should come FIRST Don’t start with knight… that’s going to be looked at

last for grading Cannot actually move most of the pieces without

moving the pawn anywayNo checks/checkmates/queening pawns

Only implement what’s listed in the project description

Start project ASAP The full two weeks are likely needed

Goffin – ENEE150