|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.
Established in 1998, Calsoft is a leading software product engineering Services Company specializing in Storage, Networking, Virtualization and Cloud business verticals. Calsoft provides End-to-End Product Development, Quality Assurance Sustenance, Solution Engineering and Professional Services expertise to assist customers in achieving their product development and business goals. The company's deep domain knowledge of Storage, Virtualization, Networking and Cloud verticals helps in delivering ...
Oct. 24, 2016 07:15 PM EDT Reads: 1,042
SYS-CON Events announced today that Cloudbric, a leading website security provider, will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Cloudbric is an elite full service website protection solution specifically designed for IT novices, entrepreneurs, and small and medium businesses. First launched in 2015, Cloudbric is based on the enterprise level Web Application Firewall by Penta Security Sys...
Oct. 24, 2016 07:15 PM EDT Reads: 1,150
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering Cloud Expo and @ThingsExpo will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at Cloud Expo. Product announcements during our show provide your company with the most reach through our targeted audiences.
Oct. 24, 2016 06:15 PM EDT Reads: 4,739
In the next five to ten years, millions, if not billions of things will become smarter. This smartness goes beyond connected things in our homes like the fridge, thermostat and fancy lighting, and into heavily regulated industries including aerospace, pharmaceutical/medical devices and energy. “Smartness” will embed itself within individual products that are part of our daily lives. We will engage with smart products - learning from them, informing them, and communicating with them. Smart produc...
Oct. 24, 2016 05:45 PM EDT Reads: 1,495
SYS-CON Events announced today that 910Telecom will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Housed in the classic Denver Gas & Electric Building, 910 15th St., 910Telecom is a carrier-neutral telecom hotel located in the heart of Denver. Adjacent to CenturyLink, AT&T, and Denver Main, 910Telecom offers connectivity to all major carriers, Internet service providers, Internet backbones and ...
Oct. 24, 2016 05:00 PM EDT Reads: 3,627
Extreme Computing is the ability to leverage highly performant infrastructure and software to accelerate Big Data, machine learning, HPC, and Enterprise applications. High IOPS Storage, low-latency networks, in-memory databases, GPUs and other parallel accelerators are being used to achieve faster results and help businesses make better decisions. In his session at 18th Cloud Expo, Michael O'Neill, Strategic Business Development at NVIDIA, focused on some of the unique ways extreme computing is...
Oct. 24, 2016 05:00 PM EDT Reads: 3,899
SYS-CON Events announced today that Coalfire will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Coalfire is the trusted leader in cybersecurity risk management and compliance services. Coalfire integrates advisory and technical assessments and recommendations to the corporate directors, executives, boards, and IT organizations for global brands and organizations in the technology, cloud, health...
Oct. 24, 2016 04:45 PM EDT Reads: 1,565
SYS-CON Events announced today that Transparent Cloud Computing (T-Cloud) Consortium will exhibit at the 19th International Cloud Expo®, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. The Transparent Cloud Computing Consortium (T-Cloud Consortium) will conduct research activities into changes in the computing model as a result of collaboration between "device" and "cloud" and the creation of new value and markets through organic data proces...
Oct. 24, 2016 04:30 PM EDT Reads: 1,365
In his session at 19th Cloud Expo, Claude Remillard, Principal Program Manager in Developer Division at Microsoft, will contrast how his team used config as code and immutable patterns for continuous delivery of microservices and apps to the cloud. He will show the immutable patterns helps developers do away with most of the complexity of config as code-enabling scenarios such as rollback, zero downtime upgrades with far greater simplicity. He will also have live demos of building immutable pipe...
Oct. 24, 2016 04:30 PM EDT Reads: 1,582
In his general session at 18th Cloud Expo, Lee Atchison, Principal Cloud Architect and Advocate at New Relic, discussed cloud as a ‘better data center’ and how it adds new capacity (faster) and improves application availability (redundancy). The cloud is a ‘Dynamic Tool for Dynamic Apps’ and resource allocation is an integral part of your application architecture, so use only the resources you need and allocate /de-allocate resources on the fly.
Oct. 24, 2016 04:00 PM EDT Reads: 3,723
As data explodes in quantity, importance and from new sources, the need for managing and protecting data residing across physical, virtual, and cloud environments grow with it. Managing data includes protecting it, indexing and classifying it for true, long-term management, compliance and E-Discovery. Commvault can ensure this with a single pane of glass solution – whether in a private cloud, a Service Provider delivered public cloud or a hybrid cloud environment – across the heterogeneous enter...
Oct. 24, 2016 03:45 PM EDT Reads: 1,402
Traditional on-premises data centers have long been the domain of modern data platforms like Apache Hadoop, meaning companies who build their business on public cloud were challenged to run Big Data processing and analytics at scale. But recent advancements in Hadoop performance, security, and most importantly cloud-native integrations, are giving organizations the ability to truly gain value from all their data. In his session at 19th Cloud Expo, David Tishgart, Director of Product Marketing ...
Oct. 24, 2016 03:45 PM EDT Reads: 2,557
We're entering the post-smartphone era, where wearable gadgets from watches and fitness bands to glasses and health aids will power the next technological revolution. With mass adoption of wearable devices comes a new data ecosystem that must be protected. Wearables open new pathways that facilitate the tracking, sharing and storing of consumers’ personal health, location and daily activity data. Consumers have some idea of the data these devices capture, but most don’t realize how revealing and...
Oct. 24, 2016 02:15 PM EDT Reads: 3,953
So you think you are a DevOps warrior, huh? Put your money (not really, it’s free) where your metrics are and prove it by taking The Ultimate DevOps Geek Quiz Challenge, sponsored by DevOps Summit. Battle through the set of tough questions created by industry thought leaders to earn your bragging rights and win some cool prizes.
Oct. 24, 2016 02:15 PM EDT Reads: 4,018
A completely new computing platform is on the horizon. They’re called Microservers by some, ARM Servers by others, and sometimes even ARM-based Servers. No matter what you call them, Microservers will have a huge impact on the data center and on server computing in general. Although few people are familiar with Microservers today, their impact will be felt very soon. This is a new category of computing platform that is available today and is predicted to have triple-digit growth rates for some ...
Oct. 24, 2016 02:00 PM EDT Reads: 34,155
Governments around the world are adopting Safe Harbor privacy provisions to protect customer data from leaving sovereign territories. Increasingly, global companies are required to create new instances of their server clusters in multiple countries to keep abreast of these new Safe Harbor laws. Is it worth it? In his session at 19th Cloud Expo, Adam Rogers, Managing Director of Anexia, Inc., will discuss how to keep your data legal and still stay in business.
Oct. 24, 2016 01:15 PM EDT Reads: 1,452
SYS-CON Events announced today that MathFreeOn will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. MathFreeOn is Software as a Service (SaaS) used in Engineering and Math education. Write scripts and solve math problems online. MathFreeOn provides online courses for beginners or amateurs who have difficulties in writing scripts. In accordance with various mathematical topics, there are more tha...
Oct. 24, 2016 01:00 PM EDT Reads: 1,012
In past @ThingsExpo presentations, Joseph di Paolantonio has explored how various Internet of Things (IoT) and data management and analytics (DMA) solution spaces will come together as sensor analytics ecosystems. This year, in his session at @ThingsExpo, Joseph di Paolantonio from DataArchon, will be adding the numerous Transportation areas, from autonomous vehicles to “Uber for containers.” While IoT data in any one area of Transportation will have a huge impact in that area, combining sensor...
Oct. 24, 2016 01:00 PM EDT Reads: 860
SYS-CON Events announced today that SoftNet Solutions will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. SoftNet Solutions specializes in Enterprise Solutions for Hadoop and Big Data. It offers customers the most open, robust, and value-conscious portfolio of solutions, services, and tools for the shortest route to success with Big Data. The unique differentiator is the ability to architect and ...
Oct. 24, 2016 01:00 PM EDT Reads: 899
Successful transition from traditional IT to cloud computing requires three key ingredients: an IT architecture that allows companies to extend their internal best practices to the cloud, a cost point that allows economies of scale, and automated processes that manage risk exposure and maintain regulatory compliance with industry regulations (FFIEC, PCI-DSS, HIPAA, FISMA). The unique combination of VMware, the IBM Cloud, and Cloud Raxak, a 2016 Gartner Cool Vendor in IT Automation, provides a co...
Oct. 24, 2016 12:30 PM EDT Reads: 1,229