CS 101 E Introduction Aaron Bloomfield MEC 205
CS 101 -E: Introduction Aaron Bloomfield MEC 205 MEC 215 Clark G 004 (really) 1
Assumptions o The following is assumed for students in 101 -E n You have taken a course-equivalent in programming o Thus, you know the basics of programming n You did not get a 4 or a 5 on the AP computer science exam (AB level) 2
Differences with 101 o o Labs must be done by all 101 -E students on their own time n If you miss more than 2, you are subject to failure n Labs due 8: 30 p. m. on Sunday n Lab session for 101 -E students Sunday at 7 p. m. Pace through the textbook is the same n We’ll go into more detail, though n Today’s class will be a high-level overview 3
A bit of humor: Review of last time 4
Computing units of measure o o o o Kilo (K) = 1, 000 (thousand) Mega (M) = 1, 000 (million) Giga (G) = 1, 000, 000 (billion) Tera (T) = 1, 000, 000 (trillion) Kilo = 210 = 1, 024 Mega = (1024)2 = 1, 048, 576 Giga = (1024)3 = 1, 073, 741, 824 Tera = (1024)4 = 1, 099, 511, 627, 776 = = Kibi (Ki) Mebi (Mi) Gibi (Gi) Tebi (Ti) 5
A marketing trick o o This hard drive has 250, 059, 350, 016 bytes n =250. 06 Gigabytes n =232. 89 Gibibytes Guess which one they use to advertise the drive? 6
Software o o Program n Sequence of instruction that tells a computer what to do Execution n Performing the instruction sequence Programming language n Language for writing instructions to a computer Major flavors n Machine language or object code n Assembly language n High-level Detailed Program knowledge to which of computer the machine respond is not Java Symbolic is acan high-level language For program to be directly. required. Eachmachine Uses instruction a for programming coding executed itcode must be is a vocabulary binary and that language instructions translated structure corresponds closer to to 7 athe problem native being instruction solved
A bit of humor: Input methods 8
Translation o o o Translator n Accepts a program written in a source language and translates it to a program in a target language Compiler n Standard name for a translator whose source language is a high-level language Interpreter n A translator that both translates and executes a source program 9
Java translation o o o Two-step process First step n Translation from Java to bytecodes o Bytecodes are architecturally neutral object code o Bytecodes are stored in a file with extension. class Second step n An interpreter translates the bytecodes into machine instructions and executes them o Interpreter is known a Java Virtual Machine or JVM 10
Task o Display the forecast I think there is a world market for maybe five computers. Thomas Watson, IBM, 1943. 11
Display. Forecast. java // Authors: J. P. Cohoon and J. W. Davidson // Purpose: display a quotation in a console window public class Display. Forecast { // method main(): application entry point public static void main(String[] args) { System. out. print("I think there is a world market for"); System. out. println(" maybe five computers. "); System. out. println(" Thomas Watson, IBM, 1943. "); } } Anmethod Three A application statements is a named program make piece is uprequired the of code action to that have of performs method a main()action some public static void or implements method named a behavior main(). Method main() is part of class Display. Forecast 12
Sample output 13
Java Documentation o Familiarize yourself with the Java documentation n It will save you lots of time! 14
Good Commenting o o Necessary so others can re-use your code n And so the graders can understand it! A well commented program: // Authors: J. P. Cohoon and J. W. Davidson // Purpose: display a quotation in a console window public class Display. Forecast { // method main(): application entry point public static void main(String[] args) { System. out. print("I think there is a world market for"); System. out. println(" maybe five computers. "); System. out. println(" Thomas Watson, IBM, 1943. "); } } 15
Bad commenting // // Thomas J. Watson (February 17, 1874 - June 19, 1956) is considered to be the founder of IBM. He was one of the richest men of his time and called the world's greatest salesman when he died. // // // // While at NCR, he was convicted for illegal anticompetitive sales practices (e. g. he used to have people sell deliberately faulty cash registers, either second-hand NCR or from competitors; soon after the second-hand NCR or competitors cash register failed, an NCR salesperson would arrive to sell them a brand new NCR cash register). He was sentenced, along with John H. Patterson (the owner of NCR), to one year of imprisonment. Their conviction was unpopular with the public, due to the efforts of Patterson and Watson to help those affected by the 1913 Dayton, Ohio floods, but efforts to have them pardoned by President Woodrow Wilson were unsuccessful. However, the Court of Appeals overturned the conviction on appeal in 1915, on the grounds that important defense evidence should have been admitted. // // // Watson was born in Campbell, New York. His formal education consisted of only a course in the Elmira School of Commerce. His first job was at age 18 as a bookkeeper in Clarence Risley's Market in Painted Post, New York. Later he sold sewing machines and musical instruments before joining the National Cash Register Company as a salesman in Buffalo. He eventually worked his way up to general sales manager. Bent on inspiring the dispirited NCR sales force, Watson introduced the motto, "THINK, " which later became a widely known symbol of IBM. // // // Although he is well known for his alleged 1943 statement: public class Display. Forecast { "I think there is a world market for maybe five computers" there is no evidence he ever made it. The author Kevin // method main(): application entry point Maney tried to find the origin of the quote. He has been public static void main(String[] args) { unable to locate any speeches or documents of Watson's System. out. print("I think there is a world market for that contain this, nor is it present in any contemporary System. out. println(" maybe five computers. "); articles about IBM. The earliest known citation is from System. out. println(" Thomas Watson, IBM, 1943. "); 1986 on Usenet in the signature of a poster from Convex } Computer Corporation as "I think there is a world market } 16 for about five computers" --Remark attributed to Thomas J. Watson (Chairman of the Board of International
Java and the Internet 17
Engineering software o Complexity of software grows as attempts are made to make it easier to use n Rise of wizards 18
Software engineering o Goal n Production of software that is effective and reliable, understandable, cost effective, adaptable, and reusable o o Makes Work Because Cost Design to correctly sense software develop of the due and long and so tonot that the lifetime maintain fail great newmany features should costspeople involved not andexceed will capabilities to behave involved expected can flexible be added components benefit that can be used in other software n Creation n Debugging n Maintenance n Enhancement Two-thirds of the cost is typically beyond creation 19
Principles of software engineering o Abstraction o Encapsulation o Modularity o Hierarchy Ranking Separate Construct Determine or ordering components a the system relevant of from objects into properties externaland andpackages internal features components while ignoring aspects nonessential details 20
A bit of humor: 1989 Computer Advertisement Guess the price! 21
Object-oriented design o o Purpose n Promote thinking about software in a way that models the way we think and interact with the physical word o Including specialization Object n Properties or attributes n Behaviors 22
Programming o o Class n Term for a type of software object Object n An instance of a class with n specific properties and attributes 23
Programming o o Problem solving through the use of a computer system Maxim n You cannot make a computer do something if you do not know how to do it yourself 24
Problem Solving o Why do you care? n We are all assigned tasks to do o At work o At home o At school o Why not do them n Right n Efficiently 25
Problem Solving o Why care about computerbased problem solving (i. e. , programming)? n n n Neat Frontier of science Profitable Necessary Quality of life 26
Problem Solving o Remember Accept Solutions n Thegoal Often process require is notisboth aiterative clever concrete solution andbut abstract a correct thinking solution o In solving the problem increased understanding might Teamwork require restarting 27
Problem Solving Process o What is it? 28
Problem Solving Process o What is it? n Analysis n Design n Implementation n Testing 29
Problem Solving Process o What is it? n Analysis n Design n Implementation n Testing Determine the inputs, outputs, and other components of the problem Description should be sufficiently specific to allow you to solve the problem 30
Problem Solving Process o What is it? n Analysis n Design n Implementation n Testing Describe the components and associated processes for solving the problem Straightforward and flexible Method – process Object – component and associated methods 31
Problem Solving Process o What is it? n Analysis n Design n Implementation n Testing Develop solutions for the components and use those components to produce an overall solution Straightforward and flexible 32
Problem Solving Process o What is it? n Analysis n Design n Implementation n Testing Test the components individually and collectively 33
Problem Solving Process 34
Problem Solving Methodologies o How to do it? n Depends upon your mode of thinking o Bricolage approach o Planned approach 35
Problem Solving Methodologies o How to do it? n Depends upon your mode of thinking o Bricolage approach o Planned approach Problem features and aspects are repeatedly tried and manipulated according to your personal way of organizing information A mistake is not an error, but a correction waiting to be made in the natural course of solving the problem 36
Problem Solving Methodologies o How to do it? n Depends upon your mode of thinking o Bricolage approach o Planned approach Uses logic, formalism, and engineering coupled with a structured methodology Inherent structure of the planned approach offers makes it easier to show correctness of solution Dominant method in terms of teaching 37
Tips o Find out as much as you can o Reuse what has been done before o Expect future reuse o Break complex problems into subproblems 38
Tips o Find out as much as you can o Reuse what has been done before o Expect future reuse o Break complex problems into subproblems Consider Research can is require and generate questions Find out what knownsignificant about thetime problem Sketching apresenter solution andbecause then repeatedly its components The worthwhile the resultrefine is a better Talk effort to theis until the entire process is specified understanding Determine what attempts have succeeded and what attempts True of the problem makes it easier to solve have understanding failed 39
Tips o Find out as much as you can o Reuse what has been done before o Expect future reuse o Break complex problems into subproblems Your Be open timetoisindirect valuable use of existing materials Correctness is probably even more valuable Use existing infrastructure that is known to work 40
Tips o Find out as much as you can o Reuse what has been done before o Expect future reuse o Break complex problems into subproblems Make as few assumptions as necessary Maximizes the likelihood that your effort can be used in future situations 41
Tips o Find out as much as you can o Reuse what has been done before o Expect future reuse o Break complex problems into subproblems Divide-and-conquer Solve subproblems and combine into an overall solution 42
Tips o Read n Problem solving texts o George Polya, How to Solve It; A New Aspect of Mathematical Method, Princeton Press, 1988 o Wayne Wickelgren, How to Solve Mathematical Problems, Dover Publications, 1995 o Paul Zeitz, The Art and Craft of Problem Solving, John Wiley, 1999 n Sociological examination of different problem solving styles o Sherry Turkle and Seymour Papert, Epistemological Pluralism: Styles and Voices Within the Computer Culture, Signs: A Journal of Women in Culture and Society, 1990 43
- Slides: 43