CIT 590 Intro to Programming Lecture 2 Questions regarding enrollment • The cap is still in effect • The course will be offered again.
Download ReportTranscript CIT 590 Intro to Programming Lecture 2 Questions regarding enrollment • The cap is still in effect • The course will be offered again.
CIT 590 Intro to Programming Lecture 2 Questions regarding enrollment • The cap is still in effect • The course will be offered again in the spring • The waitlist is closed as well • If you know programming, please consider dropping the course and taking courses like • Computational linguistics • Software engineering • If you do not want to spend a fair amount of time programming please drop the course • If you can take CIS 110 (the undergrad intro to programming) they have 1 section still open • If you really absolutely have to do this course, you will have to talk to Mike Felker and convince him Agenda • ‘import’ • IDLE frustrations • Abstraction • Functions • Testing • The concept of scope One big giant python file …. • Python is full of modules • import math • from math import * • the same logic can be used for your own functions • areaFuncs.py and usageOfFuncs.py • Importing a module within another module Agenda • ‘import’ • IDLE frustrations • Abstraction • Functions • Testing • The concept of scope Things you cannot do in IDLE • Line numbers – there are some extensions that I have not tried out • Do not forget the .py extension • History using the up and down keys • Configure idle • For other complaints … • http://inventwithpython.com/blog/2011/11/29/the-things-i-hateabout-idle-that-i-wish-someone-would-fix/ Agenda • ‘import’ • IDLE frustrations • Abstraction • Functions • Testing • The concept of scope Abstraction • A good program will have layers of abstraction • Sometimes you only care about the input and output and do not really want or even need to know the intrinsics • math.sqrt() how is implemented • Who cares! • APIs (Application Programming Interfaces) • https://code.google.com/p/python-twitter/ PennApps!!! • http://2013f.pennapps.com/ Modular programming • Software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules • each module contains everything necessary to execute only one aspect of the desired functionality. • You’ll also hear this referred to as top-down design and stepwise refinement functions • In accordance with the concept of abstraction • Divide a program up into its ‘functional’ portions • Testing becomes much easier • Test each component really well • Think about a few integration tests • vowelCounter.py Information hiding • David Parnas first introduced the concept of information hiding around 1972. • hiding "difficult design decisions or design decisions which are likely to change." • Hiding information in that manner isolates clients from requiring intimate knowledge of the design to use a module, and from the effects of changing those decisions. Software reuse • Do not reinvent the wheel • The reuse of programming code is a common technique which attempts to save time and energy by reducing redundant work. • Software libaries/modules - good example of code reuse Good program design • Separate your program into the building blocks • Write a function for each of the building blocks • Simple methods of separation • Separate functions for the calculations • Separate function for the input • Separate function for the output The coke machine example • Cokemachine1 and cokemachine2.py Testing functions • Debugging via test cases • Reading code – romanNumeral.py • Code reviews Scoping • local variables versus global variables • changing the value of a global variable within a function using the global keyword Summary • Understanding the importance of modular programming • Functions • Testing a function and code walkthroughs • Variable scope