7/27/10 ITK 179

417 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
417
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

7/27/10 ITK 179

  1. 1. What is Computer Science? Hardware Software Theory 1800 AD  Architecture 1945 AD  Languages 1960 AD 
  2. 2. 08/16/10 Alan Turing (1912-1954) – The Enigma The man who invented the computer Image from http:// ei.cs.vt.edu/~history/Turing.html <ul><ul><li>Turing Machines </li></ul></ul>Turing Award: the Nobel Prize in CS
  3. 3. Said: “ Turing Machines are human that compute .” “ In logic nothing is accidental ” Ludwig Wittgenstein (1889-1951) Image from http:// www.ags.uci.edu/~bcarver/wgallery.html
  4. 4. Hardware 0 1 1 0 2 4 =16 0 1 0 0 1 1 0 0 ... ... ... ... Software
  5. 5. Hardware Input device Output device Central Processor Unit: Internal Storage Control Unit + Arithmetic-Logic Unit (ALU)
  6. 6. Software: <ul><li>Operation systems </li></ul><ul><li>Applications </li></ul>XP, Unix, VAX Words Excel E.I. Hello Java Hello.java javac Hello.class (class loader) Eclipse, NetBean IDE, Sun
  7. 7. IDE ( Integrated Development Environment ) <ul><li>A customized plain text editor </li></ul><ul><li>Compiler </li></ul><ul><li>Loader </li></ul><ul><li>Debugging tool </li></ul>JDK (Java Development Kid) = IDE+JRE Eclipse = IDE <ul><li>notepad </li></ul><ul><li>javac hello </li></ul><ul><li>java hello </li></ul><ul><li>...... </li></ul>
  8. 8. How much effort in solving a problem This is more important and difficult; data structures , algorithm analysis This is a basic requirement. We need to reduce this portion 6 month from now
  9. 9. Problems  Solutions cycle Problems System analyst, Project leader Algorithms Senior Programmers Programs in JAVA (or any high level Programming Language) compiler Assembly Assembler Machine code linker Results Customers Programmers Syntax Semantics (human) IDE (computers)
  10. 10. Procedure vs Object To solve a program is: <ul><li>To find a way to manipulate data -- </li></ul><ul><li>We design procedures </li></ul><ul><li>Procedure-Oriented Programming </li></ul><ul><li>Statements + functions  programs </li></ul><ul><li>To find objects to model the problem – </li></ul><ul><li>We choose data (object) </li></ul><ul><li>Object-Oriented Programming </li></ul><ul><li>Classes + Objects  programs </li></ul><ul><li>(interfaces, methods, attributes…) </li></ul>
  11. 11. What is “model”? X models an ideal style of Y X  objects Y  problem
  12. 12. Class A class is a concept of something Vehicle 4 wheels, seat, engine, windows…… Truck ………… Sedan ………… SUV …………
  13. 13. Objects: an instance of some class Vehicle SUV Honda Pilot 011-JAV instantiation Class Object
  14. 14. Method & Attribute Each class: Method & Attribute The class designer should determine what kind of methods and attribute its object should have Method: behaviors, service, operation, and functionalities of the object. Field (attribute): the information, status, and properties of the object.
  15. 15. 011-JAV Honda Pilot Services, methods Attributes UML (Unified Modeling Language) class diagram Class name Z.Turn(right) Z Plate: 011-JAV Color: Blue Engine size: 3.0 L ... ... Start the engine() Stop() Turn (direction) Air() ... ... Honda Pilot
  16. 16. Services, methods Attributes UML class diagram for Robot Class name Constructor int street int avenue Direction direction ThingBag backback ... ... Robot(City aCity, int aStreet, int aAvenue, Direction aDir) void move() void turnLeft() void pickThing() void putThing() ... ... Robot
  17. 17. Modeling what? Modeling Robots with Software Objects - the title of 1.3 in ITK168 textbook But this phrase does not make too much sense to me... Should be: Modeling Robots in a City with Software Classes. int street int avenue Direction direction ThingBag backback ... ... Robot(City aCity, int aStreet, int aAvenue, Direction aDir) void move() void turnLeft() void pickThing() void putThing() ... Robot String name int stree_No ... ... .... .... City(...........) .... .... .... .... City
  18. 18. Object–Oriented Programming <ul><li>Model the structure and behavior of a system through the interaction of software objects that represent entities from the problem domain </li></ul>
  19. 19. Task: deliver X from (1,2) to (3,1) and step away import becker.robot.*; public class DeliverX{ public static void main(String args[]){ // set up Initial situation City A = new A(); Thing X = new Thing(A,1,2); Robot karel = new Robot(A,0,0, Direction.East); // direct the robot karel.move(); karel.move(); karel.turnRight(); karel.move(); karel.pickThing(); karek.move(); karel.move(); karel.turnRight(); karel.move(); karel.putThing(); karel.move(); } } name Karel X 4 3 2 1 0 4 3 2 1 0
  20. 20. A Java program import javax.swing.JOptionPane; public class time{ public static void main(String args[]){ int x,y,z; String X,Y; X = JOptionPane.showInputDialog(&quot;Input x&quot;); Y = JOptionPane.showInputDialog(&quot;Input y&quot;); x = Integer.parseInt(X); y = Integer.parseInt(Y); z = x*y; JOptionPane.showMessageDialog( null, x + &quot; * &quot; + y + &quot; = &quot; + z, &quot;The product of &quot; + x + &quot; and &quot; + y, JOptionPane.PLAIN_MESSAGE ); System.exit(0); } } classes methods package arguments Variable declaration
  21. 21. Data Type <ul><li>Characterize data into different kinds for convenience </li></ul><ul><li>bit </li></ul><ul><li>byte </li></ul><ul><li>integer </li></ul><ul><li>ascii </li></ul><ul><li>character </li></ul><ul><li>array </li></ul><ul><li>string </li></ul><ul><li>real </li></ul><ul><li>record </li></ul>+ operations  Objects
  22. 22. Abstraction <ul><li>A tool to manage complexity </li></ul><ul><li>Hide irrelevant details; focus on the features needed to use a thing </li></ul><ul><li>Examples </li></ul><ul><ul><li>File deletion using icons </li></ul></ul><ul><ul><li>The brakes on a car </li></ul></ul><ul><ul><li>Television remote </li></ul></ul><ul><ul><li>What else? </li></ul></ul>
  23. 23. Data Type <ul><li>Specification View of a data type </li></ul><ul><ul><li>Data values </li></ul></ul><ul><ul><li>Operations defined on those values </li></ul></ul><ul><ul><ul><li>Abstract Data Type (ADT) – use of abstraction! </li></ul></ul></ul><ul><li>Implementation View of a data type </li></ul><ul><ul><li>Language-specific representation for the values </li></ul></ul><ul><ul><li>Implementation of the operations </li></ul></ul><ul><ul><li> Implementation of an ADT </li></ul></ul>
  24. 24. Abstract model of Priority Queues ( Specification View) Priority Queue a black box insert one item Get the one with the highest priority the minimum one (or equivalently, maximum ) Abstract Data Type (ADT)
  25. 25. Abstract model of Priority Queues ( Implementation View) Binary Search Tree or Binary Heap? insert one item Get the one with the highest priority the minimum one (or equivalently, maximum ) Abstract Data Type (ADT)
  26. 26. The Java Collections Framework (JCF) UML Class Diagram
  27. 27. Collection Operations <ul><li>Add an element </li></ul><ul><li>Remove an element </li></ul><ul><li>Replace an element </li></ul><ul><li>Retrieve an element </li></ul><ul><li>Determine if a collection contains an element </li></ul><ul><li>Get the collection’s size </li></ul><ul><li>Determine if a collection is empty </li></ul><ul><li>Traverse a collection </li></ul><ul><li>Determine if two collections are equal </li></ul><ul><li>Clone a collection </li></ul><ul><li>Serialize a collection </li></ul>Most collections support the same operations, but may give them different names.

×