Introduction to Modeling Java and UML

1,132 views

Published on

Published in: Technology
  • Be the first to comment

Introduction to Modeling Java and UML

  1. 1. Chapter 1 Introduction to Modeling Java and UML 鄧姚文 [email_address] http://w3.im.knu.edu.tw/~joseph
  2. 2. Agenda <ul><li>What is modeling? </li></ul><ul><li>UML </li></ul><ul><li>Modeling software systems with UML </li></ul><ul><li>Modeling process </li></ul>
  3. 3. Introduction <ul><li>Why Java? </li></ul><ul><ul><li>A good object-oriented programming language </li></ul></ul><ul><ul><li>Web-enabled enterprise computing (J2EE) </li></ul></ul><ul><ul><li>Excellent support for exception handling and concurrency </li></ul></ul><ul><li>Other OO languages </li></ul><ul><ul><li>Small Talk, C++, Object Pascal, C#, Python </li></ul></ul>
  4. 4. Goal of This Book <ul><li>Be able to </li></ul><ul><ul><li>Communicate an understanding of OO modeling theory and practice to others </li></ul></ul><ul><ul><li>Communicate an understanding of UML notation to others </li></ul></ul><ul><ul><li>Critically review a wide variety of UML software models </li></ul></ul><ul><ul><li>Use UML to create a detailed understanding of the problem from the user’s perspective </li></ul></ul><ul><ul><li>Use UML to visualize and document a balanced solution using the full suite of Java technologies </li></ul></ul><ul><ul><li>Use UML to describe other technologies and class libraries </li></ul></ul>
  5. 5. What Is Modeling? <ul><li>A model is a simplification with a purpose </li></ul><ul><li>Use precisely defined notation to describe and simplify a complex and interesting structure, phenomenon, or relationship </li></ul><ul><li>Real-world examples </li></ul><ul><ul><li>The solar system model </li></ul></ul><ul><ul><li>Mathematical models </li></ul></ul>
  6. 6. 地軸傾斜 北極冬天沒陽光 南極夏天沒黑夜 以太陽系模型說明極地永晝與永夜
  7. 7. What Is Modeling? (cont’d) <ul><li>Simplification </li></ul><ul><ul><li>Less complex, more accessible </li></ul></ul><ul><li>Varying perspectives </li></ul><ul><ul><li>Describe the system from different perspectives </li></ul></ul><ul><ul><li>Help developers manage complexity </li></ul></ul><ul><li>Common notation </li></ul><ul><ul><li>To facilitate communication </li></ul></ul><ul><ul><li>Allows developers to combine their efforts and to work in parallel </li></ul></ul>
  8. 8. UML <ul><li>Unified Modeling Language </li></ul><ul><li>A language for specifying, visualizing, constructing, and documenting the artifacts of software systems </li></ul><ul><li>A set of precise notations </li></ul><ul><li>Helps developers create ideas and communicate them </li></ul><ul><li>An open standard controlled by OMG </li></ul>
  9. 9. UML The Basics <ul><li>Abstraction 抽象化,摘要 </li></ul><ul><ul><li>只要抓住重點,不必每樣細節都考究 </li></ul></ul><ul><ul><li>A simplification or model of a complex concept, process, or real-world object </li></ul></ul><ul><ul><li>Help people understand something at an appropriate level </li></ul></ul><ul><ul><li>Different people would build different abstractions for the same concept </li></ul></ul><ul><ul><li>Highlight the characteristics and behavior of something that is too complex to understand in its entirety </li></ul></ul>
  10. 10. UML The Basics <ul><li>Encapsulation 封裝 </li></ul><ul><ul><li>凸顯重要特質隱藏內部細節 </li></ul></ul><ul><ul><li>Highlight the important aspects of an object </li></ul></ul><ul><ul><li>Hide the cumbersome internal details of the object </li></ul></ul><ul><ul><li>Make the system easier to understand and to reuse </li></ul></ul><ul><ul><li>Make a system more extendible </li></ul></ul>
  11. 11. UML The Basics <ul><li>Object </li></ul><ul><ul><li>A particular and finite element in a large model </li></ul></ul><ul><ul><ul><li>Visible or invisible </li></ul></ul></ul><ul><ul><ul><li>Persistent or transient </li></ul></ul></ul><ul><ul><li>State: describes characteristics and current condition </li></ul></ul><ul><ul><li>Behavior: defines the actions that other objects may perform on the object </li></ul></ul><ul><ul><li>Method: a service or responsibility that an object exposes to other objects </li></ul></ul><ul><ul><li>Each has a unique identifier </li></ul></ul><ul><ul><li>Limited responsibility and cooperation </li></ul></ul>
  12. 12. UML The Basics <ul><li>Class </li></ul><ul><ul><li>A group of objects that have something in common </li></ul></ul><ul><ul><li>Captures a particular abstraction </li></ul></ul><ul><ul><li>Provides a template for object creation </li></ul></ul><ul><ul><li>Each objects created from a class is identical in </li></ul></ul><ul><ul><ul><li>The type of data they can hold </li></ul></ul></ul><ul><ul><ul><li>The type and number of objects they know about </li></ul></ul></ul><ul><ul><ul><li>The logic for any behavior they provide </li></ul></ul></ul>
  13. 13. UML The Basics <ul><li>Relationships between objects </li></ul><ul><ul><li>Dependency </li></ul></ul><ul><ul><li>Association </li></ul></ul><ul><ul><li>Aggregation </li></ul></ul><ul><ul><li>Composition </li></ul></ul>
  14. 14. Dependency <ul><li>Short-term dependency </li></ul><ul><li>An object may create another object as part of a method, ask it to perform some function, and then forget about it </li></ul>
  15. 15. Association <ul><li>An object keeps a reference to another object and can call the object’s, methods as it needs them </li></ul><ul><li>An object may receive an object as a parameter to a configuration method and keep a reference to the object </li></ul>
  16. 16. Aggregation <ul><li>An object is part of a greater whole </li></ul><ul><li>The contained object may participate in more than one aggregation relationship, and exists independently of the whole </li></ul>
  17. 17. Composition <ul><li>An object is owned by a greater whole </li></ul><ul><li>The contained object may not participate in more than one composition relationship and cannot exist independently of the whole </li></ul>
  18. 18. UML The Basics <ul><li>Navigability </li></ul><ul><ul><li>The control relationship </li></ul></ul><ul><ul><li>The arrow indicates direction of control </li></ul></ul>
  19. 19. UML The Basics <ul><li>Multiplicity </li></ul><ul><ul><li>The number of relationships </li></ul></ul><ul><ul><li>No default multiplicity </li></ul></ul>
  20. 20. UML The Basics <ul><li>Interface </li></ul><ul><ul><li>Defines a set of related behavior </li></ul></ul><ul><ul><li>Does not specify the actual implementation for the behavior </li></ul></ul><ul><ul><ul><li>Specify the signature of one or more methods </li></ul></ul></ul><ul><ul><li>A class realizes an interface by implementing each method in the interface </li></ul></ul>
  21. 21. UML The Basics <ul><li>Polymorphism </li></ul><ul><ul><li>Multiple implementation of a single abstraction </li></ul></ul><ul><ul><ul><li>Abstraction are captured in classes and in interfaces </li></ul></ul></ul>
  22. 22. Polymorphism Through Realization
  23. 23. Polymorphism Through Inheritance
  24. 24. Modeling Software Systems with the UML <ul><li>UML enables building a single coherent model that describes a software system from several perspectives </li></ul><ul><ul><li>Internal consistency </li></ul></ul><ul><ul><li>Distinct views </li></ul></ul><ul><li>Participants can use the same model and speak the same language throughout the development process </li></ul>
  25. 25. The Customer’s Perspective <ul><li>Use case </li></ul><ul><ul><li>Defines and describes a discrete way in which users get value from the system </li></ul></ul><ul><li>Text description of each use case </li></ul><ul><ul><li>Including the details of the interactions between the user and the system </li></ul></ul><ul><li>Activity diagram </li></ul><ul><ul><li>Visual description of the interaction between the system and the user for a use case </li></ul></ul>
  26. 26. The Developer’s Perspective <ul><li>Class diagram </li></ul><ul><ul><li>Defines and constrains a group of objects in detail </li></ul></ul><ul><ul><li>Shows the state, behavior, and relationships </li></ul></ul><ul><li>State chart </li></ul><ul><ul><li>Describe the state-dependent behavior for a class </li></ul></ul><ul><ul><li>How an object responses to requests depending on its internal configuration </li></ul></ul><ul><li>Package diagram </li></ul><ul><ul><li>How different parts of a system depend on one another </li></ul></ul>
  27. 27. The Developer’s Perspective (cont’d) <ul><li>Sequence diagram </li></ul><ul><ul><li>How objects interact with one another to provide the functionality </li></ul></ul><ul><ul><li>Indicates the order of the interaction </li></ul></ul><ul><li>Collaboration diagram </li></ul><ul><ul><li>Revealing the relationship between objects </li></ul></ul>
  28. 28. Modeling Process <ul><li>The developers and customers use the UML to understand the problem from the customer’s point of view </li></ul><ul><li>The developers use UML to understand the problem from their own point of view </li></ul><ul><li>The UML model is used as a resource by the implementers of the system </li></ul>
  29. 29. Modeling Process (cont’d) <ul><li>Requirements gathering </li></ul><ul><li>Analysis </li></ul><ul><li>Technology selection </li></ul><ul><li>Architecture </li></ul><ul><li>Design and implementation </li></ul>
  30. 30. Requirements Gathering <ul><li>Understand the problem from the customer’s point of view </li></ul><ul><li>Do NOT concern for technology or system design </li></ul><ul><li>In this process, developers create </li></ul><ul><ul><li>Use case diagrams </li></ul></ul><ul><ul><li>Text use case descriptions </li></ul></ul><ul><ul><li>Activity diagrams </li></ul></ul>
  31. 31. Analysis <ul><li>Understand the problem from the developer’s point of view </li></ul><ul><li>Still do NOT concern for technology </li></ul><ul><li>Discover the roles and responsibilities that must be filled in the system </li></ul><ul><li>In this process, developers create </li></ul><ul><ul><li>Class diagrams </li></ul></ul><ul><ul><li>Sequence diagrams </li></ul></ul><ul><ul><li>Collaboration diagrams </li></ul></ul>
  32. 32. Technology Selection <ul><li>Categorize the system in terms of its technological requirements </li></ul><ul><li>Select the most appropriate technologies to fulfill these well-defined needs </li></ul><ul><li>Produce a high-level summary of the technological requirements and a list of appropriate technologies for the system </li></ul><ul><li>No additional UML diagrams are produced </li></ul>
  33. 33. Architecture <ul><li>Describe the system at high level </li></ul><ul><li>Decompose the system into smaller parts (subsystems) </li></ul><ul><li>Highlight relationships between parts </li></ul><ul><li>Hide details of each part </li></ul><ul><li>In this process, developers create </li></ul><ul><ul><li>Primary class diagrams </li></ul></ul><ul><ul><li>Package diagrams </li></ul></ul>
  34. 34. Design and Implementation <ul><li>Design </li></ul><ul><ul><li>Use all the results from the previous steps </li></ul></ul><ul><ul><li>Create a model of objects that interact to provide the system’s functionality </li></ul></ul><ul><ul><li>The last chance to validate the solution </li></ul></ul><ul><li>Implementation </li></ul><ul><ul><li>Write the code according to the design </li></ul></ul>

×