170 likes | 304 Views
Java & Object-Oriented Programming. Dieter W. Storr August 2001. Java & Object-Oriented Programming. OODBMS. OOP. Classes. Objects. Methods. Subclasses. Variables. Instances. Inheritance. UML. Superclasses. OMG. Java & Object-Oriented Programming. Classes
E N D
Java & Object-Oriented Programming Dieter W. Storr August 2001
Java & Object-Oriented Programming OODBMS OOP Classes Objects Methods Subclasses Variables Instances Inheritance UML Superclasses OMG Dieter W. Storr
Java & Object-Oriented Programming • Classes • Methods are behavioral elements (algorithm, function, procedure) • Variables (data types) • Attributes are data elements (data member, instance variable, data field) • Objects (Instance) • Entities of a Class Dieter W. Storr
Java & Object-Oriented Programming Dieter W. Storr
Java & Object-Oriented Programming • Organize Classes and Class Behavior • InheritanceEnables one class(subclass) to inherit all of the behavior and attributes of another class (superclass) • InterfacesCollection of methods that indicate a class has some behavior in addition what it inherits from its superclasses. • PackagesA grouping of classes and/or sub-packages Dieter W. Storr
Java & Object-Oriented Programming • Creating a Class Hierarchy, e.g. • Dragons and Jabberwocks • Both are large monsters that eat peasants • Both have sharp claws, powerful teeth, type-A personalities • Medusa, Yeti, Sasquasch, Grue, DustBunny==> find a superclass and subclasses Dieter W. Storr
Java & Object-Oriented Programming • Creating a Class Hierarchy, e.g. • Monster Superclass • Behavior: To be ferocious, terrifying, and bad for the neighborhood • Instance variable: Sex, Color • FlyingMonster Subclass • Behavior: Swooping down on prey, carrying peasants of into the sky, dropping them from great hights Dieter W. Storr
Java & Object-Oriented Programming • Creating a Class Hierarchy, e.g. • WalkingMonster Subclass • Behavior: More susceptible to fallen arches • Four Legged Subclass of FlyingMonster • Behavior: • Subclasses Mammal, Reptile, Amphibian Dieter W. Storr
Java & Object-Oriented Programming Dieter W. Storr
Java & Object-Oriented Programming Dieter W. Storr
Java & Object-Oriented Programming class Jabberwock { String color; String sex; boolean hungry; void feedJabberwock() { if (hungry == true) { System.out.println(“Yum -- a peasant!”); hungry = false; } else System.out.println(“No -- already ate.”); } Dieter W. Storr
Java & Object-Oriented Programming void showAttributes() { System.out.println(“This is a “ + sex + “ “ + color + “ jabberwock.”); if (hungry == true) System.out.println(“The jabberwock is hungry.“); else System.out.println(“The jabberwock is full.“); } <snip> Dieter W. Storr
Java & Object-Oriented Programming • Unified Modeling Language • UML (Unified Modeling Language) is a standard notation for the modeling of real-world objects as a first step in developing an object-oriented design methodology. Dieter W. Storr
Java & Object-Oriented Programming • Its notation is derived from and unifies the notations of three object-oriented design and analysis methodologies: • Grady Booch's methodology for describing a set of objects and their relationships • James Rumbaugh's Object-Modeling Technique (OMT) • Ivar Jacobson's approach which includes a use case methodology Dieter W. Storr
Java & Object-Oriented Programming • Use-Case Modeling • An actor represents anything that interacts with the system • A use case is a “chunk” of functionality performed by a system, yielding a measurable result of value for an actor Dieter W. Storr
Java & Object-Oriented Programming A use case diagram is drawn to illustrate that use cases and actors interact by sending stimuli to one another Customer Conduct Bank Transactions Bank Run Reports Maintain ATM Machine ATM Maintainer Dieter W. Storr
Java & Object-Oriented Programming • Scenario • Object (State, Behavior, Identity) • Interaction Diagrams • Sequence Diagrams and Scripts • Collaboration Diagrams • Link Notations • Classes and Objects Dieter W. Storr