Chapter 25. Sharpen Your Focus with Mylyn

Introduction to Mylyn

Contributed by: Keith Coughtrey

Today’s development projects, and the environments we use to build them, are increasingly rich and complex, and informative. However, in practical terms, there is a limit to the amount of information human beings can deal with simultaneously. Mylyn is an innovative Eclipse plug-in that enhances developer productivity by providing integrated task management and a contextual view of the tasks you are working on.

Mylyn benefits developers in two ways. The first provides a convenient integration with issue management systems such as Trac (see Chapter 28), Bugzilla (see Chapter 27), and JIRA, allowing you to view and manage tasks held in your issue tracker from within the IDE. This in itself is appreciable, but Mylyn goes much further than that. Mylyn also provides a way to hide much of the detail of your projects that is irrelevant to the task at hand. It is this second aspect, called context management, that provides a real increase in developer productivity because it cuts down on the amount of navigating, searching, and scanning through trees, lists, and code looking for the parts that are of interest when working on a particular task—whether that be a bug fix or the development of a new feature. Indeed, Mylyn is based on the observation that when you work on a particular development task, you actually need only to look at and manipulate a relatively small number of files. By masking out irrelevant information, Mylyn lets you focus exclusively on the files that need to be modified.

Also, because Mylyn maintains a separate context for each task, when you return to a task that was worked on previously, you are immediately presented with those parts of you project that were considered relevant at the time. Because the context can move with the task as it is assigned to different members of the team, it may be that when you open a task you see those parts of the code that a previous developer worked on when he or she looked at the task. This can be a real head start or a great memory jogger.

I’m sure you are wondering how Mylyn knows which parts of the project are relevant to a task. Essentially, that is determined by you and based on what you examine and where you make changes as you work on a particular task. There will be more details regarding this later in this chapter.

Installing Mylyn

Mylyn comes bundled with Eclipse 3.3 and later versions. You can update the plug-in and install extra features using the Eclipse Remote Install feature. Open the “Find and Install” option from the Eclipse help menu, select the “Search for new features to install” and enter the URL of the update site. See Figure 25-1.[22]

Next you select the features you want to install. It’s probably best to include everything, but you can leave out any connectors you don’t intend to use.

Installing the Mylyn plug-in
Figure 25-1. Installing the Mylyn plug-in

Even if you do have a more recent version of Eclipse with Mylyn integrated, be sure to check out the optional connectors and the Mylyn Extras update site. Here you can get useful additional connectors to other Issue Management systems such as Trac and Jira, or experiment with integration with the XPlanner Agile project management tool (see Figure 25-2).

The Mylyn extras
Figure 25-2. The Mylyn extras

Tracking Tasks and Issues

Tasks and issues can come from many sources. To-do lists are a well known and widely used technique for enhancing personal productivity. In a development project, developers can also define and record tasks as an effective way of organizing their work. QA staff will raise issues during testing: missing features, bugs to be fixed, and so on. Mylyn allows you to track the progress of tasks that can either be stored locally in your workspace or stored in the repository of your favorite issue tracker. Mylyn provides connectors for Bugzilla (see Chapter 27), Trac (see Chapter 28), and JIRA, among others.

Indeed, Mylyn is an excellent, lightweight task management system in its own right. It provides you with a convenient, centralized view of all your tasks, both the ones that you assign yourself (your own “to-do” list) and issues raised by other people. You can also keep an eye on tasks assigned to other people that you may need to follow up on. And you can do all this without having to leave your development environment!

To create a new local task, you simply click on the New Task toolbar button of Mylyn’s “Task List” view (see Figure 25-3). Then you can enter a summary of the task, set a priority, add an estimate, and schedule a date on which the work will be done. These tasks are not visible to other users, so this is a good way to organize your work on a personal level.

Adding a Mylyn task
Figure 25-3. Adding a Mylyn task

The Mylyn “Task List” view provides a few nice features that help you stay focused on the most important jobs at hand. Completed tasks are barred, and the current active task (see Focusing on a Task with Context Management) is shown in bold. If you have a lot of tasks (and you generally will!), a good trick is to focus on the tasks due in the current week. You can do this using the “Focus on Workweek” button on the Task List toolbar, or using the popdown menu (see Figure 25-4). You can also filter out completed tasks or tasks below a certain priority.

The Mylyn task list
Figure 25-4. The Mylyn task list

Mylyn also offers some simple but effective schedule management features. You can use the tasks to manage your time, rescheduling things if necessary as priorities change. When a task is overdue, it appears in red in the task list (see Figure 25-4), and a popup window appears on your desktop to remind you (just in case). If you do need to reschedule it, just use the “Schedule” option in the contextual menu (see Figure 25-5). With a simple right-click, you can indicate that a task is complete or defer it to a later date.

Scheduling a task in Mylyn
Figure 25-5. Scheduling a task in Mylyn

Tasks can also be grouped into categories and when displaying just those tasks scheduled for the current working week or hovering over a task category, you see a progress bar giving a visual indication of the proportion of tasks that have been completed (see Figure 25-6).

Turning to repository tasks, the plug-in gives the kind of facilities that have long been available for interacting with source repositories and synchronization with the repository works in much the same way.

Interacting with Task Repositories

Mylyn provides sophisticated integration with many issue tracking systems such as Bugzilla (see Chapter 27), Trac (see Chapter 28), and JIRA. To integrate with JIRA, JIRA needs to be configured to accept remote API calls (make sure the “Accept remote API calls” option in the General Configuration screen is activated).

Progress bars give an idea of how much planned work has been completed
Figure 25-6. Progress bars give an idea of how much planned work has been completed

To integrate with your issue tracking system, you need to set up a task repository. Open the Mylyn Task repositories view and click on the toolbar button to create a new repository connection (see Figure 25-7). Select the repository type, click Next, then enter the server details. Choose Validate Settings and then Finish. You can set up as many task repositories as you want, which is useful if you are working on several projects that use different issue tracking systems.

At the time of this writing, the server drop-down has an example entry for both the Bugzilla and Trac repository types. It is worth exploring these repositories to get a feel for how the integration works.

Adding a new task repository
Figure 25-7. Adding a new task repository

Once you have set up a task repository, you can retrieve tasks and issues by querying the repository. For example, you might want to create a query to bring back all the issues assigned to you. You can create a new query from the “Task List” view using the “New→Query” menu option (see Figure 25-8).

Querying the issue management system
Figure 25-8. Querying the issue management system

The attributes displayed depend on the repository type but, as you can see, they give all the options you need to filter out a subset of the repository tasks that are of interest to you.

Once you have created the query, it will appear in your “Task List” view (see Figure 25-9). You can double-click on these tasks to view the details page in the web browser embedded within Eclipse. This is another nice thing about Mylyn: when you view or modify repository tasks, you use the same web interface as you would normally use with your issue tracking system. You just do it from within Eclipse.

The detailed view of a repository task also has a “Planning” tab, similar to the one used for locally stored tasks (see Figure 25-3). This tab allows you to add your own personal planning details and notes to a repository task in exactly the same way you would for a personal task, giving you a consistent way to manage planning all your tasks in a single place.

Repository tasks retrieved from queries appear in the task list
Figure 25-9. Repository tasks retrieved from queries appear in the task list

By default, Mylyn will automatically synchronize with your task repositories on a regular basis. This task is run as a discreet background process: your repository queries will be regularly updated to reflect the current repository content.

In addition, if another user creates an issue in the issue management system, or modifies an existing issue, Mylyn will automatically notify you of the change in a small pop-up (see Figure 25-10). The left-pointing arrow indicates a change coming down from the repository to your local system. This is a convenient way to keep tabs on any new issues. You don’t need to monitor your email for incoming issues.

Mylyn will notify you of any new issues
Figure 25-10. Mylyn will notify you of any new issues

You can define how frequently you want Mylyn to synchronize with the repository in the Windows →Preferences→Mylyn→Tasks menu (the default is every 20 minutes).

You can also place new tasks directly into this repository from within Eclipse. In the contextual menu in the “Task List” view, select “New→Repository Task” (see Figure 25-11). This will open a browser view in Eclipse, where you can add the new task into your issue management system using the usual web interface.

Adding a repository task
Figure 25-11. Adding a repository task

Both Bugzilla and Trac[*] integration support full off-line issue editing, meaning that you have a snapshot of the issues that you can amend locally. When you make a change to an issue and save, it assumes an outgoing mode (indicated by an arrow pointing to the right). This change can then be committed to the repository when appropriate.

Mylyn also lets you run “ad-hoc” search queries. Unlike queries made from the task list (Figure 25-8), the results of these searches are not stored in the “Task List” view. You can do this using the normal “Search” window, where you will find a special “Task Search” tab dedicated to task repository searches. This tab contains the same, repository-dependent search criteria as you find in the query window (see Figure 25-8).

Apart from avoiding the switching backward and forward between a browser and the IDE, the real benefit of having your issue tracker integrated into Eclipse comes in the links that can be made between the issue content and the project. For example, if the issue contains a stack trace, clicking on it will take you to the corresponding line of code in the same way it does when you click on a stack trace in the console.

Focusing on a Task with Context Management

The objective here is to reduce the information overload you typically get when working on projects in Eclipse.

Without Mylyn, you quickly find that the Package Explorer and Navigator have hundreds or perhaps thousands of entries. The outline view of a complex class may show dozens of properties and methods and you often end up with far too many code editors open to display. Also, when code assist pops up, it often contains a long list of possible selections.

Generally, only a small subset of all this information is relevant to the task in hand. For example, the class you are working on may contain many methods that are stable and not of interest in the particular context and of course the same goes for the Outline view.

With Mylyn all you need to do is to activate a task (by clicking a radio button in the task list) before you start working on it and from then on, your activity starts to build up the context. When you activate a task, the package explorer view will automatically be filtered to display only the objects deemed of interest for this particular task.

At the start, your context is empty and the various views such as the Package Explorer show what appears to be an empty project. The easiest way to add content is to use the Open Type dialog (Ctrl+Shift+T) to search for the object of interest. If you then select a class to open, that class is added to your context because you have shown an interest in it.

Initially, all of the methods in the class you have opened will be folded on the basis that none of them are of interest. However, as you click on methods they unfold and are added to your context, appearing in the Package Explorer and the Outline views.

The more that you work with elements, the more interesting they are presumed to be. Eventually they become landmarked, indicating that they are a key part of the context of this task. Mylyn adds a toggle button to the Package Explorer, Navigator, and Outline views that allows you to apply the task focus in two different ways. When the toggle is set to focus on the active task, these views show only those items that are of interest. However, when the task focus is toggled off, the views present everything that they would without Mylyn, but some decoration is added to make the items of interest stand out. By default, all uninteresting items are shown in gray, interesting items in black, and landmarks in bold.

This is illustrated in Figure 25-12. This screen shot illustrates a number of the key features of Mylyn context management. We can see the “Focus on Active Task” toogle button (1), which lets you switch context filtering on and off. Mylyn also applies filtering In the Java editor view, letting you concentrate on the specific code you want to work on. In this editor, when context filtering is activated, uninteresting code is automatically folded (2), making it easier to scan through the code quickly. If you select a folded element, it unfolds and is integrated into the task context.

Context-sensitive filtering is also applied to the Java code-completion feature (4). Note how the code assist has been divided into two lists. Above the line are items that are in your context. In addition, these items are ranked by relevance for the active task. All in all, you have a pretty good chance that the item you want will be visible right away.

In the “Outline” view (3), landmarked items are shown in bold (for example, the override() method here), whereas uninteresting methods (such as the clone() method) are hidden.

When a task is activated, it appears in bold in the “Task List” view (5), making it easy to see at a glance.

The combination of all these features helps to mask irrelevant and unnecessary information from your view, and lets you concentrate on the task at hand. In a subtle but real way, this approach results in a surprising gain in developer productivity.

Using the Mylyn view in Eclipse
Figure 25-12. Using the Mylyn view in Eclipse

Clearly, if you work on a task for an extended period, your context would get bloated and you would start to lose the benefits of task focus. To avoid this happening, things that you haven’t accessed much are progressively removed from your context. Any open editor associated with such an element will be closed automatically.

If you need to, you can give Mylyn some help by using the right-click menu options to “Mark as Landmark” or “Make Less Interesting” in the Package Explorer view.

The real beauty of the task context comes into play when you switch back to a task you worked on a while ago and you are saved from a great deal of searching around trying to recall and locate the objects of interest. When you deactivate a task, the corresponding editors are all closed. If you switch back to this task later on, they will all be opened again. To make things even easier a Back navigation button appears in the task list toolbar that will give you a list of the last 10 tasks you worked on.

Perhaps this is an obvious point but you should bear in mind that because whatever you touch gets added to your task context, it is important that you always have the correct task activated. This does require some discipline, but it’s a good habit to get into. As Mylyn also tracks roughly how long you have spent on a task, this can help you compare estimates with actuals.

Using the Eclipse Change Sets

In Eclipse, change sets allow you to organize resources that you have modified into logical groups before updating them in your source code repository. Eclipse supports this mechanism for CVS and Subversion. In CVS, all of the changes are submitted with the same comment message. In Subversion, where change sets are supported natively, all of the modifications in the change set are submitted as a single transaction.

Change sets in Eclipse are good, but they are complicated to manage manually in any but the most trivial of cases. However, Mylyn can help you manage your change sets automatically. Whenever you activate a task, a new change set will be created for that task. Any files you modify while working on that task will be added to this change set automatically.

You can manage the Mylyn change set in the Eclipse Synchronize view (“Team→Synchronize”). To enable change set support, ensure the “Show Change Sets” button is set on the Synchronize view. Here, you can view the modified files that currently make up your change set, or commit or revert your changes. And, if you really need to, you can always manually add other modified files to the Mylyn change set using the contextual menu (see Figure 25-13).

Eclipse change sets with Mylyn
Figure 25-13. Eclipse change sets with Mylyn

Another advantage of using the Mylyn change sets is that the commit message is automatically initialized with a sensible message based on the title and status of your active task (see Figure 25-14). This makes it easier to relate source code modifications to issues in a consistent manner. If you are using Trac, it is also possible to configure Trac to automatically append this message to the issue whenever the changes are committed (see Updating Trac Issues from Subversion).

Committing a Mylyn change set
Figure 25-14. Committing a Mylyn change set

It can be useful to customize the message format to suit your environment. For example, if you are using Subversion and Trac, you might want to configure Subversion to update the Trac issue based on the Subversion message (see Updating Trac Issues from Subversion). In this case, you can customize the message so that the Subversion hook will identify the Trac issue in the message, as shown in Figure 25-15.

Committing a Mylyn change set
Figure 25-15. Committing a Mylyn change set

This way, your Subversion message will be automatically added to the Trac issue.

Mylyn also integrates well with the History view (see Figure 25-16). In this view, you can see a history of the changes made to a particular file, including the messages associated with each commited change set. These messages also include a hyperlink to the corresponding task.

Viewing change history
Figure 25-16. Viewing change history

Sharing Context with Other Developers

The Mylyn context is a powerful tool that enables you to get up to speed very quickly when you reactivate a task. It also helps other developers who may have to pick up a task from where you left off. Providing them with the context you so painstakingly created can be a valuable aid. The developer can immediately see what files you were modifying, what tests you where running, and so forth. This allows him to immediately focus on the correct trouble spots, rather than having to search for them himself.

In Mylyn, you can share your contexts with other developers. Mylyn lets you attach the current context to a task and record this context as an attachment to the corresponding ticket in the issue management system (at the time of this writing, this only worked for Bugzilla task repositories). You do this from the “Context” tab, using the “Attach context...” link. Subsequently, other developers can click on “Retrieve context...” to download and activate this context in their own Eclipse environment.

Conclusion

The task and context management features of Mylyn work together to help you focus your effort on the task at hand, making everything relevant easier to find and hiding the irrelevant. When you factor in the ability to share contexts with other teams members, these features make the plug-in a worthwhile addition to your Eclipse environment.



[22] You can find the latest live update sites at http://www.eclipse.org/downloads/.

[*] Supported from Trac version 0.10 onward using the XML-RPC access type.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.163.208