|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.
You think you know what’s in your data. But do you? Most organizations are now aware of the business intelligence represented by their data. Data science stands to take this to a level you never thought of – literally. The techniques of data science, when used with the capabilities of Big Data technologies, can make connections you had not yet imagined, helping you discover new insights and ask new questions of your data. In his session at @ThingsExpo, Sarbjit Sarkaria, data science team lead ...
Apr. 29, 2016 09:15 PM EDT Reads: 292
The IoT has the potential to create a renaissance of manufacturing in the US and elsewhere. In his session at 18th Cloud Expo, Florent Solt, CTO and chief architect of Netvibes, will discuss how the expected exponential increase in the amount of data that will be processed, transported, stored, and accessed means there will be a huge demand for smart technologies to deliver it. Florent Solt is the CTO and chief architect of Netvibes. Prior to joining Netvibes in 2007, he co-founded Rift Technol...
Apr. 29, 2016 09:00 PM EDT Reads: 1,532
If there is anything we have learned by now, is that every business paves their own unique path for releasing software- every pipeline, implementation and practices are a bit different, and DevOps comes in all shapes and sizes. Software delivery practices are often comprised of set of several complementing (or even competing) methodologies – such as leveraging Agile, DevOps and even a mix of ITIL, to create the combination that’s most suitable for your organization and that maximize your busines...
Apr. 29, 2016 08:30 PM EDT Reads: 1,744
Struggling to keep up with increasing application demand? Learn how Platform as a Service (PaaS) can streamline application development processes and make resource management easy.
Apr. 29, 2016 07:45 PM EDT Reads: 2,011
New Relic, Inc. has announced a set of new features across the New Relic Software Analytics Cloud that offer IT operations teams increased visibility, and the ability to diagnose and resolve performance problems quickly. The new features further IT operations teams’ ability to leverage data and analytics, as well as drive collaboration and a common, shared understanding between teams. Software teams are under pressure to resolve performance issues quickly and improve availability, as the comple...
Apr. 29, 2016 07:30 PM EDT Reads: 2,401
The proper isolation of resources is essential for multi-tenant environments. The traditional approach to isolate resources is, however, rather heavyweight. In his session at 18th Cloud Expo, Igor Drobiazko, co-founder of elastic.io, will draw upon their own experience with operating a Docker container-based infrastructure on a large scale and present a lightweight solution for resource isolation using microservices. He will also discuss the implementation of microservices in data and applicat...
Apr. 29, 2016 05:15 PM EDT Reads: 1,693
Join IBM June 8 at 18th Cloud Expo at the Javits Center in New York City, NY, and learn how to innovate like a startup and scale for the enterprise. You need to deliver quality applications faster and cheaper, attract and retain customers with an engaging experience across devices, and seamlessly integrate your enterprise systems. And you can't take 12 months to do it.
Apr. 29, 2016 04:30 PM EDT Reads: 1,775
See storage differently! Storage performance problems have only gotten worse and harder to solve as applications have become largely virtualized and moved to a cloud-based infrastructure. Storage performance in a virtualized environment is not just about IOPS, it is about how well that potential performance is guaranteed to individual VMs for these apps as the number of VMs keep going up real time. In his session at 18th Cloud Expo, Dhiraj Sehgal, in product and marketing at Tintri, will discu...
Apr. 29, 2016 04:30 PM EDT Reads: 633
Machine Learning helps make complex systems more efficient. By applying advanced Machine Learning techniques such as Cognitive Fingerprinting, wind project operators can utilize these tools to learn from collected data, detect regular patterns, and optimize their own operations. In his session at 18th Cloud Expo, Stuart Gillen, Director of Business Development at SparkCognition, will discuss how research has demonstrated the value of Machine Learning in delivering next generation analytics to im...
Apr. 29, 2016 03:45 PM EDT Reads: 1,605
This is not a small hotel event. It is also not a big vendor party where politicians and entertainers are more important than real content. This is Cloud Expo, the world's longest-running conference and exhibition focused on Cloud Computing and all that it entails. If you want serious presentations and valuable insight about Cloud Computing for three straight days, then register now for Cloud Expo.
Apr. 29, 2016 03:30 PM EDT Reads: 1,666
As you respond to increasing requests for new analytics, you need fast and flexible technology in your arsenal so that you can deploy the right workload to the right platform for the need at hand. Do you need self-service and fast time to value? Do you have data and application control and privacy needs, along with strict SLAs to meet? IBM dashDB™ is data warehouse technology powered by in-memory computing and in-database analytics that are designed for fast results, scalability and more.
Apr. 29, 2016 03:15 PM EDT Reads: 1,546
SYS-CON Events announced today that SoftLayer, an IBM Company, has been named “Gold Sponsor” of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2016, at the Javits Center in New York, New York. SoftLayer, an IBM Company, provides cloud infrastructure as a service from a growing number of data centers and network points of presence around the world. SoftLayer’s customers range from Web startups to global enterprises.
Apr. 29, 2016 03:00 PM EDT Reads: 854
So, you bought into the current machine learning craze and went on to collect millions/billions of records from this promising new data source. Now, what do you do with them? Too often, the abundance of data quickly turns into an abundance of problems. How do you extract that "magic essence" from your data without falling into the common pitfalls? In her session at @ThingsExpo, Natalia Ponomareva, Software Engineer at Google, will provide tips on how to be successful in large scale machine lear...
Apr. 29, 2016 02:45 PM EDT Reads: 864
Up until last year, enterprises that were looking into cloud services usually undertook a long-term pilot with one of the large cloud providers, running test and dev workloads in the cloud. With cloud’s transition to mainstream adoption in 2015, and with enterprises migrating more and more workloads into the cloud and in between public and private environments, the single-provider approach must be revisited. In his session at 18th Cloud Expo, Yoav Mor, multi-cloud solution evangelist at Cloudy...
Apr. 29, 2016 02:30 PM EDT Reads: 1,406
The paradigm has shifted. A Gartner survey shows that 43% of organizations are using or plan to implement the Internet of Things in 2016. However, not just a handful of companies are still using the old-style ad-hoc trial-and-error ways, unaware of the critical barriers, paint points, traps, and hidden roadblocks. How can you become a winner? In his session at @ThingsExpo, Tony Shan will present a methodical approach to guide the holistic adoption and enablement of IoT implementations. This ov...
Apr. 29, 2016 02:00 PM EDT Reads: 1,545
In his session at 18th Cloud Expo, Sagi Brody, Chief Technology Officer at Webair Internet Development Inc., will focus on real world deployments of DDoS mitigation strategies in every layer of the network. He will give an overview of methods to prevent these attacks and best practices on how to provide protection in complex cloud platforms. He will also outline what we have found in our experience managing and running thousands of Linux and Unix managed service platforms and what specifically c...
Apr. 29, 2016 01:45 PM EDT Reads: 1,077
SYS-CON Events announced today that Peak 10, Inc., a national IT infrastructure and cloud services provider, will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. Peak 10 provides reliable, tailored data center and network services, cloud and managed services. Its solutions are designed to scale and adapt to customers’ changing business needs, enabling them to lower costs, improve performance and focus inter...
Apr. 29, 2016 01:30 PM EDT Reads: 823
Artificial Intelligence has the potential to massively disrupt IoT. In his session at 18th Cloud Expo, AJ Abdallat, CEO of Beyond AI, will discuss what the five main drivers are in Artificial Intelligence that could shape the future of the Internet of Things. AJ Abdallat is CEO of Beyond AI. He has over 20 years of management experience in the fields of artificial intelligence, sensors, instruments, devices and software for telecommunications, life sciences, environmental monitoring, process...
Apr. 29, 2016 01:30 PM EDT Reads: 791
SYS-CON Events announced today that Stratoscale, the software company developing the next generation data center operating system, will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. Stratoscale is revolutionizing the data center with a zero-to-cloud-in-minutes solution. With Stratoscale’s hardware-agnostic, Software Defined Data Center (SDDC) solution to store everything, run anything and scale everywhere...
Apr. 29, 2016 01:00 PM EDT Reads: 1,490
SYS-CON Events announced today that Ericsson has been named “Gold Sponsor” of SYS-CON's @ThingsExpo, which will take place on June 7-9, 2016, at the Javits Center in New York, New York. Ericsson is a world leader in the rapidly changing environment of communications technology – providing equipment, software and services to enable transformation through mobility. Some 40 percent of global mobile traffic runs through networks we have supplied. More than 1 billion subscribers around the world re...
Apr. 29, 2016 01:00 PM EDT Reads: 770