Download presentation
Presentation is loading. Please wait.
Published byAgnes Virginia Price Modified over 8 years ago
1
Compsci 06/101, Fall 2010 10.1 How to build a program l Create a module Can be used by other modules via import Collection of functions, later collection of classes How do the functions in one module communicate? l Sometimes functions in one module interact Easy if one function calls another Harder if state must be saved between function calls l Enter global variables The scourge of human kind
2
Compsci 06/101, Fall 2010 10.2 Global variables l Why are these bad? Leaky information from one module to another If implementation changes, hard to maintain code So, NEVER access global state/variables outside a module Eventually move toward understanding of name spaces l When using a global variable you must Declare the variable as global in a function Not for read-only, don't need to be declared, but just do it l Designing and using classes will change this
3
Compsci 06/101, Fall 2010 10.3 Programming Style l Functions return a value If they don’t they do anyway: None Sometimes it's ok not to, the function has a side effect Could be printing, could be altering global state Could be … l Functions have a comment indicating their purpose Describe functionality Describe parameters Describe return type Describe exceptions (later)
4
Compsci 06/101, Fall 2010 10.4 Lynn Conway See Wikipedia and lynnconway.com l Joined Xerox Parc in 1973 Revolutionized VLSI design with Carver Mead l Joined U. Michigan 1985 Professor and Dean, retired '98 l NAE '89, IEEE Pioneer '09 l Helped invent dynamic scheduling early '60s IBM l Transgender, fired in '68
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.