Home > Articles

This chapter is from the book

Guided Tours and Sightseeing Maps

It is easier to quickly discover the best of a new place with a guided tour or a sightseeing map. In a city you have never visited before, you can explore randomly, hoping to bump into something interesting. This is something I love to do during an afternoon within a longer stay, to get a feel of the place. However, if I have only one day and I want to quickly enjoy the best of the city, I take a guided tour with a theme. For example, I have excellent souvenirs from a guided tour of the old sky-scrapers in Chicago, where the guide knew how to get us into the historical lobbies to enjoy the low light that was typical of early light bulbs. One year later, I enjoyed an architecture boat tour of Chicago, from the river, which is another way to really grasp the city. In Berlin, I booked a tour dedicated to Berlin’s street art, which was eye opening. For me, the same street art I see every day without really noticing gains another dimension when put in a context with one hint from a guide.

But guided tours start at a fixed hour on a few days a week only, often take a few hours, and may be expensive. If you happen to pass through a city on the wrong day, you are out of luck. But you can still get a tourist map or printed guided tours. And, of course, there is probably an app for that! Plenty of apps provide guided tours and sightseeing maps, classified by themes such as attractions, eat, drink, dance, and concerts. In Chicago, the Society of Architecture offers free architecture tours on leaflets, too. And the Internet is full of resources to help plan a visit, such as “Top 20 List of Must-See Highlights,” “Itineraries to Help You Plan Your Visit,” and “101 Things to Do in London.”

The process of becoming familiar with a code base can be similar to the process of becoming familiar with a city. The best way for someone to discover it is with another human—a colleague. But if you want to provide an alternative to a human guide, you can take inspiration from the tourism industry and provide itineraries of guided tours and sightseeing maps. This tourism metaphor comes from Simon Brown, who writes the blog “Coding the Architecture” and also wrote the book Software Architecture for Developers, Volume 2.

One important thing to realize is that all the tourism guidance in a city is highly curated: Only a very small subset of all the possible content of the city is presented, for various reasons ranging from the historical importance of different landmarks to more money-related reasons.

One important difference between a code base and a city is that a code base can change more frequently than most cities. As a result, the guidance must be provided in such a way that the work to keep it up-to-date is minimized; of course, automation is a good option here.

Therefore: Provide curated guides of a code base, each with a big theme. Augment the code with extra metadata about the guided tour or a sightseeing map, and set up an automated mechanism to publish as often as desired an updated guide from these metadata. A sightseeing map or a guided tour based on tags in the code is a perfect example of the augmented code approach.

If the code base does not change much, a guided tour or a sightseeing map can be as simple as a bookmark with a list of the selected places of interest, each with a short description and a link to its location in the code. If the code is on a platform like GitHub, it is easy to link to any line of code directly. This bookmark can be created in HTML, Markdown, JSON, a dedicated bookmark format, or any other form you like.

If the code base changes frequently or may change frequently, a manually managed bookmark would require too much effort to keep up-to-date, so you might choose dynamic curation instead: Place tags on the selected locations in the code and rely on the search features of the IDE to instantly display the bookmarks. If needed, you can add metadata to the tags to enable reconstruction of the complete guided tour, simply by scanning the code base.

You might be worrying that adding tags about sightseeing maps or guided tours into the code will pollute the code—and you are right. These tags are not really about the tagged element intrinsically but about how it is used, so use this approach sparingly.

Consider your code base as a beautiful wilderness in the mountains where you go hiking. It is a protected area, and there are red-and-white hiking trail signs painted directly on the stones and on the trees. This paint does pollute the natural environment in a small way, but we all accept it because it’s very useful and degrades the landscape only a limited amount.

Creating a Sightseeing Map

To create a sightseeing map, you first create a custom annotation or attribute, and then you put it on the few most important places that you want to emphasize. To be effective, you should keep the number of places of interest low—ideally 5 to 7 and certainly no more than 10.

It may well be that one of the most difficult decision here is to name each annotation or attribute. Here are some naming suggestions:

  • KeyLandmark or Landmark

  • MustSee

  • SightSeeingSite

  • CoreConcept or CoreProcess

  • PlaceOfInterest, PointOfInterest, or POI

  • TopAttraction

  • VIPCode

  • KeyAlgorithm or KeyCalculation

For the approach to be useful, you also need to make sure everybody knows about the tags and how to search them.

A Sightseeing Map Example in C# and Java

Say that in creating a custom attribute, you decide to put it into its own assembly to be shared by other Visual Studio projects (which also means you don’t want anything to be specific to any particular project there). Here is how the attribute might look in C#:

1  public class KeyLandmarkAttribute: Attribute
2  {
3  }

You can now immediately use this attribute to tag your code:

1  public class Foo
2  {
3     [KeyLandmark("The main steps of enriching the Customer
4     Purchase from the initial order to a ready-to-confirm
5     purchase")]
6     public void Enrich(CustomerPurchase cp)
7     {
8        //... interesting stuff here
9     }
10 }

Java and C# are very similar. Here’s the same example, now in Java:

1  package acme.documentation.annotations;
2
3  /**
4 * Marks this place in the code as a point of interest
worth listing on a sightseeing map.
5 */
6
7  @Retention(RetentionPolicy.RUNTIME)
8  @Documented
9  public @interface PointOfInterest {
10
11  String description() default "";
12  }

And now we can use it as follows:

1  @PointOfInterest("Key calculation")
2  private double pricing(ExoticDerivative ...){
3  ...

An alternative naming could look like this:

1  @SightSeeingSite("This is our secret sauce")
2  public SupplyChainAllocation optimize(Inventory ...){
3  ...

In C# you would use the custom attribute as follows:

1 public class CoreConceptAttribute : Attribute
2
3 [CoreConcept("The main steps of enriching the Customer
4 Purchase from the initial order to the ready to ship
5 Shipment Request")]

The wording is up to you, and you can use one generic annotation with a generic name like PointOfInterest and add the parameter Key calculation to tell precisely what it is about. Alternatively, you could decide to create one annotation for each kind of point of interest:

1  @KeyCalculation()
2  private double pricing(ExoticDerivative ...){
3  ...

Creating a Guided Tour

In the example shown in this section, the idea is to take a newcomer by the hand along the complete chain of processing of an incoming transaction, from the event listener on a message queue down to storing the outgoing report to the database. Note that even though it strictly separates the domain logic and the infrastructure logic, this guided tour spans both business logic elements with elements of the underlying infrastructure in order to give a complete picture of a complete execution path.

This guided tour currently has six steps, each of which is anchored on a code element that can be a class, a method, a field, or a package.

This example uses the custom annotation @GuidedTour with some parameters:

  • The name of the guided tour: This is optional if there is only one tour, or if you prefer one annotation by guided tour, like @QuickDevTour.

  • A description of the step in the context of this tour: This is in contrast to the Javadoc comment on the element, which describes the element for what it is and not necessarily for how it is used.

  • A rank: The rank can be expressed as a number or anything comparable, and it is used to order the steps when presenting them to the visitor.

Here’s an example of a guided tour:

1 /**
2 * Listens to incoming fuel card transactions from the
3 * external system of the Fuel Card Provider
4 */
5 @GuidedTour(name = "Quick Developer Tour",
6     description = "The MQ listener which triggers a full
7 chain of processing", rank = 1)
8 public class FuelCardTxListener {

It then goes through other steps, until the last one:

1 @GuidedTour(name = "Quick Developer Tour",
2     description = "The DAO to store the resulting
3     fuel card reports after processing", rank = 7)
4 public class ReportDAO {
5
6 public void save(FuelCardTransactionReport report){
7 ...

If you wanted to provide a simple selection of points of interest only for an audience of developers, you could stop here and rely on the user to do a search of the custom annotation to get the IDE to present the tour as a whole:

1  Search results for 'flottio.annotations.GuidedTour'
6 References:
2
3  flottio.fuelcardmonitoring.domain - (src/main/java/l...)
4  - FuelCardMonitoring
5  - monitor(FuelCardTransaction, Vehicle)
6  - FuelCardTransaction
7  - FuelCardTransactionReport
8
9  flottio.fuelcardmonitoring.infra - (src/main/java/l...)
10 - FuelCardTxListener
11 - ReportDAO

The recap is all here, but it is not pretty, and there is no ordering. This could be enough for a small list of the main landmarks that a developer can explore in any order desired, though, so do not discount the value of the integrated approach, as it is much simpler and may be more convenient than more sophisticated mechanisms.

However, this first case is not enough for a guided tour that is meant to be visited in order, from start to finish. So the next step is to create a living document out of it so that it is a living guided tour.

Creating a Living Guided Tour

Going further than in the preceding section, you can create a little mechanism to scan the code base to extract the information about each step of the guided tour and produce a synthetic report of the guided tour in the form of a ready-to-follow and ordered itinerary.

FuelCardTxListener

The MQ listener which triggers a full chain of processing.

Listens to incoming fuel card transactions from the external system of the fuel card provider.

FuelCardTransaction

The incoming fuel card transaction.

A transaction, between a card and a merchant, as reported by the fuel card provider.

FuelCardMonitoring

The service that takes care of all the fuel card monitoring.

Monitoring of fuel card use to help improve fuel efficiency and detect fuel leakages and potential driver misbehaviors.

monitor(transaction, vehicle)

The method that does all the potential fraud detection for an incoming fuel card transaction.

1  public FuelCardTransactionReport monitor(FuelCardTransaction
2  transaction, Vehicle vehicle) {
3     List<String> issues = new ArrayList<String>();
4
5     verifyFuelQuantity(transaction, vehicle, issues);
6     verifyVehicleLocation(transaction, vehicle, issues);
7
8  MonitoringStatus status
9     = issues.isEmpty() ? VERIFIED : ANOMALY;
9  return new FuelCardTransactionReport(
10    transaction, status, issues);
11 }

FuelCardTransactionReport

The report for an incoming fuel card transaction.

The fuel card monitoring report for one transaction, with a status and any potential issue found.

ReportDAO

The DAO to store the resulting fuel card reports after processing.

Note that in this guided tour, each title is a link to the corresponding line of code on GitHub. When the point of interest is a method (like the monitor() method), I include its block of code verbatim from GitHub, for convenience. In a similar fashion, when the point of interest is a class, I might include an outline of the nonstatic fields and the public methods if I find it convenient and relevant to the focus of the guided tour.

This living guided tour document is generated in Markdown, for convenience. Then a tool like Maven site (or sbt or any other similar tool) could do the rendering to a web page or in any other format. An alternative, as shown here, is to use a Java-Script library to render the Markdown in the browser, which requires no additional toolchain.

An alternative to using strings in the guided tour annotations would be to use enums, which take care of naming, descriptions, and ordering at the same time. However, this moves the descriptions of each step of the guided tour from the annotated code to the enum class, as you can see here:

1 public enum PaymentJourneySteps {
2    REST_ENDPOINT("The single page app call this endpoint with
the id of the shopping cart"),
3    AUTH_FILTER("The call is being authenticated"),
4    AUDIT_TRAIL("The call is audit-trailed in case of dispute
and to comply to regulation"),
5
6    PAYMENT_SERVICE("Now enter the actual service to perform
the job"),
7
8    REDIRECT("The response from the payment is sent through a
redirect");
9
10 private final String description;
11 }

This enum is then used as the value in the annotation:

1  @PaymentJourney(PaymentJourneySteps.PAYMENT_SERVICE)
2  public class PaymentService...

The Implementation of the Guided Tour

In Java you can use a Doclet-like library called QDox to do the implementation grunt work, which allows you to access the Javadoc comments. If you don’t need Javadoc, then any parser and even pain reflection could work.

QDox scans every Java file in src/main/java, and from the collection of parsed elements, you can do the filtering by annotation. When a Java element (class, method, package, and so on) has the custom GuidedTour annotation, it is included in the guided tour. You can extract the parameters of the annotation and also extract the name, Javadoc comment, line of code, and other information (including the code itself, when necessary). You can then turn all that into fragments of Markdown for each step, stored in a map sorted by the step rank criteria. This way, when the scan is done, you can render the whole document by concatenating all the fragments in the rank ordering.

Of course, the devil is in the details, and this kind of code can quickly grow hairy, depending on how demanding you are with respect to the end result. Scanning code and traversing the Java or C# metamodel is not always nice. In the worst case, you could even end up with a visitor pattern. I expect that more mainstream adoption of these practices will lead to new small libraries which will take care of most of the grunt work for common use cases.

A Poor Man’s Literate Programming

A guided tour is reminiscent of literate programming but in reverse: Instead of having prose with code, a guided tour has code with prose. For a sightseeing map, you only have to select the points of interest and group them by big themes. For a guided tour, you need to devise a linear ordering of the code elements. In literate programming, you also tell a linear story that progresses through the code and ends up with a document explaining the reasoning and the corresponding software at the same time.

A guided tour or sightseeing map is not just a documentation concern but also a way to encourage continuous reflection on your own work as you do it. It would therefore be a good idea to document a guided tour as soon as you are building the early walking skeleton of the application. This way, you will benefit from the thoughtful effect of doing the documentation at the same time of doing the work.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020