3Why Object Oriented Approach? Advances in application development drove the object oriented approachApplications are more complex - graphical user interfaces utilizing diverse data types such as sound, video and textApplications are based on ‘object’ patterns that have been developed and tested - reusability
4Why Object Oriented Approach? Object Oriented Databases differ from Relational Databases but there are similarities:Relational model emphasizes an entity and it’s attributes and keeps separate the data manipulationObject Oriented model emphasizes attributes and data process – encapsulating both into a single object
5Why Object Oriented Approach? Self-contained objects can be reused and moved around with relative easeSupports direct many-to-many relationshipsOO databases are navigational - Access to data is through relationships stored within the data themselves (remember hierarchical and network databases?)Not well suited to ad hoc queries
6Why Object Oriented Approach? Two types of OO DatabasesPure object-oriented - based solely on the object-oriented data model (I.e. CA – Jasmine)Hybrid object oriented – primarily relational – stores objects in relations (this is what we will focus on)
8Objects“An object is an abstract representation of some real world entity that has a unique identity, embedded properties, and the ability to interact with other objects and act upon itself” (text)It is a software construct that encapsulates state and behavior
9ObjectsEach of these objects has a unique identity but they share common general characteristics such as name, address, date of birth
10Objects Objects are described by attributes or instance variables Each attribute has a unique name, a base data type (integer, string etc) and a domain (constraint)An object’s attribute can be single-valued or multi-valuedAn object can reference one or more other objects
11Base data type is ‘real’ with values between 0.00 and 4.00 * Represents an attribute that references one or more other objectsMAJOR references another object called DEPARTMENTADVISOR references another object called PROFESSORCOURSES_TAKEN references another object called COURSECOURSE is a collection object because Course is a list of objects
12ObjectsEach object has a unique identifier, called an OID (Object ID) **Note: this is not a primary keyOID is assigned by the system at the moment the object is created and can never be changedOID does not depend on the object’s attribute valuesOID is deleted when the object is deleted and can never be re-used
13ObjectsNote: There is no PK or FK notation in object oriented data design!
14ObjectsStateA set of values that the object’s attributes have at any given timeTo change the objects state, you must change the values of the object’s attributesTo change the value of the object’s attributes, send a message to the objectThe message will invoke a method
15ObjectMethodsThe code that performs a specific operation on the object’s dataCan change the object’s attribute values or can return the value of selected object attributesAn object invokes a method by sending a messageRepresents the object’s behavior
17ClassesA collection of similar objects with shared structure (attributes) and behavior (methods)All objects in a class share the same structure and the same methodsEach instance of an object is a class instance or an object instanceEach instance of a CLASS is an OBJECT with a unique OID
18Classes Class is similar to an Entity in a relational data model Class contains the common features for all the objects in a class, including their structure and methodsClass is a template to create the object
19Classes Types of classes generally used: Entity – these classes reflect real world data which relates to the business requirementsBoundary – these classes handle the communication between the system surrounding and the inside of the system (usually relate to interfaces)Control – these classes coordinate the events needed to realize the behavior (I.e. they know where to find the data but not how to find it)
22UML Universal Modeling Language A methodology to follow to model Object Oriented structuresWe will use Rational Rose to document our OO structuresStructure of a class in UML notation:Class NameAttributesOperations(Methods)
23UML How are classes identified? Classes are identified for a use case A use case represents a process with a systemUse case descriptions describe what a use case does. Scenarios describe different paths through a use case
25UML Sample Use Case Description Use Case Specification: Browse Catalog Brief DescriptionThis use case describes how a shopper can browse the catalog of items that are available to be bid on.PreconditionsAt the moment when the use case begins, the system is displaying the Online Auction Main Page.Basic FlowThe use case begins when the shopper selects the Browse Catalog option on the Online Auction Main Page.The system retrieves the list of categories (E1) and the system displays the Category Page with a drop down list of categories and an Exit Button.If the shopper selects the Exit Button, the system performs Exit (S1).If the shopper selects an option from the drop down list, the system retrieves all the items for that category (E1) and displays an Item List Page showing a table with item names with a Display Button and an Exit Button.
26UML To discover classes: Use existing models (will identify classes, attributes and methods/operations)Use a category list (will identify classes, attributes)Use noun phrases (will identify classes, attributes)Objective is to find the data that is requiredWe will identify entities as we did for relational – through a business overview and we will document the class diagram in Rational Rose
27Existing Data Models Already published and can be re-used Retrieved from:
28Conceptual Class Category Category ListFocuses on a list of common categories which emphasis business information system needsConceptual Class CategoryExamplesBusiness TransactionsGuidelines: These are critical.Sale, PaymentTransaction Line itemsGuidelines: These are the line items associated with transactions.SalesLineItemProduct or service related to a transaction or a transaction line itemGuidelines: Transactions are for something (a product or service)ItemRoles of people or organizations related to the transaction; actors in the use caseGuidelines: We usually need to know about the parties involved in a transactionsCashier, Customer
29Noun Filtering Done for each scenario (not for a use case description) Underline the noun phrases in the scenarioPlace the candidate noun phrases into a noun filter table templateFilter the noun phrases through a process of eliminationDraw class diagram
30UML Sample Scenario with noun filtering System Actor Scenarios HD Browse Item ScenarioPrecondition: At the moment when the scenario begins, the system is displaying the Online Auction Main Page.ActorSystemSelects the Browse Catalog option on the Online Auction Main Page.Retrieves the list of categories and displays the Category Page with a drop down list of categories and an Exit Button.Selects an option from the drop down listRetrieves all the items for that category and displays an Item List Page showing a table with item names with a Display Button and an Exit Button.Selects an item and clicks the Display Button.Retrieves the product name, it’s picture and a description and displays the information on the Item Information Page with a Place Bid Button and an Exit Button.Clicks the Place Bid Button.Use case ends and starts the Place Bid use case.
31UMLSampleSequenceDiagram – used to discover methods
32UML Sample Class Diagram methods/operations relationship Relationship nameclassattributesmultiplicity
33UMLClass SyntaxName – should meaningfully reflect the responsibility of the classI.e. CustomerAttributes – the set of characteristics necessary to describe the classI.e. firstName, lastName, initial, dateOfBirthEach attribute has a unique name and data typeSimilar to attributes in relational (columns in a table)Operations/Methods – what actions can be carried out on an instance of the classI.e. addDateOfBirth, retrieveLastName
34UML Attributes Can be of a base data type or an abstract data type i.e. real, integer, string or characterSubject to a predefined set of operations (i.e. integer base data type can be used for addition, subtraction, multiplication and division)Can have a domain (constraint)Abstract data typeUser definedDescribes a set of similar objects
35UML Object Oriented Data Model A conceptual model Drawn in MSVisio Identify the main entitiesIdentify attributes (both base data type and abstract data type).If an abstract data type has attributes of its own, create a new class for that abstract data type and include the attributes in it
36UMLSample class:abstract data typesBase data type
37Discovering Classes - Example Sun Life provides insurance plans to employees of Seneca. An employee must register for a plan. Each plan has a list of benefits associated with it (for instance, dental, orthodontic, prescriptions, glasses, long term disability etc). Employees can select which benefits they want (they don’t have to sign up for all of them). Employees can also cover their children (or dependents).
38UMLSample Conceptual Class Diagram:Abstract data typeBase data type
39UMLSample Conceptual Class Diagram (with multiplicity):
40Discovering Classes - Example Seneca College wants to create a website to allow an alumni or a company to be able to make contributions. These customers will be use an id to track their contributions. Contributions will include customer name, address and phone number. When a contribution is made, the customer can select a specific area for their contribution amount to be directed. For instance, they may want to direct their contribution to the athletic department, student housing or to a specific academic department such as Computer Studies. Customers need to specify whether they want a tax receipt or not and they can either be invoiced for their contribution or they can pay for it by credit card.
41UML Sample Conceptual Class Diagram: Abstract data types – refer to another class
42OO Database Design vs Relational Database Design Model PhaseOO ModelContentRelational ModelConceptual ModelObject Oriented Data Model (OODM) – MSVisioMajor classes; some attributes defined; shows all relationships (including M:N)Entity Relationship Diagram (ERD) – MSVisioMajor entities; some attributes defined; shows all relationships (may show M:N)Logical ModelClass Diagram – Rational RoseClasses; attributes; relationships (can still have M:N)Entities; attributes; PKs, FKs, relationships (no M:N)Physical ModelRelational Schema – MSAccessTables; attributes, PKs, FKs, all attributes atomic, no MVD