What are the similarities and differences between a UML Class Diagram and Object Diagram?

What are the similarities and differences between a UML Class Diagram and Object Diagram?


What are the similarities and differences between a UML Class Diagram and Object Diagram?

ANSWER

Class Diagrams and Object Diagrams use almost identical notations. Both represent a static view of a system, however Object Diagrams represent a snapshot in time, whereas Class Diagrams are not time dependent and are an abstract view of the types of objects that may exist within a system, the relationships between them, and how and when one type of object can exist in relationship to another. Since Object Diagrams represent specific object instances that exist at a single point in time, they are sometimes called Instance Diagrams.

A few notable differences in the notation and rules used to represent Class and Object Diagrams are:

  • Class Diagrams represent each class via a rectangle and display up to 3 types of information; the class name (not underlined), its attributes, and its operations. The Object Diagram also uses a rectangle to represent an object instance, however the object name is underlined and lists the name of the object followed by a colon and then the class name which describes its type (e.g. Joe: Student, where Joe is the name of the object instance and Student is class).  Additionally the Object Diagram will list an object's attributes, but it will also list the value of that attribute at that point in time (e.g. SSN = 555-55-5555).
  • Class Diagrams enforce multiplicity rules between associated classes.  For example, a Class Diagram may display an association between a Car and Passengers. The Class Diagram would show a single rectangle to represent the class car and a single rectangle to represent the class passenger, but display multiplicities stating that each car may have 1..4 passengers. An Object Diagram being a snapshot in time would show a rectangle for the Car and up to 4 separate rectangles, one for each passenger that exists at that movement in time.
  • Many of the constraints or association types that exist in a class diagram have no relevance in an object diagram. Multiplicities in a class diagram may constrain the number of passengers in a car to 4, but this rule would be enforced within the code itself such that a 5th passenger object could never be created. Therefore, multiplicities are not shown within an object diagram. Only the actual numbers of objects that exist at that moment in time are shown. Similarly, other constraints such as "at least one passenger be of type driver" could also be captured and displayed in a class diagram but would not be shown in an object diagram since these rules are enforced within the actual code.

要查看或添加评论,请登录

r R.的更多文章

  • Regulated Domains

    Regulated Domains

    Regulated domains Agile software development methods were initially seen as best suitable for non-critical product…

  • What Is Managed IT Services?

    What Is Managed IT Services?

    Introduction Managed IT services allow businesses to delegate their IT operations to an expert third-party organization…

    1 条评论
  • IT Consulting

    IT Consulting

    IT Consulting Define, design and execute IT strategies that drive business growth Disruptive technologies like the…

  • 12 Best Software Development Methodologies

    12 Best Software Development Methodologies

    https://acodez.in/12-best-software-development-methodologies-pros-cons/

  • The Top 36 SaaS Companies & Products to Watch in 2020

    The Top 36 SaaS Companies & Products to Watch in 2020

    The Top 36 SaaS Companies & Products to Watch in 2020 It's undeniable that software as a service (or SaaS) is growing…

  • The waning days of Indian IT workers being paid to do nothing Bench or Workforce Rescource Management

    The waning days of Indian IT workers being paid to do nothing Bench or Workforce Rescource Management

    The waning days of Indian IT workers being paid to do nothing Preparing for a labor force that doesn't yet exist. The…

  • Complete List of Business Verticals, Industries & Sectors

    Complete List of Business Verticals, Industries & Sectors

    Complete List of Business Verticals, Industries & Sectors Aerospace (aircraft manufacturing) Agriculture Livestock…

  • USA Recruitment

    USA Recruitment

    When it comes to specific domain and country, few extra responsibilities and skills get added. Responsibilities:…

  • What is a Bench Sales Recruiter?

    What is a Bench Sales Recruiter?

    What is a USA Bench Sales Recruiter? A 'Bench Marketer' or 'Bench Sales Recruiter' is a Sales, Account or Recruiting…

    3 条评论
  • Why Is the Hierarchy of Authority Important in an Organization?

    Why Is the Hierarchy of Authority Important in an Organization?

    Why Is the Hierarchy of Authority Important in an Organization? Small Business Business Models & Organizational…

社区洞察

其他会员也浏览了