Mark Goffin - EngD Research Engineer Christopher Baker – EngD Research Engineer
ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.
-
Upload
kenneth-richard -
Category
Documents
-
view
213 -
download
0
Transcript of ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.
![Page 1: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.](https://reader037.fdocuments.net/reader037/viewer/2022091113/5697bfee1a28abf838cb9969/html5/thumbnails/1.jpg)
ENEE150 – 0102ANDREW GOFFIN
Functional Decomposition
![Page 2: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.](https://reader037.fdocuments.net/reader037/viewer/2022091113/5697bfee1a28abf838cb9969/html5/thumbnails/2.jpg)
Why use functions?
Code ReuseSplitting Up FunctionalityReadabilityEase of testingSeparating use and implementation
Goffin – ENEE150
![Page 3: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.](https://reader037.fdocuments.net/reader037/viewer/2022091113/5697bfee1a28abf838cb9969/html5/thumbnails/3.jpg)
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.](https://reader037.fdocuments.net/reader037/viewer/2022091113/5697bfee1a28abf838cb9969/html5/thumbnails/4.jpg)
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.](https://reader037.fdocuments.net/reader037/viewer/2022091113/5697bfee1a28abf838cb9969/html5/thumbnails/5.jpg)
Code Example – Robot Control
Goffin – ENEE150
![Page 6: ENEE150 – 0102 ANDREW GOFFIN Functional Decomposition.](https://reader037.fdocuments.net/reader037/viewer/2022091113/5697bfee1a28abf838cb9969/html5/thumbnails/6.jpg)
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.](https://reader037.fdocuments.net/reader037/viewer/2022091113/5697bfee1a28abf838cb9969/html5/thumbnails/7.jpg)
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.](https://reader037.fdocuments.net/reader037/viewer/2022091113/5697bfee1a28abf838cb9969/html5/thumbnails/8.jpg)
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.](https://reader037.fdocuments.net/reader037/viewer/2022091113/5697bfee1a28abf838cb9969/html5/thumbnails/9.jpg)
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