190 likes | 292 Views
CSE115: Introduction to Computer Science I. Dr. Carl Alphonce 219 Bell Hall 645-4739 alphonce@buffalo.edu. Phones off Signs out. Announcements. Advice take notes in lecture don’t rely only on slides REVIEW notes regularly bring notes to recitation Web-CAT we’re tweaking it
E N D
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 645-4739 alphonce@buffalo.edu
Phones off Signs out
Announcements • Advice • take notes in lecture • don’t rely only on slides • REVIEW notes regularly • bring notes to recitation • Web-CAT • we’re tweaking it • don’t worry if you get e-mail about regrading
Agenda • Brief review • Unified Modeling Language (UML) • Methods in general
Object • class instantiation • created by ‘new’ + constructor • representation stored on heap
Reference • an address • value of ‘new’ expression
Variable • name • location • type • value • scope • lifetime • local variable • instance variable
Expression • examples of expressions • ‘new’ expression • variable expression (on RHS of assignment) example1.Terrarium t1; example1.Terrarium t2; t1 = new example1.Terrarium(); t2 = t1;
package • organizational mechanism • each class belongs to a package
class • “blueprint” of an object
constructor • used by new to initialize a new object
scope • static property of variable • part of program text where a variable declaration holds
lifetime • runtime property of variable • period of time during which variable exists in memory
UML • Unified Modeling Language • industry standard • Class diagrams
UML • Unified Modeling Language • express design without reference to an implementation language • For example
Binary Class Relationships:directional • binary two classes are involved • source class has code modification • target class does not • composition • source: WHOLE • target: PART • in diagram: • line decoration is on source/WHOLE • show only detail that’s needed/desired
package cse115; public class Dog { public Dog() { } } package cse115; public class Tail { public Tail() { } }
package cse115; public class Dog { private Tail _tail; public Dog() { _tail = new Tail(); } } package cse115; public class Tail { public Tail() { } }