|By Dan Clark||
|April 28, 2003 12:00 AM EDT||
The class diagram is an excellent aid to model the attributes, operations, and associations of the classes in your applications. This article, the second in a series of articles that introduce the reader to the concepts of object-oriented design and the Unified Modeling Language, focuses on UML class diagrams. It reviews UML class diagramming notation and the use of Visio to construct a class diagram.
The Need for Modeling Classes
Class structures are fundamental to any object-oriented programming language. The class structure is a template for the objects that will implement the functionality of your applications. As a .NET developer, you need to become increasingly familiar with the classes available in the .NET Framework. As you gain experience developing .NET applications you will discover the need to develop your own class libraries. Good design of object-oriented applications dictates a clear separation of functionality between the user interface, business logic, and data access logic. Well-designed applications achieve this separation of functionality through the development of class libraries that encapsulate internal processing. By developing class libraries, your applications become more manageable, scalable, and extendable.
An all-too-common problem in many object-oriented applications is a lack of preplanning. Class libraries evolve haphazardly. As a result, the distinction of roles and responsibilities among the various classes in the library becomes muddled and convoluted. These class libraries are difficult to manage, revise, and employ. This is especially problematic when large teams of developers build an application. Employing a tool to model your class libraries is imperative to ensure that the application remains consistent, manageable, and clearly defined. A UML class diagram is an excellent tool for modeling the structure of your class libraries.
Modeling Class Structure Using UML
In a UML class diagram, a rectangle divided into three parts represents the class. The top section contains the name of the class, the middle section contains the attributes of the class, and the lower section contains the operations performed by the class. Operations may take the form of methods, constructors, destructors, properties, or events. Figure 1 illustrates a UML class diagram representing a loan class. This class is part of a library loan application that tracks loan, member, and inventory information for a small library.
Examining the class diagram reveals that along with the name of the attribute, it defines the attribute's accessibility. A minus sign (-) in front of the attribute name indicates it is private. A plus sign (+) indicates it is public, and a pound sign (#) indicates it is protected. A private element is only accessible from within the class. A public element is accessible from any code in the same project or any project with a reference to the project containing the class. A protected element is accessible from within the class and any class derived from the class.
Although the UML specifications do not define specific data types, when developing classes for use in .NET assemblies you can strongly type the attributes using the supported types of your implementation language. Visio allows the choice of either VB, C#, C++, or IDL supported data types. Data types can also be complex data types defined by your class library or the .NET class library. For example, a catalog class may have an item attribute that is of type System.Data.DataRow. Another possible scenario would be to create a catalog class as a collection class whose item attribute is an Item class type.
The lower section of the UML class shape defines the operations of the class. Typically, the class diagram will define the name of the operation, its accessibility, any parameters passed in to the operation, and any return value passed back when the operation executes. The loan class represented in Figure 1 contains two constructors (Sub New), a function (CalculateDueDate), an event procedure (OverDueNotice), and a property (LoanID). Unfortunately, the UML specifications do not define a way to identify the various operation types in the diagram. You can, however, add your own notation to indicate the various types depending on the modeling tool you use. Figure 2 shows the loan class shape with custom stereotypes added to identify the various operations defined in the diagram.
Modeling Class Associations
When a class refers to or uses another class, the classes form an association. For example, in the library loan application we have identified the need to construct a Loan class and a Book class. The responsibility of the Loan class is to maintain information about a book out on loan. This includes the member who has the book, the book, and the due date. The responsibility of the Book class is to maintain relevant information about the book. This includes ISBN, title, author, and publisher. Since the Loan class maintains a reference to the Book class, the book class is a collaborator of the Loan class. A line connecting the two classes represents this association in the class diagram. The association line often includes a label to describe the association.
Association lines can also indicate the direction of the association. In the previous case, the Loan class maintains a reference to the Book class, but the book class does not maintain a reference to the Loan class. To depict a one-way association, you add an arrow to the association line. The class diagram shown in Figure 3 documents the association between the loan class and the book class.
Sometimes a single instance of one class associates with multiple instances of another class. For example, a member may have multiple books out on loan. In this case, a single instance of a member class is associated with multiple instances of the Loan class. Multiplicity is included in the class diagram by placing the appropriate symbol on the association line. The class diagram in Figure 4 indicates that an instance of the Member class may be associated with multiple instances of the Loan class.
Using Visio to Construct a Class Diagram
Now that you're familiar with some of the notations used to construct a class diagram, you are ready to investigate the use of Visio to create class diagrams. If you do not have Visio installed, you can still benefit from following along and completing the diagram with paper and pencil.
1. Start up Visio. From the File menu choose New -> Software -> UML Model Diagram.
2. Locate the Shapes window along the left side of the screen. This window includes a tab for the common UML diagrams. Select the UML Static Structure tab (see Figure 5).
3. From the Shapes window click and drag the Class shape onto the design surface. Right-click the Class shape on the design surface and choose Properties. A UML Class Properties window becomes visible (see Figure 6). Change the name to "Book" and add the description "Responsible for maintaining book information" in the Documentation text box.
4. Select Attributes on the Categories list box in the left side of the window. Click on the New button on the right side of the window to add a new attribute to the class. Click on the Properties button to display the UML Attribute Properties window. Change the name of the attribute to "mISBN". Change the type to "VB::Char" and verify that the visibility is "private". Click the OK button to return to the UML Class Properties window.
5. Select Operations in the Categories list box on the left side of the window. Click on the New button on the right side of the window to add a new operation to the class. Click on the Properties button to display the UML Operation Properties window. Change the name of the operation to "ISBN". Change the return type to "VB::Char" and verify that the visibility is "public". Select "Code Generation Options" in the Categories list box on the left side of the window. Change the operation kind to "Property" and check the "Create Get Method" and "Create Set Method" check boxes to indicate it is a readable/writable property. Click the OK button to return to the UML Class Properties window.
6. Select Operations in the Categories list box on the left side of the window. Click on the New button on the left side of the window to add a new operation to the class. Click on the Properties button to display the UML Operation Properties window. Change the name of the operation to "CheckAvailability". Change the return type to "VB::Boolean" and verify that the visibility is "public". Select "Parameters" in the Categories list box on the left side of the window. Click on the New button on the right side of the window to add a new parameter to the operation. Click on the Properties button to display the UML Parameter Properties window. Change the name of the parameter to "ReservationDate" and the type to "VB::Date". Click the OK button to return to the UML Operation Properties window. Click the OK button to return to the UML Class Properties window. Click OK to close the UML Class Properties window. The Book class diagram should look similar to the one shown in Figure 7.
7. In order to demonstrate the creation of class associations, add a Member class and a Loan class to the class diagram. If you want some practice, add some attributes and operations to these classes.
8. From the Shapes window, click and drag the Binary Association shape onto the design surface. Attach end 1 of the Binary Association to the Member class and end 2 to the Loan class. The Binary Association line will turn red if it is not attached properly. Right-click the Binary Association shape on the design surface and choose Properties. The UML Association Properties window will display. Change the name of the association to "Takes Out". Change the Name Reading Direction to "forward". Change End 1's multiplicity to 1 and check the IsNavigable check box. When you are finished, click OK to close the window.
9. Right-click the "Takes Out" Binary Association shape on the design surface and choose Shape Display Options. The UML Shape Display Options window displays. Under the General section, click the Name check box. Under the Suppress section, click on the First end and Second end check boxes. When finished, click OK.
10. Figure 8 shows the completed diagram, including an association between the Loan class and the Book class. For additional practice, add this association to your diagram.
This article has introduced you to using the Unified Modeling Language to model the class structure of your application. The class diagram is a great aid for modeling the attributes and operations of the classes that make up your application. The class diagram also shows how the various classes in your application associate with each other. A CASE tool such as Visio, although not necessary, is beneficial in the creation of the class diagram.
A future article will continue the study of UML and class associations, focusing on modeling class inheritance hierarchies. In addition, you will be introduced to modeling interfaces, meta classes, and utility classes, which are all commonly used in class library applications. Finally, you will experience using Visio to generate a Visual Studio .NET class library from the UML model.
Nowadays, a large number of sensors and devices are connected to the network. Leading-edge IoT technologies integrate various types of sensor data to create a new value for several business decision scenarios. The transparent cloud is a model of a new IoT emergence service platform. Many service providers store and access various types of sensor data in order to create and find out new business values by integrating such data.
Oct. 10, 2015 04:00 AM EDT Reads: 583
The cloud has reached mainstream IT. Those 18.7 million data centers out there (server closets to corporate data centers to colocation deployments) are moving to the cloud. In his session at 17th Cloud Expo, Achim Weiss, CEO & co-founder of ProfitBricks, will share how two companies – one in the U.S. and one in Germany – are achieving their goals with cloud infrastructure. More than a case study, he will share the details of how they prioritized their cloud computing infrastructure deployments ...
Oct. 10, 2015 03:00 AM EDT Reads: 753
There are so many tools and techniques for data analytics that even for a data scientist the choices, possible systems, and even the types of data can be daunting. In his session at @ThingsExpo, Chris Harrold, Global CTO for Big Data Solutions for EMC Corporation, will show how to perform a simple, but meaningful analysis of social sentiment data using freely available tools that take only minutes to download and install. Participants will get the download information, scripts, and complete en...
Oct. 10, 2015 03:00 AM EDT Reads: 327
Data loss happens, even in the cloud. In fact, if your company has adopted a cloud application in the past three years, data loss has probably happened, whether you know it or not. In his session at 17th Cloud Expo, Bryan Forrester, Senior Vice President of Sales at eFolder, will present how common and costly cloud application data loss is and what measures you can take to protect your organization from data loss.
Oct. 10, 2015 03:00 AM EDT Reads: 591
SYS-CON Events announced today that Dyn, the worldwide leader in Internet Performance, will exhibit at SYS-CON's 17th International Cloud Expo®, which will take place on November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Dyn is a cloud-based Internet Performance company. Dyn helps companies monitor, control, and optimize online infrastructure for an exceptional end-user experience. Through a world-class network and unrivaled, objective intelligence into Internet condit...
Oct. 10, 2015 02:00 AM EDT Reads: 654
Between the compelling mockups and specs produced by analysts, and resulting applications built by developers, there exists a gulf where projects fail, costs spiral, and applications disappoint. Methodologies like Agile attempt to address this with intensified communication, with partial success but many limitations. In his session at DevOps Summit, Charles Kendrick, CTO and Chief Architect at Isomorphic Software, will present a revolutionary model enabled by new technologies. Learn how busine...
Oct. 10, 2015 02:00 AM EDT Reads: 312
Interested in leveraging automation technologies and a cloud architecture to make developers more productive? Learn how PaaS can benefit your organization to help you streamline your application development, allow you to use existing infrastructure and improve operational efficiencies. Begin charting your path to PaaS with OpenShift Enterprise.
Oct. 10, 2015 02:00 AM EDT Reads: 579
Achim Weiss is Chief Executive Officer and co-founder of ProfitBricks. In 1995, he broke off his studies to co-found the web hosting company "Schlund+Partner." The company "Schlund+Partner" later became the 1&1 web hosting product line. From 1995 to 2008, he was the technical director for several important projects: the largest web hosting platform in the world, the second largest DSL platform, a video on-demand delivery network, the largest eMail backend in Europe, and a universal billing syste...
Oct. 10, 2015 01:00 AM EDT Reads: 247
Containers have changed the mind of IT in DevOps. They enable developers to work with dev, test, stage and production environments identically. Containers provide the right abstraction for microservices and many cloud platforms have integrated them into deployment pipelines. DevOps and Containers together help companies to achieve their business goals faster and more effectively.
Oct. 10, 2015 12:00 AM EDT Reads: 222
Containers are revolutionizing the way we deploy and maintain our infrastructures, but monitoring and troubleshooting in a containerized environment can still be painful and impractical. Understanding even basic resource usage is difficult - let alone tracking network connections or malicious activity. In his session at DevOps Summit, Gianluca Borello, Sr. Software Engineer at Sysdig, will cover the current state of the art for container monitoring and visibility, including pros / cons and li...
Oct. 10, 2015 12:00 AM EDT Reads: 268
As a CIO, are your direct reports IT managers or are they IT leaders? The hard truth is that many IT managers have risen through the ranks based on their technical skills, not their leadership ability. Many are unable to effectively engage and inspire, creating forward momentum in the direction of desired change. Renowned for its approach to leadership and emphasis on their people, organizations increasingly look to our military for insight into these challenges.
Oct. 9, 2015 11:15 PM EDT Reads: 212
Today air travel is a minefield of delays, hassles and customer disappointment. Airlines struggle to revitalize the experience. GE and M2Mi will demonstrate practical examples of how IoT solutions are helping airlines bring back personalization, reduce trip time and improve reliability. In their session at @ThingsExpo, Shyam Varan Nath, Principal Architect with GE, and Dr. Sarah Cooper, M2Mi's VP Business Development and Engineering, will explore the IoT cloud-based platform technologies driv...
Oct. 9, 2015 10:15 PM EDT Reads: 150
There are many considerations when moving applications from on-premise to cloud. It is critical to understand the benefits and also challenges of this migration. A successful migration will result in lower Total Cost of Ownership, yet offer the same or higher level of robustness. Migration to cloud shifts computing resources from your data center, which can yield significant advantages provided that the cloud vendor an offer enterprise-grade quality for your application.
Oct. 9, 2015 09:30 PM EDT Reads: 318
The web app is agile. The REST API is agile. The testing and planning are agile. But alas, data infrastructures certainly are not. Once an application matures, changing the shape or indexing scheme of data often forces at best a top down planning exercise and at worst includes schema changes that force downtime. The time has come for a new approach that fundamentally advances the agility of distributed data infrastructures. Come learn about a new solution to the problems faced by software organ...
Oct. 9, 2015 08:00 PM EDT Reads: 941
The buzz continues for cloud, data analytics and the Internet of Things (IoT) and their collective impact across all industries. But a new conversation is emerging - how do companies use industry disruption and technology enablers to lead in markets undergoing change, uncertainty and ambiguity? Organizations of all sizes need to evolve and transform, often under massive pressure, as industry lines blur and merge and traditional business models are assaulted and turned upside down. In this new da...
Oct. 9, 2015 08:00 PM EDT Reads: 320
Secure Cloud through Automated Compliance | @CloudExpo @CloudRaxak #Cloud #BigData #DevOps #Microservices
Cloud computing delivers on-demand resources that provide businesses with flexibility and cost-savings. The challenge in moving workloads to the cloud has been the cost and complexity of ensuring the initial and ongoing security and regulatory (PCI, HIPAA, FFIEC) compliance across private and public clouds. Manual security compliance is slow, prone to human error, and represents over 50% of the cost of managing cloud applications. Determining how to automate cloud security compliance is critical...
Oct. 9, 2015 06:00 PM EDT Reads: 329
The Internet of Everything is re-shaping technology trends–moving away from “request/response” architecture to an “always-on” Streaming Web where data is in constant motion and secure, reliable communication is an absolute necessity. As more and more THINGS go online, the challenges that developers will need to address will only increase exponentially. In his session at @ThingsExpo, Todd Greene, Founder & CEO of PubNub, will explore the current state of IoT connectivity and review key trends an...
Oct. 9, 2015 05:30 PM EDT Reads: 126
The Internet of Things (IoT) is growing rapidly by extending current technologies, products and networks. By 2020, Cisco estimates there will be 50 billion connected devices. Gartner has forecast revenues of over $300 billion, just to IoT suppliers. Now is the time to figure out how you’ll make money – not just create innovative products. With hundreds of new products and companies jumping into the IoT fray every month, there’s no shortage of innovation. Despite this, McKinsey/VisionMobile data...
Oct. 9, 2015 04:00 PM EDT Reads: 253
You have your devices and your data, but what about the rest of your Internet of Things story? Two popular classes of technologies that nicely handle the Big Data analytics for Internet of Things are Apache Hadoop and NoSQL. Hadoop is designed for parallelizing analytical work across many servers and is ideal for the massive data volumes you create with IoT devices. NoSQL databases such as Apache HBase are ideal for storing and retrieving IoT data as “time series data.”
Oct. 9, 2015 03:45 PM EDT Reads: 511
In recent years, at least 40% of companies using cloud applications have experienced data loss. One of the best prevention against cloud data loss is backing up your cloud data. In his General Session at 17th Cloud Expo, Bryan Forrester, Senior Vice President of Sales at eFolder, will present how organizations can use eFolder Cloudfinder to automate backups of cloud application data. He will also demonstrate how easy it is to search and restore cloud application data using Cloudfinder.
Oct. 9, 2015 03:00 PM EDT Reads: 505