- announcements - exam conflicts - CodeLab 1 due today @ 11:58 pm - reading: Ch 1, Ch 2.1-2.3 - online survey - CodeWarrior Tutorial due Monday - CodeLab 2 due Wednesday 9/15 - Assignment 0 posted online (due Friday 9/17) - Office Hours room change to CSS 1306 - 11:00 last week catchup - how parts of computer work as pertinent to Java - programs stored in storage device - secondary - nonvolatile - slow - when run, bring program into main memory - primary/volatile/fast - prefixes are binary - k = 2^10 = 1,024 - M = 2^20 = 1,048,576 - G = 2^30 = 1,073,741,824 - Stack, heap - static, constant - CPU does actual work - may use communication device (modem, cable, DSL) - Programming Lang - categories - machine - assembly (assembler) - high-level - OO - compilers - Java bytecode, VM and interpreter - errors - compile-time - run-time - logical - Why not Engligh - Java - James Gosling, Sun - C based - web programming: applets (mini-app for browser) - applications - clean design - Demo program /* * Demo of a program. * No one should be deprived of a "Hello world" program! */ public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } 11:10 OBJECTS AND CLASSES OBJECT DEFINITION OBJECT UML CLASS DEFINITION CLASS UML DISTINCTION: SOPHIE'S WORLD ____________ | | | | | ---------- | |____________| ______________ | | | | | | | | |______________| - object: thing we can imagine - data - ops that manipulate data - programs: interacting objects - notation: UML = Unified Modeling Language - mulitple objs of same type in program - program has instr to create objs - class: obj definition - what objs can and cannot do - obj: instance of exactly one class - obj "belongs to" class - no lim on # instances of a class - class versus object: Sophie's World 11:20 MESSAGES AND METHODS MESSAGE: TO OBJ FROM OUTSIDE METHOD: INTERNAL IMPL OF MESSAGE UML ARGUMENTS RETURN VALUES INSTANCE VS CLASS ____________ | | () | | ------------------->| ---------- | <|---o |____________| - programming: 1) define classes 2) use classes & objs to accomplish tasks - message - instruct class/obj to perform task - message UML: - must program class/obj to process msg - method: instructions to perform a task - class: defined for class } more - instance: defined for obj } below - argument: value passed to obj in association w/ msg - msg name sent must match some method def - instance methods: pertain to individual instance/obj - one-way msg - obj performs msg op - obj does not communicate back to msg sender - two-way msg: obj returns information to sender - can be data can be success/fail status - class methods: pertain to all instances of a class - deal w/ collective info about all instances of a class 11:30 CLASS AND INSTANCE DATA DATA DATA AND MESSAGES CLASS VS INSTANCE MEMBER/VALUE TYPES: VARIABLE VS CONSTANT ______________ | | | | | ---------- | |______________| | | | | | {frozen} | | __________ | | | | | | | | | | |__________| | |______________| ______________ | | | | |______________| | | | | | ---------- | | {frozen} | | __________ | | | | | | | | | | |__________| | |______________| - class & instance data values - store information about self - often altered by messages - all instances of same class - possess same set of data values - content may vary - class data value - information shared by all instances - collective information about the instances - an instance can access data vals of the class to which it belongs - data member synonym for data val - representing class data val as instance data val wastes space - types of data vals - variable: can change over time - constant - cannot change over time - keyword frozen on UML diagrams - data val summary - class var - class const - instance var - instance const 11:40 INHERITANCE DEFINITION SUPERCLASS/ANCESTOR/BASE CLASS SUBCLASS/DESCENDANT/DERIVED CLASS HIERARCHY POWERFUL ___ | | |___| ^ | ___ | | |___| - inheritance - use to design 2+ entities that are different but share many common features 1) superclass/ancestor/base class - class w/ common features - cannot refer to items defined in subclass 2) subclass/descendant/derived class - extension of common class - inherits all attributes of common class - can refer to items defined in superclass - hierarchy - subclass is superclass of other classes - powerful: develop complex programs efficiently and elegantly 11:45 SOFTWARE ENGINEERING/LIFE CYCLE - computer programming - writing code - software development - good developer - know lang - know how to design program - here: OO - software engineering - systematic, disciplined - development, testing, maintenance - software life cycle - conception --> operation - phases - analysis - needs of customer - feasibility - yes --> requirements specification - testable - design - specification --> design - OO: set of classes - coding - design --> program - here: Java program - easier than design - testing - run program - varying data sets - types (OO) - unit: classes individually - integration: classes working together - debugging: eliminating errors (design and coding) - operation - use program - maintenance - make changes - additional features - undetected errors - 70% software cost