Выбрать главу

This gets a little tricky. The destination of a message can’t be the vertical bar (known as an “activation”) below a class instance. Note that when you drag the message wire over the activation bar, the international “no” symbol pops up. Drag the wire until the UpDownButton box is shaded blue, and click. Again, you’ll probably want to drag down the activation bar at the end of the illuminate message for readability. Your diagram should now look something like Figure 8.14.

Figure 8.14: Sequence diagram with messages.

Continue adding messages to carry out the sequence of events listed above. After illuminating the button, the Controller will start the Elevator moving toward the specified floor. The Elevator will notify the Controller when it has reached the floor, whereupon the Controller will stop the Elevator and turn off the button illumination. Finally the Controller opens the Door and, after a suitable delay, closes the Door. The final diagram is shown in Figure 8.15.

Figure 8.15: Completed sequence diagram.

Unfortunately, EclipseUML seems to have a mind of its own when it comes to vertical spacing of messages. It seems that some activation bars can be moved and resized, while other can’t. The resulting diagram is so big it requires a full screen to display.

We could continue looking at the other UML diagrams, but I think you get the idea. Feel free to play around with them and see what they do.

8.1.6 Configuring EclipseUML

EclipseUML has a number of configuration options. Click Window→Preferences and select the UML entry. The top-level preferences dialog has four tabs. The Appearance tab is show in Figure 8.16. You may very well want to turn off the Show splash screen option. The tool bar can be displayed as text and/or images. The icon images can be either flat or embossed, although I can’t really see any difference.

Figure 8.16: EclipseUML preferences.

Diagram presentation style offers some subtle variations in display, mainly involving shading. The differences are more apparent in the use case diagram than in the sequence diagram.

The Options and Print tabs are fairly self-explanatory. The Diagram Board tab offers options related to the grid and ruler, although it’s not obvious that they do anything.

Expand the UML preferences entry then expand Class Diagram. In the Association dialog is a Router option that specifies how lines, or “wires,” are drawn. The default is “Manhattan,” which routes the lines with right angles. The alternative is “Manual,” which runs the lines directly. Most of the other options are concerned with features of Java.

8.2 CVS

Back in the early days of embedded computing, a lone engineer would design the hardware and write the software, sometimes in assembly language. I did my share of that back in the day. In that kind of environment, keeping track of changes was no big deal. The entire program may have consisted of perhaps a dozen or so files, and it’s easy enough to wrap your mind around a project of that magnitude.

Needless to say, things have changed. Projects are not uncommon that contain hundreds, if not thousands of files being worked on by teams of developers who may be distributed all over the world. Now, keeping track of changes is a big deal. In fact, disciplined management of revisions is absolutely critical in maintaining control of the software development process. I even regret not having used version control on projects where I was the only developer.

CVS (Concurrent Versioning System) is an Open Source software package that supports simultaneous development of files by multiple developers. It is commonly used in large programming projects, but its use is not limited to software development. It can be useful in any task that involves managing files of data on a computer system.

CVS uses a client/server paradigm to store a set of files on a server and then make those files accessible to all users who need them. The system provides commands to “check out” a copy of a file for modification and subsequently “commit” changes back to the repository. It also scans files as they are moved to and from the repository, to prevent one person’s changes from overwriting another’s.

The system also maintains a history of each file, which allows you to go back and recreate any previous version.

8.2.1 Branches

CVS is based on the notion of branches, where programming teams can share and integrate ongoing work. A branch is a shared work area that can be updated at any time by any member of the team. This allows individuals to share their own work with other members of the team and to access the work of others during all stages of a project. The branch effectively represents the current shared state of the project.

The process is illustrated graphically in Figure 8.17. Two programmers each check files out of the branch, update them, and commit them back to the branch. It is entirely possible that both programmers are working on the same file. Both programmers need to synchronize the file to check for conflicting changes before committing.

Figure 8.17: CVS workflow.

Every CVS repository has a special branch called HEAD that is the main branch. HEAD, also referred to as the trunk, is considered sacrosanct. You don’t commit something to HEAD until you are absolutely certain that it’s correct. Other branches are created to provide a safe place to make changes before committing file to the HEAD branch.

8.2.2 CVS in Eclipse

Like most Unix/Linux software packages, CVS is strictly command line-driven. But of course, Eclipse wraps a graphical user interface around that, just like it does for gdb. The CVS GUI is embodied in the CVS Repository Exploring perspective. The blank CVS perspective shown in Figure 8.18 isn’t very exciting.

Figure 8.18: Blank CVS Repository Exploring perspective.

To see how CVS works, we’ll have to connect to a repository on a CVS server. There’s a large number of CVS repositories at sourceforge.net. I happened to choose nxtOSEK, an RTOS for the Lego Mindstorm NXT, as my sample project, but feel free to select whatever strikes your fancy at SourceForge, or anywhere else for that matter. nxtOSEK is found at http://sourceforge.net/projects/lejos-osek.

In a web browser, go to that page, or the page for your selected project, and scroll down until you find a link to the CVS Repository. Upon clicking the link you’ll see some basic information about CVS and about anonymous access. There you’ll see a command line, something like:

cvs –d:pserver:anonymous@lejos-osek.cvs.sourceforge.net:/cvsroot/lejos-osek login

Note that this is in fact one line.

This tells us the following:

• The repository uses the CVS protocol pserver.

• The user login name is anonymous with no password.

• The server name is lejos-osek.cvs.sourceforge.net.

• The root path to the project is cvsroot/lejos-osek.

This is enough information to get Eclipse to connect to the project. Right-click in the CVS Repositories view and select New→ Repository Location…. Fill out the resulting dialog, as shown in Figure 8.19. The User: field is a drop-down menu whose only entry is anonymous.