UML for the C programming language.



Similar documents
How To Develop A Telelogic Harmony/Esw Project

Model-driven development solutions To support your business objectives. IBM Rational Rhapsody edition comparison matrix

The role of integrated requirements management in software delivery.

IBM RATIONAL PERFORMANCE TESTER

Six ways to accelerate Android mobile application development

Realizing business flexibility through integrated SOA policy management.

Introduction to SOA governance and service lifecycle management.

Ten steps to better requirements management.

SINGLE SIGNON FUNCTIONALITY IN HATS USING MICROSOFT SHAREPOINT PORTAL

Open source, commercial software or a coexistence strategy?

Achieving business agility and cost optimization by reducing IT complexity. The value of adding ESB enrichment to your existing messaging solution

Minimizing code defects to improve software quality and lower development costs.

Connectivity and integration Executive brief. Optimize the potential of ERP systems through IBM SMART SOA integration strategies.

Connecting PPM and software delivery

Web servers and WebSphere Portal

Applying 4+1 View Architecture with UML 2. White Paper

Ten questions to ask when evaluating contract management solutions

Tips for writing good use cases.

Getting Embedded C Applications to Market Faster using the Model-Driven Development Technologies of Modeling, Simulation and Code Generation

Designing a Home Alarm using the UML. And implementing it using C++ and VxWorks

Software change and release management White paper June Extending open source tools for more effective software delivery.

DO-178B compliance: turn an overhead expense into a competitive advantage

IBM Tivoli Network Manager V3.9

IBM Sterling Transportation Management System

IBM WebSphere Application Server Communications Enabled Applications

Windows 2000 / NT 4.0 / 95 / 98, MS-DOS, Suse Operating Systems

User experience storyboards: Building better UIs with RUP, UML, and use cases

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

IBM Unstructured Data Identification and Management

A new approach to automotive electric/electronic engineering life-cycle management

Better management through process automation.

IBM Sterling Warehouse Management System

IBM Global Business Services Microsoft Dynamics AX solutions from IBM

Rational Asset Manager 7.2 Editions and Licensing

Delivering information you can trust. IBM InfoSphere Master Data Management Server 9.0. Producing better business outcomes with trusted data

Systems and software product lines: the new frontier for business innovation.

The power of IBM SPSS Statistics and R together

Memory-to-memory session replication

A proven 5-step framework for managing supplier performance

Business Process Management IBM Business Process Manager V7.5

WebSphere Business Monitor

IBM Business Monitor. BPEL process monitoring

IBM Global Business Services Microsoft Dynamics CRM solutions from IBM

Web application security: automated scanning versus manual penetration testing.

IBM Rational systems and software solutions for the medical device industry

IBM Sterling Order Management

IBM Software Information Management. Scaling strategies for mission-critical discovery and navigation applications

Systems Engineering with RUP: Process Adoption in the Aerospace/ Defense Industry

The Value of Modeling

Systems and software product line engineering with SysML, UML and the IBM Rational Rhapsody BigLever Gears Bridge.

Integrated Development of Distributed Real-Time Applications with Asynchronous Communication

IBM Rational Rhapsody NoMagic Magicdraw: Integration Page 1/9. MagicDraw UML - IBM Rational Rhapsody. Integration

Algorithms, Flowcharts & Program Design. ComPro

IBM reaps business benefits and major cost savings from unified communications and collaboration

Cúram Business Intelligence and Analytics Guide

Designing Real-Time and Embedded Systems with the COMET/UML method

Gain a competitive edge through optimized B2B file transfer

Chapter 13: Program Development and Programming Languages

UML -> Rhapsody in Ada An Example

Development Environment and Tools for Java. Brian Hughes IBM

Continuing the MDM journey

Beyond converged networks: driving user productivity through unified communications and collaboration.

IBM WebSphere ILOG Rules for.net

IBM Rational AppScan: enhancing Web application security and regulatory compliance.

WebSphere Business Monitor

Improving sales effectiveness in the quote-to-cash process

Next-generation e-commerce for retail: How to optimize cross-channel marketing, sales and service.

Agile enterprise content management and the IBM Information Agenda.

Chapter 13: Program Development and Programming Languages

Enterprise content management solutions Better decisions, faster. Storing, finding and managing content in the digital enterprise.

Layered Approach to Development of OO War Game Models Using DEVS Framework

IBM BPM powered by Smart SOA White paper. Dynamic business processes for government: Enabling perpetual collaboration with IBM BPM.

WebSphere Cast Iron Cloud integration

IBM Tivoli Provisioning Manager V 7.1

The value of modeling

Chapter 13 Computer Programs and Programming Languages. Discovering Computers Your Interactive Guide to the Digital World

Working with telecommunications

IBM Software IBM Business Process Management Suite. Increase business agility with the IBM Business Process Management Suite

Manage Software Development in LabVIEW with Professional Tools

IBM Storwize V5000. Designed to drive innovation and greater flexibility with a hybrid storage solution. Highlights. IBM Systems Data Sheet

Industry Models and Information Server

A Comparison of Service-oriented, Resource-oriented, and Object-oriented Architecture Styles

WebSphere DataPower Release DNS Enhancements

Choosing a Development Tool

IBM Tivoli Netcool network management solutions for enterprise

S7 for Windows S7-300/400

Embedded/Real-Time Software Development with PathMATE and IBM Rational Systems Developer

IBM Policy Assessment and Compliance

Insights into Enterprise Telecom Expense Management

Glossary of Object Oriented Terms

Announcements. SE 1: Software Requirements Specification and Analysis. Review: Use Case Descriptions

IBM Cognos Enterprise: Powerful and scalable business intelligence and performance management

Modernizing enterprise application development with integrated change, build and release management.

WebSphere Business Monitor

To introduce software process models To describe three generic process models and when they may be used

Coca-Cola Bottling Company taps into a rich collaboration platform with integrated VoIP

Transcription:

Functional-based modeling White paper June 2009 UML for the C programming language. Bruce Powel Douglass, PhD, IBM

Page 2 Contents 2 Executive summary 3 FunctionalC UML profile 4 Functional development within UML FunctionalC diagrams 11 Validating the design using the model 11 Generating code from the model 12 Ensuring that the model and the code are always synchronized 12 Conclusion Executive summary Unified Modeling Language (UML) has been highly successful in the modeling of software-intensive systems, including systems-oriented models and realtime and embedded designs. The most common implementation for these models has been C++, with the C language in second place. On one hand, this is surprising because the most common implementation language for realtime and embedded systems overall by far is the language C. On the other hand, UML is used almost exclusively for object-oriented systems development, and most realtime and embedded designs are functionally oriented. There are three strategies for using UML for developing C realtime and embedded applications: Object-oriented modeling Object-based modeling Functional-based modeling Object-oriented modeling, object-based modeling and functional-based modeling vary in how completely they use the power and richness of UML. Object-oriented modeling uses the full richness of UML to represent the system and then forward-generates C code. This is straightforward, and the only tricky aspect of this is the mapping of the truly object-oriented features of UML into C code. There are some common idioms that make this transformation simple: Classes become structs containing data elements and pointers to member functions; generalization is implemented by the nesting of the structs representing the base classes; polymorphic operations are generated by producing virtual function tables with name-mangled member functions; and so on. Object-based designs are even simpler because they don t use the full richness of UML; specifically, they disallow the use of generalization and polymorphism. This results in designs that more directly and obviously map to the C language features but don t take advantage of all the conceptual tools available within UML.

Page 3 The last approach, functional-based modeling, is the focus of this paper. There are many reasons developers may want to avail themselves of the power of UML to represent the different aspects of their systems (e.g., functional, behavioral, interactive and structural) and yet eschew the use of object features completely, such as: UML can be a powerful tool for developers who do not use object features in their system designs. The developers may wish to represent legacy C code in models without requiring its re-architecture. The developers may be more comfortable with more traditional C concepts of files, functions and variables than they are with classes, operations and attributes. The system under development may be safety critical, and safety-critical designs are more difficult to certify under standards like DO-178B, Software Considerations in Airborne Systems and Equipment Certification. The FunctionalC profile uses a subset of UML for the modeling of functionally oriented, C-based systems. FunctionalC UML profile A profile is a specialized version of UML that subsets, supersets or extends UML for a particular purpose or vertical market domain. The FunctionalC profile uses a subset of UML for the modeling of functionally oriented, C-based systems. The primary diagram types defined in this profile are detailed in Table 1. Diagram type FC diagram UML basis diagram Description Requirements Use case diagram Use case diagram Represents uses of the system with relations to actors Structure Build diagram Component diagram Shows the set of artifacts constructed from the source files, such as executables and libraries Call graph Class diagram Shows the calls and their sequences among sets of functions File diagram Class diagram Shows the set of.c and.h files and their relations, including Source code diagram <none> Shows the generated source code as editable text Behavior Message diagram Sequence diagram Shows sequences of calls and events sent among a set of files, including passed parameter values State diagram State diagram Shows the state machine for files and how their included functions and actions are executed as events (whether synchronous or asynchronous) are received Flowchart Activity diagram Details the flow of control for a function or use case Table 1: FunctionalC profile diagrams.

Page 4 Functional development within UML Developers can program functionally with UML diagrams by using a UML stereotype called a file, which is simply a graphical representation of a source file. This file is capable of containing all the elements that C developers are used to dealing with, including variables, functions, types, etc. The file is added to the diagram and is used to partition the design into elements in much the same way a class is used to partition a program in object-oriented (OO) programming. A file is a UML stereotype that acts as a graphical representation of a source file and contains elements familiar to C developers, such as variables, functions and types. The code generated from the model appears very similar to the structural coding styles with which C programmers are familiar. The profile represents.c and.h files that have the same name and couples them together as one element on a diagram called a file. If you do not use the.c and.h file coupling in your code, then we can represent a.c or.h file individually on the diagram. This means that developers do not need to learn how to do OO design, but can just bring the concepts that they have always used into the next level of abstraction, the model. In essence, using the concepts of files, variables and functions in the model enables C developers to graphically describe their program and generate, what you see is what you get (WYSIWYG) code from the graphics. In addition, the C developer can simulate the design at the graphical level on the host PC by executing UML model before going to the target to ensure that the behavior and functionality are correct.

Page 5 Let s take the example of a timer file. This file could have the responsibility to keep track of time. It could have variables such as minutes and seconds, and perhaps functions such as reset and tick. The reset function could initialize the variables to zero, and the tick function could increment the time by one second. In the FunctionalC profile, we can create a simple file diagram such as the following that shows a single file called Timer that has variables minutes and seconds of type integer, as well as public functions tick() and reset(). Timer <File> +mins : int +secs : int -tick():void -Reset():void Figure 1: Structure diagram. The C code for this file would look just as you would expect a typical C program to look: extern int mins; extern int secs; /*## operation Reset() */ void Reset(); /*## operation tick() */ void tick(); This code looks the same as what a C programmer might write, except it was generated from adding these elements into the diagram above. Functions in one file can, of course, communicate with functions contained in another file, and they can also contain behavior defined by either a state diagram or a flowchart. In addition, files and objects can both be used in the same model, and files can be converted to objects, if desired. This enables developers who wish to migrate to an OO approach to do it at their own pace and doesn t force an all-or-nothing switch.

Page 6 Figure 2: Use case diagram. Use case diagrams are a powerful way to organize and manage a system s requirements. FunctionalC diagrams Use case diagrams are used to render coherent sets of requirements (called use cases) and their relations to external elements (called actors). This is the same as standard UML and is a powerful way to organize and manage a system s requirements. File diagrams graphically show files, their contents (typically functions, variables and types) and the relations with other files (including source or header file).

Page 7 A file diagram graphically shows a file s contents and its relationship to other files in the system while a build diagram shows the relationships between artifacts. Figure 3: File diagram. The build diagram represents the artifacts constructed via the compilation and link process and how they relate to each other. Figure 4: Build diagram.

Page 8 The call graph shows the relations among functions and variables. A call graph shows the relationships between functions and variables while a message diagram depicts a specific message-processing scenario. Figure 5: Call graph. Each message diagram shows a particular scenario in which a specific set of messages (either synchronous or asynchronous) is processed in a particular order. There are usually many message diagrams per use case or per collaboration of files. Figure 6: Message diagram.

Page 9 A state diagram represents the set of sets achievable by a file (or use case), the events it receives and the transitions that occur as a result of those event receptions. A state diagram shows the set of sets achievable by a file or use case the events it receives and the transactions that result. Figure 7: State diagram.

Page 10 A flowchart is used primarily to represent an algorithm or the detailed functional flow of control within a function. Flowcharts may be used to detail the functional flow of control. Figure 8: Flowchart.

Page 11 The same diagrams used to describe a model can be used to validate it. Validating the design using the model In a typical design, it is never clear that the model is correct until it has been executed. Technology is available today to perform graphical back-animation or simulation, which allows code generated automatically from the model with instrumentation to talk back to the modeling tool. The tool then uses this information to depict the code execution, but in terms of model concepts. This means that the very same diagrams used to describe the model can be used to validate the model. For example, the developer is able to see the value of the variables, see to what each relation is set, see what state each file is in, trace the functions calls between files on a sequence diagram and even step through a flowchart. This animation can be done at any time during a project and allows the programmer to spend more time being highly productive and doing design (the intellectual property), and less time doing the tedious bookkeeping portions of coding. Being able to test and debug a design at both the model and code levels enables the programmer to detect problems early and correct them when they are cheaper and easier to fix. With realtime and embedded model projects, a significant amount of the code may be generated automatically. Generating code from the model Depending on the tool used, C code can be generated directly from the model; all the code that we have seen so far for the timer file can be generated automatically. In fact, the author s experience with realtime and embedded model projects is that on average, a significant amount of the code can be generated automatically. The remaining is code that the programmer writes, such as the bodies for the tick and reset functions. Code can be generated automatically for the dependencies, the association, files, functions, variables, state diagrams, flowcharts and so on. The programmer just needs to specify the functions and actions on the state charts.

Ensuring that the model and the code are always synchronized In the traditional use of computer-aided software/system engineering (CASE) tools, programmers spend time creating a model and then generate the code. Later the code is modified to get it to work, and nobody ever has the time or energy to update the model. As time goes on, the models get more and more out of sync with the code and become less and less useful. Again, technology is now available to enable any modifications to the code to be round-tripped back into the model, helping to ensure that the code and the model are in sync at all times. This is so important during the maintenance phase, as well as when features need to be added to a new version. Conclusion The introduction of natural C concepts such as files, functions and variables into UML as a profile helps C developers to receive the benefits of model-driven architecture while thinking and working in the manner to which they are accustomed. Through the process of visualization, it is now possible to incorporate legacy code into the development environment without changing a single line, enabling C developers to reuse their legacy code (IP), either as is or as a starting point. Generation of productionquality structured code directly from the model helps lower risk even further by allowing UML and model-driven architecture (MDA) to fit into existing processes. This helps to further reduce the risk involved in adopting these technologies and can help cut development time immensely. Many companies have already been doing development with UML-based MDA and are finding that they are might be able to reduce the development cycle substantially in some cases. For more information To learn more about UML for the C programming language, contact your IBM representative or IBM Business Partner, or visit: Copyright IBM Corporation 2009 IBM Corporation Software Group Route 100 Somers, NY 10589 U.S.A. Produced in the United States of America June 2009 All Rights Reserved IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both. If these and other IBM trademarked terms are marked on their first occurrence in this information with a trademark symbol ( or ), these symbols indicate U.S. registered or common law trademarks owned by IBM at the time this information was published. Such trademarks may also be registered or common law trademarks in other countries. A current list of IBM trademarks is available on the Web at Copyright and trademark information at ibm.com/legal/copytrade.shtml Other company, product, or service names may be trademarks or service marks of others. References in this publication to IBM products and services do not imply that IBM intends to make them available in all countries in which IBM operates. The information contained in this documentation is provided for informational purposes only. While efforts were made to verify the completeness and accuracy of the information contained in this documentation, it is provided as is without warranty of any kind, express or implied. In addition, this information is based on IBM s current product plans and strategy, which are subject to change by IBM without notice. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this documentation or any other documentation. Nothing contained in this documentation is intended to, nor shall have the effect of, creating any warranties or representations from IBM (or its suppliers or licensors), or altering the terms and conditions of the applicable license agreement governing the use of IBM software. ibm.com/software/rational RAW14058-USEN-01