•7/12 /07 F-1 © 2010 T. Horton CS 4240 Principles of SW Design Packages in Java and UML.

Slides:



Advertisements
Similar presentations
Extending Eclipse Kai-Uwe Mätzel IBM OTI Labs Zurich
Advertisements

1 CIS224 Software Projects: Software Engineering and Research Methods Lecture 9 Object, Package, Component and Deployment Diagrams (Based on Fowler, 2004,
Packages Sudhir Talasila Preeti Navale. Introduction Packages are nothing more than the way we organize files into different directories according to.
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
Software Engineering 2003 Jyrki Nummenmaa 1 OBJECT ARCHITECTURE DESIGN These slides continue with our example application, based on the simplified.
Stability and Volatility is Software Design H. Rahnama Tutorial in software engineering.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Architectural Modeling Notations.
Inheritance Inheritance Reserved word protected Reserved word super
UML Static diagrams. Static View: UML Component Diagram Component diagrams show the organization and dependencies among software components. Component:
1 © Wolfgang Pelz UML3 UML 3 Notations describe how to use reusable software. Package Component Deployment Node.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Component and Deployment Diagrams
Developed by Reneta Barneva, SUNY Fredonia Component Level Design.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Package design and the Iterative process model. What is a package? Classes are not sufficient to group code –Some classes collaborate, implying dependencies.
CSE 115 Week 2 January , Wednesday Announcements Pick up Syllabus if you need one Pick up Syllabus if you need one Recitation Change Form.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
The Design Discipline.
Chapter 13 Starting Design: Logical Architecture and UML Package Diagrams.
Systems Analysis and Design in a Changing World, Fifth Edition
Smith’s Aerospace © P. Bailey & K. Vander Linden, 2005 Architecture: Component and Deployment Diagrams Patrick Bailey Keith Vander Linden Calvin College.
Session 24 Modeling the Development Environment Written by Thomas A. Pender Published by Wiley Publishing, Inc. October 27, 2011 Presented by Hyewon Lim.
OSGi.
Alexander Serebrenik, Serguei Roubtsov, and Mark van den Brand D n -based Design Quality Comparison of Industrial Java Applications.
1 OO Design Novosoft, 2001 by V. Mukhortov. 2 OO Design Goals  Flexibility Changes must be localized  Maintainability Modules requiring changes can.
Ch:10 Component Level Design Unit 4. What is Component? A component is a modular building block for computer software Because components reside within.
Component Basics CS6961 – Lecture 6 Nathan Dykman.
Advanced Principles II Principles of Object-Oriented Component Design Copyright  by Object Mentor, Inc All Rights Reserved Portions of this.
Component Technology. Challenges Facing the Software Industry Today’s applications are large & complex – time consuming to develop, difficult and costly.
Systems Analysis and Design in a Changing World, 3rd Edition
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 12-5 Software Engineering Design Goals.
4/1/05F-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Packages and Components in Java and UML.
1 OO Package Design PrinciplesStefan Kluth 4OO Package Design Principles 4.1Packages Introduction 4.2Packages in UML 4.3Three Package Design Principles.
First Venture into the Android World Chapter 1 Part 2.
OO Design Principles Copyright © Vyacheslav Mukhortov, Nikita Nyanchuk-Tatarskiy, Copyright © INTEKS LLC,
Inheritance. Inheritance is a fundamental object-oriented design technique used to create and organize reusable classes Chapter 8 focuses on: deriving.
Chapter 8 Specialization aka Inheritance. 2 Inheritance  Review of class relationships  Uses – One class uses the services of another class, either.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
CHAPTER 3 MODELING COMPONENT-LEVEL DESIGN.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 5 Methods.
CSC 520 – Advanced Object Oriented Programming, Fall, 2010 Thursday, October 14 Week 7, UML Diagrams
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Identifying classes, Packages and drawing class Diagrams, Object Diagrams and composite structure diagrams Week 07 1.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
1 Good Object-Oriented Design Radu Marinescu Lecture 3 Principles of Object-Oriented Design Part II 19 th November 2002.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
11 Systems Analysis and Design in a Changing World, Fifth Edition.
Principles of Package Design COMPOSE AT A HIGHER LEVEL OF ABSTRACTION.
1 Advanced Object- oriented Design – Principles CS320 Fall 2005.
GRASP – Designing Objects with Responsibilities
Metrics of Software Quality
Chapter 12 Object Oriented Design Principles
Unified Modeling Language
Project Topic 2: Migration to Java 9
The Object Oriented Approach to Design
Principles of Package Architecture
Starting Design: Logical Architecture and UML Package Diagrams
Analysis models and design models
Overriding Methods & Class Hierarchies
Chapter 7 –Implementation Issues
Applying OO Concepts Using Java
OBJECT ARCHITECTURE DESIGN
Principles of Object-Oriented Design Part II
the Java package design analyser
Principles of High-Level Design
Chapter 10 – Component-Level Design
Presentation transcript:

•7/12 /07 F-1 © 2010 T. Horton CS 4240 Principles of SW Design Packages in Java and UML

•7/12 /07 F-2 Suggest Readings Any Java text on packages –E.g. Just Java 1, in Chapter 5

•7/12 /07 F-3 Packages in Java A collection of related classes that form a library Also, packages in Java are namespaces –Avoid name-clashes. Usually means.java and.class files in a directory tree that mimics package structure –E.g. for the class called A.B.SomeClass, then the files will be: /A/B/SomeClass.java /A/B/SomeClass.class –Not required: could be in a database somehow –Note some IDEs (e.g. Eclipse) give a package view (better than a physical directory view of the files)

•7/12 /07 F-4 Packages in Java (reminders) Putting classes into packages. At top of file: package edu.virginia.cs441 No package statement in file? Still in a package: the default package –Recall if you don’t declare something public, private or protected, it has “default visibility” –“Real” programmers always use packages

•7/12 /07 F-5 Compiling and Running To compile: javac –Example: javac edu\uva\cs441\Foo.java To run: java –Run-time starts looking at one or more “package roots” for a class with the given name –Example: java edu.uva.cs441.Foo –The argument is not a file! It’s a class. –Where to look? CLASSPATH variable Also, you can list jar files in this variable

•7/12 /07 F-6 jar files Bundles package directory structure(s) into one file –Like a zip file –Easier to distribute, manage, etc. –Let Java run-time know to look in a jar file, or Make the jar file “clickable” like a.EXE file Note: think of jar files as components (like DLLs) –If you recompile a.java file, must update the jar file

•7/12 /07 F-7 UML and Packages UML supports a way to group model elements –Calls this a package. Roughly equivalent to Java packages. –Can be applied to any UML modeling element, not just classes Some UML tools rely on UML packages to organize their models –E.g. Visio, Together

•7/12 /07 F-8 UML Packages and Java For Java, want to show: –What packages exist –What’s in them –How they depend on each other Create a static structure diagram with just packages –Think of it as a “package diagram” (but this is not a standard UML term) –List what classes (or classifiers) are in it –Show dependencies

•7/12 /07 F-9 Drawing Packages in UML Symbol looks like folder icon –Name in tab or in “body” –Can put classifiers names in body with visibility Dashed arrows mean dependencies –Code in otherPackage must use a class in myPackage Not just import the package. Use a class somehow. Can nest packages; tag them; stereotype them; etc.

•7/12 /07 F-10 Principles of Package Design How to group classes? How to analyze a package? General principles –Gather volatile classes together Isolate classes that change frequently –Separate classes that change for different reasons –Separate high-level architecture from low-level Keep high-level architecture as independent as possible More later on this!

•7/12 /07 F-11 REP: Release/Reuse Equivalency Princple We reuse packages not individual classes One reason to create a packages is to create a reusable “component” “Granule of reuse is the granule of release” Author should maintain and release by package –Release management: older versions, announce changes, etc. –More trouble to do this for individual classes!

•7/12 /07 F-12 CCP: Common Closure Principle Classes in a package should be closed against the same kind of changes. Group classes by susceptibility to change –If classes change for the same reason, put them in one package –If that change is required, that entire package changes But no other packages

•7/12 /07 F-13 CRP: Common Reuse Principle Classes in a package are reused together. If you reuse one class, you will reuse them all. –Group related things together for reuse. If scattered, then changes will affect multiple packages –And more things many depend on multiple packages Try not to include classes that don’t share dependencies This is a form of “package cohesion”

•7/12 /07 F-14 ADP: Acyclic Dependencies Princple Allow no cycles in the package dependency graph. When cycles exist –in what order do you build? –what’s affected when package X is modified? Note we’ve moved on to “package coupling”.

•7/12 /07 F-15 SDP: Stable Dependencies Principle Depend in the direction of stability. –A package should not depend on other packages that are less stable (i.e. easier to change) –Target of a dependency should be harder to change A package X may have many incoming dependencies –Many other packages depend on it –If X depends on something less stable, then by transitivity all those other packages are less stable

•7/12 /07 F-16 SAP: Stable Abstractions Principle A package should be as abstract as it is stable How to keep a package stable? If it’s more “abstract”, then other can use it without changing it –Like the Open/Closed Principle for classes (OCP) –Extend but don’t modify

•7/12 /07 F-17 Package Metrics Tool: JDepend Tool that processes Java packages and provides package-level metrics Benefits (from the author) –Measure Design Quality –Invert Dependencies –Foster Parallel, Extreme Programming –Isolate Third-Party Package Dependencies –Package Release Modules –Identify Package Dependency Cycles

•7/12 /07 F-18 JDepend Metrics (1) Number of Classes and Interfaces –number of concrete and abstract classes (and interfaces) –an indicator of the extensibility of the package. Afferent Couplings (Ca) –number of other packages that depend upon classes within the package –an indicator of the package's responsibility Efferent Couplings (Ce) –number of other packages that the classes in the package depend upon –an indicator of the package's independence

•7/12 /07 F-19 JDepend Metrics (2) Abstractness (A) –ratio of the number of abstract classes (and interfaces) to the total number of classes –range for this metric is 0 to 1 A=0 indicating a completely concrete package A=1 indicating a completely abstract package

•7/12 /07 F-20 JDepend Metrics (3) Instability (I) –ratio of efferent coupling (Ce) to total coupling (Ce + Ca) such that I = Ce / (Ce + Ca) –an indicator of the package's resilience to change –range for this metric is 0 to 1: I=0 indicating a completely stable package I=1 indicating a completely instable package

•7/12 /07 F-21 JDepend Metrics (4) Distance from the Main Sequence (D) –perpendicular distance of a package from the idealized line A + I = 1 –an indicator of the package's balance between abstractness and stability Package Dependency Cycles –package dependency cycles are reported

•7/12 /07 F-22 JDepend Links Home for JDepend – OnJava article: Eclipse plug-in: JDepend4Eclipse –

•7/12 /07 F-23 Unused slides (for now)

•7/12 /07 F-24

•7/12 /07 F-25 UML Component Diagrams UML also has a diagram to show components –And also deployment diagrams: show how they’re deployed physically (perhaps on different nodes) –Both of these are higher-level design views, e.g. architectural Component means physical module of code –In Java, a jar file Do we need this in CS441? –Probably not: packages are probably enough –But, one component (e.g. a jar file) can contain more than one package

•7/12 /07 F-26