United Business Media EE Times


Search

HOMEMARKET INTELLIGENCE UNITFORUMSDESIGNNEW PRODUCTSCAREERSBLOGSCONTACTEVENTSSIGN UP!RSSMost Popular contentTrusted Sources

 


Using UML to drive Java can alleviate chaos








EE Times


Although the Java language is still a new proposition for development in embedded systems, developers are beginning to consider the use of modeling languages, such as Unified Modeling Language, as part of their development strategy. One reason UML is receiving greater interest in the embedded community is because Java is gaining a foothold there as well. At one time the language was thought to be too big and too slow for use in embedded systems. Sun Microsystems Inc. took this perception as the driving force behind what has become the Java 2 Micro Edition (J2ME).

Java for embedded systems is not limited to J2ME, but this seems to be the front-runner as the Java platform for a variety of embedded and handheld devices. Java has certain strengths that may appeal to the embedded developer, such as excellent object-oriented programming support, strong typing, exception handling, built-in threading, large existing frameworks and, most important, a safe and stable run-time environment. The run-time performance of Java is improving through the use of just-in-time compilers and hardware virtual machines (VMs). Memory footprint, although larger in comparison with small C-based applications, is improved through the introduction of smaller and efficient VMs and significantly smaller class frameworks.

Java offers some excellent features for the embedded developer. Those who are tired of debugging to find pointer bugs and applications that hang with no indication of errors will welcome Java's strong typing, object-oriented support and run-time environment. These features do not, however, alleviate all of the burdens of complex software development for the embedded developer. For as more-complex Java-based devices emerge, and the capabilities of the target systems increase, the demand for complex behavior and sophisticated features does also.

But these applications likely have behavior, concurrency, reliability and availability requirements that desktop applications do not offer. And J2ME applications, especially, are embedded applications that must react quickly and efficiently to input from devices and users.

In many cases — for example, an application that contains communicating threads, device drivers, user interface and a network connection — complex concurrent behavior is required. A useful abstraction for designing concurrent systems is the active object — an object that has its own thread of control.

But typical Java objects are passive: They react only to method calls, and are inactive when no method is called. An active object, by contrast, has its own thread of control and processes messages that arrive through a message queue rather than from method calls.

Message queues allow for asynchronous communication; therefore, the active object can perform activities while messages arrive. Messages are processed when current activities are complete.

However, the active-object concept can be directly modeled in UML and provides a convenient and powerful building block for development in embedded systems. That's because UML combines a number of useful features, including capsules, ports and protocols.

Capsules are a specialized class with its own thread of control that communicates with other capsules using message queues, represents active objects in UML and makes up a portion of the UML tool box addressing key needs of the embedded and real-time developer. Also helpful are ports, defined as interface objects of capsules that allow for message-based communication between capsules; and protocols, which define the list of signals that are accepted by and sent on a port.

The combination of capsule, port and protocol is analogous to hardware design where engineers build systems from components (logic chips, ASICs and microcontrollers, for example) that have established interfaces (pinouts) and connect them together on a schematic diagram.

The behavior of a capsule — that is, the way it reacts to external stimuli — is defined with hierarchical finite state machines. State machines are also common in hardware design and prove useful for building reactive and event-driven software. The state machines in capsules react to events that arrive as signals on the public ports — the public interface of the capsule to the external environment. Therefore, systems built with capsules are networks of cooperating and communicating state machines, similar to the architecture of complex hardware logic. Using smaller building blocks with well-understood behavior and interfaces is a proven way to achieve success with large-scale systems.

A practical benefit of using UML models for system architecture and design is the ability to automatically generate source code. UML is a programming language (higher level than C++ or Java) and UML models are formal enough to generate a complete application.

The combination of structure defined by collaboration diagrams, relationships defined by class diagrams, communication by ports and protocols, and behavior with state machines provides a rich and detailed description. Code generation from such models is mature and has been available for more than a decade.

Why is code generation important? Code generation extends the usefulness and power of visual modeling by not only giving a developer visual building blocks but a way to generate small and fast code from these building blocks. Code generation from UML models eliminates repetitive and error-prone manual coding that can cripple any project. Capsules, ports and protocols provide a convenient communication mechanism that would normally be hand-coded. Code generation enhances the productivity gained from visual modeling.

How does UML apply to J2ME? The configuration and profile class framework can be made into a UML library — that is, the developer can access the class framework as a set of visual tools (classes, diagrams and so on) and use them as needed. For example, a developer writing a mobile information device profile (MIDP) application can use the available classes from the Connected Limited Device Configuration and MIDP class framework.

A typical tool allows the developer to make use of the framework by just dragging and dropping any of these classes into a diagram, adding another class and a generalization (inheritance) relationship. The ability to use the class framework and the application as a visual model greatly enhances productivity.

Mobile and embedded Java applications are similar to other embedded systems. They typically use threads (or tasks) to accomplish the required response to events arriving from users, devices and other systems through intermittent network connectivity. The problem domain is more complex and time sensitive.

The use of capsules to model concurrent active objects, and of state machines to describe their behavior, provides a developer with the tools to represent these concurrent active objects. Compact and efficient Java code is generated from a capsule's state machine.

Any detailed coding, such as in class operations and state transitions, is part of the model and is included in the generated Java code. Classes and capsules are built together in a component that specifies how the code is generated, compiled and packaged. Tool support for such activities exists today and is essential to make model-driven development practical.

UML and Java are not silver bullets, however. They do not provide the magic solution to all embedded-development problems. Yet developers can take a big step toward improving their productivity by using UML model-driven development and a robust and powerful object-oriented language like Java.











  Free Subscription to EE Times
First Name Last Name
Company Name Title
Email address
  Click here for your Free Subscription to EETimes Europe
 
CAREER CENTER
Ready to take that job and shove it?
SEARCH JOBS
SPONSOR

RECENT JOB POSTINGS
CAREER NEWS
With Acquisition Delayed, Sun Cutting 3,000 Jobs
With its proposed acquisition by Oracle being delayed by regulators, Sun plans to cut 3,000 jobs across several regions over the next 12 months.

For more great jobs, career related news, features and services, please visit EETimes' Career Center.


All White Papers »   

 
Education and
Learning


Learn Now:












Home | About | Editorial Calendar | Feedback | Subscriptions | Newsletter | Media Kit | Contact | Reprints|  RSS|   Digital|  Mobile
Network Websites
International
Network Features




All materials on this site Copyright © 2009 TechInsights, a Division of United Business Media LLC All rights reserved.
Privacy Statement | Terms of Service | About