What Is a Model?
A miniature representation of an object.
A pattern on which something not yet produced will be based.
A design or type.
One serving as an example to be emulated or imitated.
To construct a plan, esp. after a pattern. [WEBS1]
You are surrounded by models every day. As you get ready for work in the morning, you turn on your television. The morning news presents the local weather map showing how rain will be moving in this weekend. You reach for your vitamins. The cap is imprinted with a diagram showing how to remove the child-proof (or should we say adult-proof) cap.
You complete your morning ritual and jump into your automobile for the always-pleasant commute to the office. You stop to pick up some breakfast. You notice that behind the counter is a laminated poster containing a series of pictures (no words) showing the fast-food staff how to assemble your breakfast sandwich. Then, back on the road you go.
Half way to the office, you hear a traffic report of an accident ahead, so you pull off the road and consult your road atlas for an alternate route. You stay alert for the overhead highway signs with the large arrows indicating the lanes of traffic and which lane turns into the alternate exit you are searching for. You arrive at the office. As you stroll through the lobby, you see the glass-enclosed 3D replica of the new corporate headquarters that is under construction. You make it to your cubicle just in time to attend a morning meeting where a benefits person is showing bar charts of how much your money can earn if you invest it in the company retirement plan.
The weather map (a model or representation of the weather), the child-proof cap (a process model of how to remove the cap), the laminated sandwich instructions (another process model), the road atlas (an abstracted model of the road), the highway sign (a directional model of the highway), the corporate headquarters replica (a physical model of the building and surrounding terrain), and the bar chart (an analytical model) all model various aspects of your world.
A model, in the sense that we will discuss in this book, is a visual way of depicting your business, its rules, the use of your systems, applications, and system architectures, and interactions within your systems. You might have seen this described as "visual modeling," a term made popular by many computer-aided software engineering (CASE) vendors over the past couple of decades. Because models don't necessarily have to be visual (they can be textual or mathematical, for example, as we saw earlier), visual modeling has come to describe exactly what it implies: models that are visual in nature, using specific graphical representations.
In the remainder of this chapter, you will learn about the value of modeling, specifically when designing software and applications. First, you will learn why models should be built and then who should be building those models. We also introduce the different types of UML models that you can build.
Why Should I Build Models?
One of the most frequent objections to the UML we have heard isn't about the UML itself; it's that some people believe that there is no value in modeling. One theme you will pick up throughout this book is that modeling for modeling's sake is of little value, but when you do it for the right reasons, modeling is quite valuable. Modeling helps you to communicate designs, quickly clarify complex problems and scenarios, and ensure that your designs come closer to reality prior to implementation. This can save you and your organization a lot of time and money, and it enables teams of people (be they teams of 2 or 2,000) to work together more effectively and ensure that they are working toward the same common goals.
Think of it this way. Would you build a house without a plan? You might not build a small-scale version of the house first, but you (or your architect and builder) certainly would have design sketches, architecture drawings, and engineering assessments in hand prior to starting construction.
From the Real WorldHouses Are Similar to Software
Before embarking on my software development career, I spent several years building houses. During that time, I learned that when you use a good model (design), the house will stand through time and different weather conditions and will be amicable to changes that might be needed later, such as adding a window. If you don't use a good model but instead use a design you have in your mind, there is a good chance your final product won't be what you intended.
Designing software brings similar challenges. You need to ensure that the designs and plans are eventually realized and realized correctly so that they last architecturally through time, and you must also ensure that if you do need to make changes, they too can endure over time. Also, you need to understand what changes will break your design. When you add a window to a house, for instance, you need to know where the pipes and wires are and what types of support exist to handle the load. Likewise, when you add a component to a system, you need to make sure the system won't come crashing down as a result.
Design so that you can accommodate unplanned changes.
Create a well-documented design so that others who are new to the design can still work with it.
Have a visual model of an architecture to help you determine implications of change.
Do not model for modeling's sake. Make your models actionable so that users understand why you created the models and what you expect should result from them in the future.
Also, be warned! Watch out for "analysis paralysis." This occurs when you spend too much time analyzing a problem and don't get to the point where you are being productive.
When you focus on making your analysis or modeling actionable, you set a plan as to what you want to achieve from your analysis. You also adopt a mindset to approach modeling without rushing, making it of value, and then moving on to the next thingbe it another model, a change to the business or business process, or something else such as writing code.
Another reason you should model is simply to understand your business and its processes. You model your business processes not only to understand what the business does and how it functions but also so that you can identify how changes will affect the business. Modeling the business helps you to identify strengths and weaknesses, identify areas that need to be changed or optimized, and in some cases, simulate different business process options.
Why Should I Model with the UML?
When we explain why people should model with the UML, we like to draw a parallel to the field of electrical engineering. Electrical engineers draw a schematic for an electrical device in a standard way (see Figure 1-2), using a common visualization so that no matter where you are in the world, the schematic is always interpreted in the same way. Anyone who is trained in reading such a diagram can easily understand the circuit design and how the device will function. Even those who might not be experts but who understand the symbols can still understand what part belongs where and how they are connected.
Figure 1-2 An electrical schematic.
Other walks of life have similar languages or notations that are specific to their disciplines. The field of music, for instance, has a standard notation (see Figure 1-3). This was a critical development in the musical field. Before this notation was developed, the only way a composer could correctly and consistently teach musicians how to play his music was in person (a conundrum that closely parallels the software industry before the development of the UML).
Figure 1-3 Musical notation.
Similarly, mathematics has its own specific notation (see Figure 1-4). In fact, the language of mathematics is often cited as the one common language that all advanced civilizations understand.
Figure 1-4 Mathematical notation.
The same is true for the UML. It provides a common "language" to bring together business analysts, software developers, architects, testers, database designers, and the many other professionals who are involved in software design and development so that they can understand the business, its requirements, and how the software and architectures will be created. Although a cellist might not understand how to play the trumpet, she will understand what notes a trumpeter plays and when because she understands musical notation. Similarly, a business analyst who knows the UML can understand what a programmer is creating using the UML because the UML is a common language. With the ongoing need to think globally when building software, the ability provided by the UML to communicate globally becomes very important.
From the Real WorldNot Lost in Translation
We were recently working with a large financial institution. They began to outsource much of their software development for a specific project. In an effort to keep costs low, they chose a well-respected international systems integrator to run the job, but they also wanted to maintain control of the system that was being built, so they kept their own architects on the project. Because the company developed the system in this way, rather than doing everything themselves, senior management had the comfort of knowing that the project would fulfill the specified requirements while staying within budget and time constraints
The financial institution had the people who understood their business. They had the domain expertise and the contacts within the business to gather and verify the requirements as needed. Their initial concerns centered on the ability to transfer information between the different organizations and across international borders. That information had to be well understood and couldn't be allowed to slow down the process. Understanding this prior to the request for proposal, the financial institution included that the contractor must use a UML-based modeling tool and follow specific quality processes as part of their contract. They found quickly that having a common language to interpret requirements and architectures enabled them to understand each other without having to translate designs and desires.
Having a common way to understand what needs to be built helped this team of different organizations, languages, and countries communicate effectively to successfully deliver an application that was on time and, more importantly, that met the requirements of their end users.
What Can I Model with the UML?
The UML enables you to model many different facets of your business, from the actual business and its processes to IT functions such as database design, application architectures, hardware designs, and much more. Designing software and systems is a complicated task requiring the coordinated efforts of different groups performing various functions: capturing the needs of the business and systems, bringing software components together, constructing databases, assembling hardware to support the systems, and so on.
You can use the different types of UML diagrams (summarized later in this chapter) to create various types of models. Figure 1-5 lists these models and their usage. The models are composed of different diagram types, model elements, and linkages between model elements that enable you to trace between them so that you can understand how they relate. Different people in the organization use these models to describe different information. As we continue throughout this book, we will elaborate on these models, their use, and the roles of the people who will be using these models.
Figure 1-5 Model types and usage.
Who Should Build Models?
Not everyone should be involved in building models, but that doesn't mean everyone can't take advantage of the models that are built. In software design and development, you should start with models that help you understand the business and end with models designed to test your applications (and repeat this process with each software iteration thereafter). A model should be a living item that continues to be updated as the business and system are updated. The model should provide understanding, communication, and direction. If it isn't updated throughout the entire software development process, it can become stale and useless, so it's imperative that your organization has a process for dealing with models and with overall model development that includes who should be creating, updating, and maintaining the models over time.
Your organization also needs to take advantage of its staff as well as external resources. An organization typically has many domain experts, often in a business analyst-type role. These people would be building and designing business models of what is in place today (as is) and where the organization is heading (as desired). These experts often must build application models at the architectural level. As such, they must understand how what you are building will interact with itself (components within itself) and with other systems inside the organization. Architects also might take on this role as well.
As an application developer, writing code is what you like to do. But writing code without designing how it will interact can be dangerous to the integrity of the system, and that is why developers should also model the code before they write it. If they are using certain tools that enable code generation from the models developed, you can automate the creation of the boring code development tasks and get down to doing the fun development work of implementing business- and technology-specific code.
As a tester, you might not get involved directly in model building, but as you will learn later in this book, understanding the models can be quite useful when you have to create your tests. If testers are following an Extreme Programming (XP) style of software development process, they might also get involved in creating the models. XP proclaims that development requirements come from test cases that are created prior to the start of coding. That approach is a bit different from other processes in which test cases are created from requirements and aren't considered the requirements. This means that when testers follow an XP process, they also are really designing the requirements and thus modeling them (textually), which ensures a better understanding by everyone else involved in the development process.
From the Real WorldFlying Toward Success
A large airline company I worked with had a great way of deciding who would model and how to avoid the issue of too many people modeling. The company created teams of people from different parts of the business, including information technology (IT). You might have heard the term of "two in a box," referring to putting two people with different skills together so that they can team up and leverage each other's strengths. This company put more than two people together, but they got similar results. They teamed up to design first-level models (called domain models), in which they defined different elements such as the many different types of agents involved within the airline industry and how they interacted with the different parts of the business. More than 10 different types of agents were in their organization, including travel, ticket, gate, etc. By coming together as a team, they leveraged the different types of expertise available and ensured that all constituents involved in the process agreed to both the terminology and how each agent was involved in the business process. As the book continues, we will examine other successes seen in this organization.