Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa OO A&D FOR DATABASE- DRIVEN SOFTWARE Larger software.

Slides:



Advertisements
Similar presentations
Software Engineering 2003 Jyrki Nummenmaa 1 OO ANALYSIS & DESIGN FOR DATABASE-DRIVEN SOFTWARE Larger software products typically use a relational.
Advertisements

XML DOCUMENTS AND DATABASES
Evaluation of Relational Operators CS634 Lecture 11, Mar Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Software Engineering 2003 Jyrki Nummenmaa 1 A BASIC OO SOFTWARE DEVELOPMENT PROCESS Earlier, we saw a number of different software lifecycle models.
Software Engineering 2003 Jyrki Nummenmaa 1 OBJECT ARCHITECTURE DESIGN These slides continue with our example application, based on the simplified.
1 Copyright © Cengage Learning. All rights reserved. 4 Probability.
Database Management System Module 3:. Complex Constraints In this we specify complex integrity constraints included in SQL. It relates to integrity constraints.
Software Engineering 2003 Jyrki Nummenmaa 1 OBJECT ANALYSIS Although there is some variance, most methods are based on what is called OMT (Object.
SKIPLISTS A Probabilistic Alternative to Balanced Trees.
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
CSC1016 Coursework Clarification Derek Mortimer March 2010.
Tirgul 6 B-Trees – Another kind of balanced trees Some notes regarding Home Work.
ER Modeling An E-R model is a conceptual (or logical) data model that includes –Entity (classes) –Attributes of each entity –Relationship types between.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Exercise Session 10.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 20: Binary Trees.
Multiplying, Dividing, and Simplifying Radicals
1 CSIT 320. Just as the combination of a database and a database management system collects and organizes information about an institution/company/… as.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Main challenges in XML/Relational mapping Juha Sallinen Hannes Tolvanen.
Software Engineering 2003 Jyrki Nummenmaa 1 USE CASES In this lecture: Use cases - What are use cases? - Why to use use cases? - How to write.
ONTOLOGY SUPPORT For the Semantic Web. THE BIG PICTURE  Diagram, page 9  html5  xml can be used as a syntactic model for RDF and DAML/OIL  RDF, RDF.
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa USE CASES In this lecture: Use cases - What are use.
TESTING.
Software Engineering 2003 Jyrki Nummenmaa 1 REQUIREMENT SPECIFICATION Today: Requirements Specification Requirements tell us what the system should.
Database Systems Normal Forms. Decomposition Suppose we have a relation R[U] with a schema U={A 1,…,A n } – A decomposition of U is a set of schemas.
Software Engineering 2003 Jyrki Nummenmaa 1 CASE Tools CASE = Computer-Aided Software Engineering A set of tools to (optimally) assist in each.
1 COP 3538 Data Structures with OOP Chapter 8 - Part 2 Binary Trees.
OHTO -99 SOFTWARE ENGINEERING LECTURE 5 Today: - An overview to OO Analysis and OO Design - Introduction of Assignment 2.
Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa SOFTWARE LIFECYCLE MODELS These slides contain a few.
Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa REQUIREMENT SPECIFICATION Today: Requirements Specification.
CS Learning Rules1 Learning Sets of Rules. CS Learning Rules2 Learning Rules If (Color = Red) and (Shape = round) then Class is A If (Color.
For accurate communication, since a project can have several participants, each from different background. Represent a given aspect of the system We will.
Software Engineering 2004 Jyrki Nummenmaa 1 A BASIC OO SOFTWARE DEVELOPMENT PROCESS Earlier, we saw a number of different software lifecycle models.
Artificial Intelligence in Game Design N-Grams and Decision Tree Learning.
1 © 2007 T. Horton CS 441, Summer 2007 Principles of SW Design Design Patterns in Context – Doing design: can we say more about how to go about it? Readings:
1 CS 430 Database Theory Winter 2005 Lecture 2: General Concepts.
Symbol Tables and Search Trees CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
CSC Intro. to Computing Lecture 10: Databases.
1 Conceptual Design using the Entity- Relationship Model.
Similarity Searching in High Dimensions via Hashing Paper by: Aristides Gionis, Poitr Indyk, Rajeev Motwani.
Object-Oriented Analysis and Design ธนวัฒน์ แซ่ เอียบ.
Chapter 9 Putting together a complete system. This chapter discusses n Designing a complete system. n Overview of the design and implementation process.
Ch- 8. Class Diagrams Class diagrams are the most common diagram found in modeling object- oriented systems. Class diagrams are important not only for.
Software Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
Storage Centre HKOI 2007 Senior Q1 Kelly Choi. The Problem The COW Team are going to look for treasures in N ruins in a rectangular map. The COW Team.
Program Organization Sequential Execution: One line done after the other Conditional Execution: If a test is true, one section is done, otherwise another.
Refactoring Agile Development Project. Lecture roadmap Refactoring Some issues to address when coding.
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
Class Diagrams. Terms and Concepts A class diagram is a diagram that shows a set of classes, interfaces, and collaborations and their relationships.
McGraw-Hill/Irwin© 2008 The McGraw-Hill Companies, All Rights Reserved Chapter 17 Object-Oriented Design and Modeling Using the UML.
Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa OBJECT DESIGN Now we need to design in such detail that.
Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa OBJECT-ORIENTED ANALYSIS Earlier, we saw a number of.
Software Engineering 2003 Jyrki Nummenmaa 1 OBJECT DESIGN Now we need to design in such detail that the design can be implemented. It will be.
Keeping Binary Trees Sorted. Search trees Searching a binary tree is easy; it’s just a preorder traversal public BinaryTree findNode(BinaryTree node,
The Law of Averages. What does the law of average say? We know that, from the definition of probability, in the long run the frequency of some event will.
Defects of UML Yang Yichuan. For the Presentation Something you know Instead of lots of new stuff. Cases Instead of Concepts. Methodology instead of the.
OO TESTING Module testing -> Class testing Integration testing
Relational Algebra Chapter 4, Part A
Teaching slides Chapter 8.
The Metacircular Evaluator
Relational Algebra Chapter 4, Sections 4.1 – 4.2
Information Integration Introduction (21.1)
Introduction of Week 9 Return assignment 5-2
OBJECT ARCHITECTURE DESIGN
slides created by Marty Stepp
OBJECT DESIGN Now we need to design in such detail that the design can be implemented. It will be important to know, which structures the programming language.
Implementation of Learning Systems
SHUT THE BOX! RULES INSTRUCTIONS PLAY.
SHUT THE BOX! RULES INSTRUCTIONS PLAY.
Presentation transcript:

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa OO A&D FOR DATABASE- DRIVEN SOFTWARE Larger software products typically use a relational database or several of them. The databases may exist before the software is being built. New databases may be created. Old databases may be modified, most typically they are extended. Often the database represents the biggest permanent value (software changes on top of the same database).

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Piece Special place Player Walk Card Place Flight An Initial Class Diagram Connected

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Associations? / 1 Based on our ER-diagram and the relation attributes, it would now be possible to add associations to the class diagram. Should we do so? On the other hand, they give information about the relationships between classes. However, the associations are typically used for navigation. In a database-driven application, this may be a big mistake!

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Associations? / 2 Consider, for instance, relations player and place. Suppose, for instance, that one player has a treasure and is two steps away from the starting place. We want to check up, whether any other player still has theoretical chances to win the game. Any such player needs to steal the treasure in at most two rounds. For this, we need to check all players, their places, and distances to the player with the treasure. Thus, we need to access at least relations player, place and walk (maybe also flight).

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Associations? / 3 Suppose our class diagram shows associations: Associations suggest navigation: for each player { get pl=player.place for each pl.walk … Q: What would this mean? A: It would mean database retrieval row-by-row. Walk Player Place

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Database retrieval row-by- row? Each retrieval may mean scanning of a whole relation: O(n) operations, if relation has n rows. At best, it means traversing a search structure such as a search tree: O(log n) operations. Relational databases are meant for set-based retrieval: get all data in one query. Conclusion: The associations were misleading. These kinds of stupid solutions just lead to poor performance and some people may even imagine that the database is slow!

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Set-based database retrieval Rather, make a query to retrieve all data in one go: select * from player, place, … Maybe make this definition into a view (which is like a predefined query). Define a new class for the query. The class does not need to have connections with place or player, although for the conceptual information it should. Use an object to go through the results of the query row by row, which means just one execution of the query in the database.

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa uses owns located contains play {ordered} cover end * * * ** * connected Piece Game Special place Treasure Player Map Card Place Flight Connection Classes And Associations

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Game ER Diagram Connected Treasur e Bandi t Player Place Special Place Jewel Card Is a CoversIs aLocatedOwnsFlightWalk M N M N M N N Piece Has

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Analysis Class Diagrams isAtAirport(): Boolean hasMoney(): Boolean getPlace(): Place move(p: Place) isWinner(): Boolean hasTreasure(): Boolean giveTreasure(): Treasure takeTreasure(t: Treasure) pay() clearFunds() Player name: String funds: Integer move(p: Place) getPlace(): Paikka Piece color: Integer 0..1 Card effect (p: Pelaaja) value: Integer TreasureJewel Bandit own use 0..1 Players addPlayer(n: String) nextPlayer(): Player treasurePlayer(p: Place): Player initialize() addPlayer(n: String) throwDice() movePlayer(p: Paikka) takeCard(p: Place) end() Game play throw(): Integer Dice {ordered} * 1 1 FlightTraffic getDestinations(p: Place): set of Place hasCard():Boolean giveCard() Place located * SpecialPlace NormalPlace FlightRoute place * 2 Map giveAdjacent(p: Place, n: Integer): set 1 * cover * follow In one relation In no relation

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Database Design Transform the ER model into an SQL database schema. You should know by now how to do it.

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa From relations to objects In ”traditional” OO methodology, so-called persistent objects are stored in a database. We will probably want our software to access the data in the relations. Conceptually, it will be straightforward and understandable to have one class for each relation, to access the data. You may also design the classes differently, but then the connection between the relations and the objects will be more complicated. However, if the relations reflect your ER-diagram, then many of them will be quite close to ”intuitive objects”.

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Relations-to-classes The main idea here is that we create OO classes for database objects (not the other way round). Notice that to use the database in a smart way, you will want to add views to your database. They are like predefined SQL queries, which can be used in further queries. They also require classes for accessing them. The MVC model part implementation can often largely be based on these classes.

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa User Application Choose to take card Show player’s funds with one unit taken Show Card Show player’s funds with jewel value added Sequence Diagram for ”Take Card”

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa UserPlayer Choose to take card showFunds(p:Player) Sequence diagrams are ok also here GameController reduceFunds(price) CardForPlaceQuery getCard() showFunds(p:Player) addFunds(value) showCard(card) This is a new class Also a new class, but for a query

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Operation design At the bottom level, you will encounter similar tasks as in the OO design discussed in our earlier slides. You will need to do “classic” OO design for the non-database classes. There, the rules discussed on previous lectures apply. Take, as an example, operation design, which is discussed in the following slides.

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Example: treasurePlayer(p: Place) Class: Players Operation: treasurePlayer(p: Place): Player Description: If there is a player in place p with the treasure, returns that player. Result: Returns player Q, for which Q.owns  nil and Q.uses.located = p, if such Q exists, otherwise nil. Assumes: p  nil

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Example: treasurePlayer(p: Place) Reads: Player, Piece Exceptions: Player has no piece. Algorithm: SELECT player_no FROM player, place WHERE player.place_no=place.place_no AND hasTreasure = true AND place_no = p if result-set contains player_no then return player_no elsereturn nil

Software Engineering – University of Tampere, CS DepartmentJyrki Nummenmaa Example: treasurePlayer(p: Place) – old formulation Reads: Player, Piece Exceptions: Player has no piece. Algorithm: while players not processed do Q = unprocessed player; if Q.hasTreasure() then if Q.getPlace() == p then return Q end end; return nil