Bookfriend report
Upcoming SlideShare
Loading in...5
×
 

Bookfriend report

on

  • 627 views

Mobile phones and smartphones are now ubiquitous in everyday life and the new and innovative aspects of the web are finally able to be realized on mobile devices. Bookfriend is a mobile phone mashup ...

Mobile phones and smartphones are now ubiquitous in everyday life and the new and innovative aspects of the web are finally able to be realized on mobile devices. Bookfriend is a mobile phone mashup application developed for Android that creates a companion guide to any book and allows users to find out information about books and explore other books that they may enjoy.

Statistics

Views

Total Views
627
Views on SlideShare
627
Embed Views
0

Actions

Likes
0
Downloads
7
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Bookfriend report Bookfriend report Document Transcript

    • UNIVERSITY OF MANCHESTER School of Computer Science Third Year Project Report Where did this book come from? Carrie Louise Hall Internet Computing BSc May 4th 2011 Supervisor: Dr Alvaro A A FernandesMobile phones and smartphones are now ubiquitous in everyday life and the new andinnovative aspects of the web are finally able to be realized on mobile devices. Bookfriend is amobile phone mashup application developed for Android that creates a companion guide to anybook and allows users to find out information about books and explore other books that theymay enjoy.
    • AcknowledgementsI would like to thank my friends and family, whose continuous support and encouragement helpedme throughout.I would also like to thank the various developers who work on the APIs used within the project,especially James Schellenberg from Bibliotravel who gave me full unlimited access to their data.Most importantly I would like to thank my supervisor Alvaro Fernandes who has supported me andgiven me confidence throughout the project, as well as inspiring and contributing to the applicationitself.Carrie Louise Hall Chapter 1 | Page 2
    • Table of ContentsAcknowledgements................................................................................................................................. 2Table of Contents .................................................................................................................................... 3List of Figures .......................................................................................................................................... 7Chapter 1. Introduction to the project ................................................................................................... 9 1.1 The Project .................................................................................................................................... 9 1.1.1 Application features ............................................................................................................... 9 1.2 Previous work................................................................................................................................ 9 1.3 Objectives...................................................................................................................................... 9 1.4 Success Criteria ........................................................................................................................... 10 1.5 Report Structure ......................................................................................................................... 10Chapter 2. Background ......................................................................................................................... 11 2.1 Mashups ...................................................................................................................................... 11 2.1.1 Challenges of mashups ........................................................................................................ 12 2.2 Web Services and APIs ................................................................................................................ 13 2.2.1 SOAP..................................................................................................................................... 13 2.2.2 REST...................................................................................................................................... 14 2.3 Android ....................................................................................................................................... 16 2.3.1 Overview .............................................................................................................................. 16 2.3.2 Architecture ......................................................................................................................... 17 2.3.3 Features ............................................................................................................................... 17 2.3.4 Applications.......................................................................................................................... 18 2.3.5 Android location services ..................................................................................................... 20 2.3.6 Versions................................................................................................................................ 21 2.4 Current mashup examples .......................................................................................................... 21 2.4.1 Book Mashups ...................................................................................................................... 21 2.4.2 Android Mashups ................................................................................................................. 22Chapter 3. Requirements ...................................................................................................................... 23 3.1 General Description .................................................................................................................... 23 3.1.1 Product perspective ............................................................................................................. 23 3.1.2 Product functions ................................................................................................................. 23 3.1.3 User characteristics .............................................................................................................. 25 3.1.4 Assumptions and dependencies .......................................................................................... 25Carrie Louise Hall Chapter 1 | Page 3
    • 3.2 Specific requirements ................................................................................................................. 25 3.2.1 External interfaces ............................................................................................................... 25 3.2.2 System requirements ........................................................................................................... 25 3.2.3 Performance requirements.................................................................................................. 25 3.2.4 Usability requirements......................................................................................................... 25 3.2.5 Reliability requirements ....................................................................................................... 26 3.2.6 Supportability requirements ................................................................................................ 26 3.2.7 Speed Requirements ............................................................................................................ 26 3.3 Data sources & APIs .................................................................................................................... 26 3.3.1 List of data sources .............................................................................................................. 26 3.3.2 Diagram ................................................................................................................................ 28 3.4 Summary ..................................................................................................................................... 28Chapter 4. Design .................................................................................................................................. 29 4.1 Developing for mobile devices.................................................................................................... 29 4.1.1 Hardware considerations ..................................................................................................... 29 4.1.2 Android Best Practices ......................................................................................................... 29 4.1.3 Compatibility ........................................................................................................................ 31 4.1.4 Screen Types ........................................................................................................................ 31 4.1.5 Android User Interface Guidelines ....................................................................................... 32 4.1.6 Guidelines used within bookfriend ...................................................................................... 32 4.2 Designs for bookfriend ................................................................................................................ 33 4.2.1 Logo and icon ....................................................................................................................... 33 4.2.2 Font ...................................................................................................................................... 34 4.2.3 Wireframe ............................................................................................................................ 34 4.2.4 Photoshop design................................................................................................................. 35Chapter 5. Implementation................................................................................................................... 36 5.1 Development Process ................................................................................................................. 36 5.1.1 Development environment .................................................................................................. 36 5.1.2 Agile Development ............................................................................................................... 37 5.1.3 Phases of development ........................................................................................................ 38 5.2 Architecture ................................................................................................................................ 41 5.2.1 Project hierarchy .................................................................................................................. 41 5.2.2 Package diagram .................................................................................................................. 42 5.2.3 Core components class diagram .......................................................................................... 42Carrie Louise Hall Chapter 1 | Page 4
    • 5.2.4 Helper components class diagram ....................................................................................... 43 5.2.5 Android classes .................................................................................................................... 43 5.3 Object-oriented design ............................................................................................................... 44 5.3.1 Design Patterns .................................................................................................................... 44 5.4 Implementation Details .............................................................................................................. 48 5.4.1 Retrieving data from a data source ..................................................................................... 48 5.4.2 Searching for a book ............................................................................................................ 49 5.4.3 Finding book locations ......................................................................................................... 50 5.4.4 Ensuring data quality ........................................................................................................... 51 5.4.5 System reliability and fallback ............................................................................................. 52 5.4.6 Graceful degradation ........................................................................................................... 53 5.4.7 Cleaning data ....................................................................................................................... 53 5.4.8 Ensuring compatibility across devices ................................................................................. 54 5.5 Improving the user experience ................................................................................................... 55 5.5.1 Finding one particular book ................................................................................................. 55 5.5.2 Speed of results.................................................................................................................... 56Chapter 6. Final result ........................................................................................................................... 59 6.1 Walkthrough ............................................................................................................................... 59 6.2 Application release ..................................................................................................................... 67 6.2.1 Android statistics.................................................................................................................. 67 6.2.2 Google Analytics................................................................................................................... 67 6.2.3 Survey................................................................................................................................... 67Chapter 7. Testing ................................................................................................................................. 68 7.1 Testing Methodology .................................................................................................................. 68 7.1.1 Testing environment ............................................................................................................ 68 7.1.2 Verification and Validation .................................................................................................. 69 7.1.3 Testing Strategy ................................................................................................................... 69 7.2 Tests undertaken ........................................................................................................................ 70 7.2.1 Incorrect user input ............................................................................................................. 70 7.2.2 ISBN validation ..................................................................................................................... 70 7.2.3 Scan barcode ........................................................................................................................ 70 7.2.4 Web-service failure .............................................................................................................. 70 7.2.5 Web connection unavailable ............................................................................................... 70 7.2.6 Web-service missing data .................................................................................................... 70Carrie Louise Hall Chapter 1 | Page 5
    • 7.2.7 Reliability of all APIs ............................................................................................................. 70 7.2.8 Retrieval of books ................................................................................................................ 70 7.2.9 Frequency of results............................................................................................................. 71 7.2.10 Operating system ............................................................................................................... 71Chapter 8. Conclusions ......................................................................................................................... 72 8.1 Project Achievements ................................................................................................................. 72 8.2 Lessons learned ........................................................................................................................... 72 8.3 Further work ............................................................................................................................... 72 8.4 Final Remarks .............................................................................................................................. 73Glossary ................................................................................................................................................. 74Appendix 1. BookListAdapter................................................................................................................ 78Appendix 2. Overlay for book locations ................................................................................................ 79Appendix 3. Image fallback ................................................................................................................... 81Appendix 4. XML layout for main screen .............................................................................................. 82Appendix 5. AsyncTask example ........................................................................................................... 83Appendix 6. BookmoochHelper class.................................................................................................... 84Appendix 7. Android statistics .............................................................................................................. 86 Platform version................................................................................................................................ 86 Device................................................................................................................................................ 86 Country ............................................................................................................................................. 87Appendix 8. Google Analytics ............................................................................................................... 88 Top Content ...................................................................................................................................... 88 Screen Resolution ............................................................................................................................. 88 Visitor Loyalty.................................................................................................................................... 89 Map Overlay ...................................................................................................................................... 89Appendix 9. Survey ............................................................................................................................... 90Appendix 10. Survey results .................................................................................................................. 92Appendix 11. Google API test class ....................................................................................................... 95Appendix 12. Testing results ................................................................................................................. 96Appendix 13. Project Plan ..................................................................................................................... 98References ............................................................................................................................................ 99Carrie Louise Hall Chapter 1 | Page 6
    • List of FiguresFigure 1: Types of mashup on Programmable Web.............................................................................. 12Figure 2: SOAP example of querying a phonebook application............................................................ 13Figure 3: REST example of querying a phonebook application ............................................................ 14Figure 4: A more complex REST query .................................................................................................. 14Figure 5: XML representation of a ‘File’ menu ..................................................................................... 15Figure 6: JSON representation of a ‘File’ menu .................................................................................... 16Figure 7: Graph showing the percentage of mobile subscribers since October 2009 .......................... 16Figure 8: Android component stack diagram ....................................................................................... 17Figure 9: Calling an Activity ................................................................................................................... 18Figure 10: Some of the Views used within Android .............................................................................. 19Figure 11: XML resources in Android .................................................................................................... 19Figure 12: Diagram representing the major components of an Activity .............................................. 20Figure 13: Android MapView with customized Overlay ....................................................................... 20Figure 14: Timeline of Google Android SDK versions ........................................................................... 21Figure 15: Use case diagram for the bookfriend application ................................................................ 24Figure 16: APIs used and functions they perform ................................................................................ 28Figure 17: Application Not Responding (ANR) dialog ........................................................................... 30Figure 18: How the Android platform maps screen densities and screen sizes ................................... 31Figure 19: Launcher icons used by Android book applications ............................................................ 33Figure 20: The bookfriend logo ............................................................................................................. 33Figure 21: The bookfriend launcher icons ............................................................................................ 33Figure 22: A menu screen and home screen and with the bookfriend launcher icon displayed ......... 34Figure 23: Font used in the bookfriend application.............................................................................. 34Figure 24: Wireframe design................................................................................................................. 34Figure 26: Version 1 of the interface design ......................................................................................... 35Figure 25: Final design of the interface ................................................................................................ 35Figure 27: The AVD Manager’s Available Packages panel which shows SDK components .................. 36Figure 28: Agile development process .................................................................................................. 37Figure 29: Packages used within the bookfriend application ............................................................... 42Figure 30: Core components class diagram .......................................................................................... 42Figure 31: Helper components class diagram ....................................................................................... 43Figure 32: Android classes .................................................................................................................... 43Carrie Louise Hall Chapter 1 | Page 7
    • Figure 34: Diagram to show how the Façade separates the application from the interface ............... 46Figure 33: The code to create the BookMashup Façade class within the application ......................... 46Figure 35: Adapter pattern in the bookfriend application ................................................................... 47Figure 36: Diagram representing the Observer pattern ....................................................................... 47Figure 37: The bookfriend customized list view ................................................................................... 48Figure 38: Entering a book .................................................................................................................... 49Figure 39: Diagram to show barcode scanning ..................................................................................... 49Figure 40: Android MapView for searching books by location ............................................................. 50Figure 41: Marker images for displaying book locations, publisher location and author birthplace ... 50Figure 42: Activity diagram showing flow of Twitter data .................................................................... 51Figure 43: Images retrieved from the Bookmooch, Goodreads, and Google API (shown to scale) ..... 52Figure 44: List of options with no Movies option ............................................................................... 53Figure 45: Diagram showing XML layout for bookfriend main screen ................................................. 55Figure 46: Class diagram of the BookmoochHelper and ApiConnector class ....................................... 58Carrie Louise Hall Chapter 1 | Page 8
    • Chapter 1. Introduction to the projectThis chapter will give an introduction to the aim and objectives of the project, and highlight workundertaken in the subject area.1.1 The ProjectThe proposal for this project was to develop an Android mobile mashup application that creates, on-the-fly, a companion guide to any book. It is a mashup application which means the information isretrieved from several web resources about books, such as reviews, characters and synopses, and ispresented to the user as a concise and homogeneous source. These resources may be professionallywritten but the primary source of information will come from user-generated data.1.1.1 Application featuresA list of terse high-level system features are often included as part of an introductory Visiondocument to a project [1]. Usually these lists are less than 10 items and highlight the noteworthyfeatures of a project from a user’s point of view.The Android application, named bookfriend, allows a user to:  Read book plots, quotes and genres  Read book reviews  Explore the author information including biography, images of the author and other books  Find tweets about the book, film adaptations and awards won  Find characters and places mentioned within a book  Explore other books by genre, publisher and location  Scan barcodes of books1.2 Previous workThe project builds from a similar project done several years ago for a web platform, but the flexibilityof the project allowed for different motivations and results. Using a web platform it is possible todisplay a lot of information of varying quality whereas on a mobile device it is important that theinformation about a book is generally correct, as there is limited screen size and connection speed.1.3 ObjectivesThe main objectives of the project were to: 1. Create a useful Android application that finds previously unknown information about any book including: o Author information o Book reviews and other feedback o Exploration of other books 2. Release the bookfriend application for public use in order to gather feedback from real users.Carrie Louise Hall Chapter 1 | Page 9
    • 1.4 Success CriteriaThe following list of criteria is used to rate the success of the bookfriend application:  The application can be installed from the Android market onto any Android device.  The application allows users to search for books and provides some information about any given book.  The application satisfies the functional and non-functional requirements specified in this document.1.5 Report StructureChapter 1 discusses the aims and objectives of the project.Chapter 2 explores the technologies used within the project and some examples of existingapplications.Chapter 3 provides the detailed requirements of the project and lists the data sources.Chapter 4 is involved in the graphical design of the application by following best practices.Chapter 5 explains the details of the implementation and structure of the application and project.Chapter 6 demonstrates the application with screenshots.Chapter 7 discusses the testing approaches and techniques, the tests undertaken and the results ofthese tests.Carrie Louise Hall Chapter 1 | Page 10
    • Chapter 2. BackgroundThis chapter gives the context of the application by discussing what mashups are, why they arepopular, and how they are created. It also provides background knowledge about the Androidplatform and presents some examples of mashups both on the web and on mobile devices.2.1 MashupsThe term ‘mashup’ originates in music and is used to describe remixing songs to create new piecesof work [2].IBM define mashups as “an exciting genre of interactive Web applications” [3] that combinecomplimentary information from multiple sources [4] and present it in a new and innovative way. Itis this unique presentation that makes mashups valuable rather than the data itself [5].The fundamental steps undertaken to create mashups are [6]: 1. Extract data from a source web site 2. Translate data into a meaningful format 3. Send data to destination sourceThe data obtained for use in a mashup is typically obtained from publicly available (and often free)web services, XML feeds, or screen-scraping.Maps are the most common form of mashup (see Figure 1). Housingmaps1 is an example of amashup which uses a Google map to display properties for sale or rent. These properties areretrieved from a website called Craigslist2, which is an online community containing classifiedadvertisements.Mashups have been labelled as the fastest growing eco-system on the web [7] because of thecombination of the rapidly increasing number of web services published by content providers andthe number of mashups made available using these services. In 2010 the growth of APIs doubled;mainly with the introduction of new social networking APIs such as Facebook creating an API fortheir data and Twitter inspiring developers to develop APIs based on sentiment analysis and socialnetworking.Often mashups are developed to solve a problem, which may explain why they are popular withgeneral web users. Some examples of this include DealMine3 which mashes up data from severaldiscount and reward sites into a comparison shopping API, and Busalert4 which is a real-time trackerservice for bus tracking in Kings County, Washington.1 http://www.housingmaps.com2 http://www.craigslist.com3 http://www.dealmine.com4 http://www.busalert.meCarrie Louise Hall Chapter 2 | Page 11
    • ProgrammableWeb5 is a directory of mashups and APIs. It contains nearly six thousand mashupswith an average of 2.8 mashups being added every day. Mapping mashups (i.e. mashups that usemaps as a way of displaying data) account for 33% of these. The diagram in Figure 1 shows thebreakdown of mashups listed on ProgrammableWeb. Figure 1: Types of mashup on Programmable WebA study of Programmable Web mashups show that mashup developers tend to build mashups froma small number of popular services rather than a wide range of specialized functions [2].2.1.1 Challenges of mashupsMashups raise new challenges and problems that need to be considered [8] such as the lack ofstandardized approaches to architecture and design. Developers have cited the following problemareas with mashups; namely data quality, the reliability of the API, documentation, coding details,legality and semantic meaning [9].Data qualityThis is arguably the biggest challenge that mashup developers face when creating a mashup andrefers to the data accuracy and completeness as well as semantic meaning, i.e. the real-worldmeaning of a phrase or word [10]. An example of this is when finding results for the search term‘apple’. This term is ambiguous and without any contextual information it is impossible for a mashupto determine if the user is looking for information regarding the company or the fruit. This problemis amplified in a mashup as data is not usually pre-processed or stored by the mashup creator.API reliabilityReliability refers to problems with authentication and performance degradation, as well as a relianceon the API creator’s priorities and decisions for future development as the operations available maynot be sufficient. Changes to an API that are not backwards-compatible (e.g. the removal of anoperation) will cause disorder within a mashup that relies on this functionality.DocumentationThe lack of documentation within APIs is apparent. The reason for this could be that it is expectedthat the user of an API is an expert, that is, they are developers that know how to programapplications and know what the general function of the API is [11]. To learn an API, sometimes theonly source available is the documentation written by the API creator. Examples of working code is agood way to inform users how to call particular functions and is a feature desired by mashupdevelopers [9].5 http://www.programmableweb.comCarrie Louise Hall Chapter 2 | Page 12
    • Coding detailsThere can be a large learning curve to develop tools that work with APIs, regardless of the languagethe application is implemented in. Mashups compile data from many different sources which canincrease the complexity in the code, both for each individual API and when integrating the sources.LegalityWeb services and APIs come with terms and conditions of use that can vary dramatically. Often it isin the conditions of a free API that the services created using the data must be available toconsumers free of charge as well. This raises questions about the profit potential of mashups thatrely on these APIs. Often advertising is included in order for developers to profit from mashupapplications, including ‘mapvertising’ which is placing sponsored ads onto map screens [12]. Otherterms of use include the need to include a company name or logo on any screen that data from thatservice appears (Goodreads include this in their terms) or that data from competitors is prohibitedon the same page . More specific terms can also be provided such as not requesting data more thanonce a second, or not storing data for more than 24 hours (if allowed at all). These terms can be veryrestrictive to mashup developers.2.2 Web Services and APIsThe data that powers mashups often comes from Application Programming Interfaces (APIs). WebAPIs facilitate data exchange between applications by providing an interface to request data andretrieve a response [4]. Many major companies such as Google, Amazon and eBay have providedfree APIs to their data [2].2.2.1 SOAPSimple Object Access Protocol (SOAP) is an XML-based protocol for exchanging information and isused within web services [13]. A SOAP message must have a root Envelope element and contain aBody element. It can also contain a Header element to describe application-specific informationsuch as authentication. It is platform and language independent and is a W3C recommendation.In the SOAP example in Figure 2 the task is to query a phonebook application for the details of auser. The user id is provided and the type of request (GetUserDetails) is an application specific XMLelement. The rest of the request is used to declare the message as a SOAP message and to declareunique namespaces. <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body pb="http://www.acme.com/phonebook"> <pb:GetUserDetails> Application <pb:UserID>12345</pb:UserID> specific </pb:GetUserDetails> elements </soap:Body> </soap:Envelope>Figure 2: SOAP example of querying a phonebook applicationCarrie Louise Hall Chapter 2 | Page 13
    • 2.2.2 RESTNowadays it is more common to develop web services and APIs by using Representational StateTransfer (REST). REST is an architectural style for distributed web applications and provides a set ofconstraints and principles [14, 15]. REST services are focused around resources, which are uniqueand global (e.g. a URI in HTTP), and communication between client and server to identify andmanipulate these resources. The constraints and principles of REST are [15]: 1. REST architecture must be a client-server architecture to promote separation of concerns between the user interface and data storage, and also allows components to scale independently. 2. REST architecture is stateless so each request must contain all the necessary information to fulfil the request as no session state is stored. This improves the reliability and scalability of the architecture. 3. REST architecture can utilise a cache to improve network efficiency. 4. REST architecture has a uniform interface between components which is more efficient for use on the Web as information is transferred in a standardised format rather than an application-specific one. 5. REST architecture is layered to further improve independence and scalability as clients are not aware of which server or cache they are connected to.A RESTful web service uses these principles of REST over HTTP and is a collection of resources with adefined URI and set of operations. These CRUD operations in HTTP are GET, PUT, POST and DELETE.The GET operation (read) is the most common and has no side-effects on the data. The clientinitiates requests using these operations and a response can be sent back in several formats, usuallyXML or JSON.REST is more lightweight than SOAP and it can be argued that there is no functionality that webservices using SOAP can achieve that REST cannot [16].Many APIs use REST, including Amazon, Twitter and Flickr. It has the advantage of being simple toimplement in any language, is scalable, and is platform and language independent.The previous example of querying a phonebook looks a lot more straight-forward using REST as itdoes not require any of the XML elements required to process a SOAP request. In essence, a RESTrequest is a URI to a desired resource.http://www.acme.com/phonebook/UserDetails/12345Figure 3: REST example of querying a phonebook applicationA GET request is sent to this URL and is easy to test by entering the URL into a browser.More complex queries are made easily by appending parameters to the URL, e.g.http://www.acme.com/phonebook/UserDetails?fName=John&lName=DoeFigure 4: A more complex REST queryCarrie Louise Hall Chapter 2 | Page 14
    • XMLAs previously mentioned, REST responses can be in XML. XML is a meta-markup language for textdocument markup [17] and is a way of improving informational structure and adding meaning todata, and can be validated. Furthermore, parsers can be used to interpret the information stored inXML which can be used to translate information from a document into aspects of an application.The following code example is an XML document for a File menu within an application. Data isspecified in the form <tag>value</tag>. XML is hierarchical and needs to be properly nested. Inthis example there are three items - new, open and close - and each item contains a title and anaction. <?xml version="1.0" ?> <root> <menu>File</menu> <commands> <item> <title>New</value> <action>CreateDoc</action> </item> <item> <title>Open</value> <action>OpenDoc</action> </item> <item> <title>Close</value> <action>CloseDoc</action> </item> </commands> </root>Figure 5: XML representation of a ‘File’ menuJSONAnother response format popular with web mashups is Javascript Object Notation (JSON), the “fat-free alternative to XML”. JSON is a data-interchange format that is both human and machinereadable [18]. It uses familiar programming conventions but is language independent and the datastructures are supported in all modern programming languages and is supported directly inJavascript [19] .It is built on name/value pairs of ordered lists of values, e.g."key": "value"Lists can be specified by replacing the value with a set of data enclosed in square brackets ([])which in itself can contain lists of data. Complex and deep structures of information still appearslightweight and readable. However, there is much contention in the web community about thehuman readability aspect of JSON [20]. It is argued that JSON is not as readable as XML as the syntaxis familiar only to developers. The counter-argument to this is that human readability should comesecondary to the ease of processing.Carrie Louise Hall Chapter 2 | Page 15
    • The following JSON construct representa the same File menu previously discussed in XML. Each itemis distinguished by using syntax similar to an array; the square brackets are used to specify a list ofitems which contain a title and an action. Individual list elements are separated by a comma. { "menu": "File", "commands": [ { "title": "New", "action":"CreateDoc" }, { "title": "Open", "action": "OpenDoc" }, { "title": "Close", "action": "CloseDoc" } ] }Figure 6: JSON representation of a ‘File’ menu2.3 Android2.3.1 OverviewAndroid is an open source software stack that includes the operating system, middleware, keyapplications, and a set of libraries to assist application development [21]. Android provides an openalternative to traditional smartphones with proprietary operating systems and developers can takefull advantage of the open source framework and powerful SDK libraries [21]. It is this opennesswhich make Android compelling for developers [22] as the data on the device (such as contacts andtext messages) are easily retrievable using the frameworks provided.Android now has the largest percentage of mobile subscribers. Figure 7 shows the growth of mobilesubscribers over the last year and a half.Figure 7: Graph showing the percentage of mobile subscribers since October 2009Carrie Louise Hall Chapter 2 | Page 16
    • 2.3.2 ArchitectureThe components of Android are designed as a stack; the bottom layer is the Linux kernel and the toplayer contains the applications.Figure 8: Android component stack diagramImage available from: http://developer.android.com/images/system-architecture.jpg2.3.3 FeaturesThere are many built-in features to Android and it is out of the scope of this project to list them all.However some of the features that are related to the development of the bookfriend applicationinclude:  Framework APIs for location-based services such as GPS  Map controls within applications including geo-coding  Multimedia hardware control, including recording with the camera  Background applications and processes  SQLite DatabasesMany of these functions, such as Google Maps and background services, are not found in othermobile operating systems.Carrie Louise Hall Chapter 2 | Page 17
    • 2.3.4 ApplicationsAndroid applications are written using Java and XML. The architectural essence of Androidapplications is as follows [21]:  Activity Manager o To control the life cycle of Activities  Views o The user interfaces for Activities  Notification Manager o A mechanism to pass messages to the user unobtrusively  Content Providers o For sharing application data  Resource Manager o To store non-code resources like strings and graphics  Manifest file o Presents essential information about the application to the Android system such as the package name, components, permissions required and libraries used.ActivitiesActivities are the building blocks of Android and form the basis for all of the user interface screens[21] by creating a windows in which the UI elements are placed by using a View. Each activity mustbe registered with the application by declaring it in the application manifest. Moving betweenActivities requires creating an Intent with the name of the class that needs to be loaded, and thecalling the startActivity( ) method to run the new Activity. Intent intent = new Intent(this, SignInActivity.class); startActivity(intent);Figure 9: Calling an ActivityAnother way to start an Activity is to use the startActivityForResult( ) method which takesan extra integer parameter to distinguish where the Activity was called from. This is useful in manyscenarios, for example if an Activity can be started to edit data as well as add data then the integercan represent the action that needs to be performed. Further to this, an integer representing theresult is passed back to the calling Activity once the new Activity ends.Carrie Louise Hall Chapter 2 | Page 18
    • ViewsViews are XML-based layout files and are linked with Activities to create a user interface screen.Android provide many basic types of View including ListView, RelativeLayout, LinearLayoutand GridView.Figure 10: Some of the Views used within AndroidA full list of the Android Views is available at:http://developer.android.com/resources/tutorials/views/index.htmlResourcesTo maintain separation of concerns, non-code resources are separated from the rest of the code.Non-code resources include strings, colours, animations and themes but Android allows custom XMLresources to be externalised as well. Resources are kept in separate XML files, e.g. colors.xml. It iseasier to maintain and modify external resources, and allows different resources to be applied indifferent circumstances. Strings are of particular importance as externalisation allows easylocalisation of an application into other languages. Some examples of resources in Android areshown in Figure 11. <string name="app_name">bookfriend</string> <color name="beige">#ede8dd</color> <style name="LargeText"> <item name="android:textSize">20sp</item> </style>Figure 11: XML resources in AndroidCarrie Louise Hall Chapter 2 | Page 19
    • Diagram of an Android application XML Layout Java code XML Resources Figure 12: Diagram representing the major components of an Activity2.3.5 Android location servicesOne of the major features of Android is the availability of the Google Maps API. To create a map inan application, developers can make use of the MapView layout shown in Figure 13. Maps can becustomized to show marker items by using an Overlay. A GeoPoint is formulated from a longitudeand latitude value of a particular location. To attach a GeoPoint to an Overlay, an OverlayItemis used which is a collection containing a GeoPoint and a message that can be displayed when theitem is clicked. The Overlay can also specify the type of image, called a Drawable, which should beused to display the marker.Figure 13: Android MapView with customized OverlayCarrie Louise Hall Chapter 2 | Page 20
    • 2.3.6 Versions Google often release updates to the Android SDK regularly. At the start of this project the version of Android was 2.1 (revision 2) and it was updated several times during the course of the project. The timeline shown in Figure 14 shows the various releases of Android that were encountered during the project lifespan. January 2010: July 2010: Feb 2011: 2.1 released 2.2 released 2.3.3 releasedOct 2009: May 2010: Dec 2010: Mar 2011:2.0 released 2.1 revision 2 2.3 released 3.0 released Figure 14: Timeline of Google Android SDK versions 2.4 Current mashup examples 2.4.1 Book Mashups Shelfari Shelfari was launched in 2006 and is now owned by Amazon. The creator of Shelfari describes it as a social media site focused on people that read books [23] and it allows people to list book titles, write reviews, recommend books to friends and find like-minded bibliophiles. Its primary data source is Amazon, and gains revenue by using Amazon’s affiliate program to link users of the site back to Amazon to buy the book. Carrie Louise Hall Chapter 2 | Page 21
    • Reading RadarReading Radar takes the New York Times bestseller list data and mashes it with Amazon informationin order to provide the most amount of information about this list of books in one place.2.4.2 Android MashupsProgrammable web only has 16 mashups listed under the Android category, and none of theserelate to books.IceCondorIceCondor is a GeoRSS feed reader for Android which combines locationdata with a Google Map. The data can be retrieved from several socialnetworking sites, or feed URL’s can be manually added. Markers are thenadded to the map and users can click on the marker to see the event.AroundMeThis mashup also uses location as a main theme butAroundMe identifies the user’s position and allowsusers to search for local businesses such as banks orrestaurants. It gathers images from Flickr andPanoramio, videos from YouTube and informationfrom Wikipedia.Carrie Louise Hall Chapter 2 | Page 22
    • Chapter 3. RequirementsThis chapter documents both the functional and non-functional requirements of bookfriend, andspecifies the data sources used to retrieve information.The following section relating to requirements will be formatted according to the IEEE-Std 830-1993structure which provides a list of topics that should be included in a Software RequirementsDocument. It is a generic specification and can be adapted easily to a wide range of projects. Arequirements document is used to describe the services and functions of a system and theconstraints under which the system must operate [24].3.1 General Description3.1.1 Product perspectiveHardwareThe application will run on Android powered devices.SoftwareThe application will be written in Android version 2.1.Note: There were major differences between Android v1 and v2 and the decision was made not tosupport devices that used the v1 SDK. This decision was made as Android publish the percentageof users that use each of the versions of the SDK and less than 12% of devices use v1.6 or lower.MemoryThe application requires up to 3mb of space once installed.3.1.2 Product functionsScenarioA scenario is a set of actions that represents a path through the system [1]. Often they are morehelpful to end-users and stakeholders than function lists as they are easier to relate to [25]. Asuccess scenario for bookfriend is as follows:The user navigates to the application and loads it. They type in a book keyword and press ‘go’. Theyare shown a list of books and select the one that they want to read about. They are shown somebasic information about the book such as the book image, author, plot summary and overall rating.From there they can explore more detailed information such as reviews and characters. The booksthat they explore are saved into a list so that can be retrieved at a later date.Carrie Louise Hall Chapter 3 | Page 23
    • Use case diagramsA use case diagram is used to show the high-level functionality of the system. The features in Figure15 show the features present at the end of implementation.Figure 15: Use case diagram for the bookfriend applicationCarrie Louise Hall Chapter 3 | Page 24
    • 3.1.3 User characteristicsThe users of the bookfriend application are not known explicitly so a wide range of users must beconsidered. This includes users of all age ranges and technical ability.3.1.4 Assumptions and dependenciesIt is assumed that the device has enough memory to store the application and run it, and that thedevice has not been modified in any way that might make it difficult to emulate. The bookfriendapplication also assumes that a web connection is available as without a connection the applicationcannot function.3.2 Specific requirements3.2.1 External interfaces Name of item: Barcode scanner Description of service: To allow the user to scan a barcode of a book Source of input: The camera on the user’s device Accuracy: Provided that the barcode is a valid ISBN, it should be 100% accurate Timing: It should not take more than 3 seconds to find the ISBN once the camera has found the barcode Other information: If the barcode scanner is not installed, the user must be prompted to install it.3.2.2 System requirements 1. The application shall allow users to search for books by author, title, ISBN or keyword 2. The application shall allow the user to scan a barcode 3. The application shall validate all user input to ensure that it can be used within the application3.2.3 Performance requirements 1. The application shall return a response to a search for a book in under one minute 2. There shall not be any memory leak during the application running state 3. Any time-consuming tasks shall be run on the background thread 4. The application shall respond to user interactions within 1 second3.2.4 Usability requirements 1. The application shall be developed based on Google’s user interface guidelines 2. During time-consuming tasks, an animated loading icon shall be shown to show the user that the application is processing 3. The application must show informative messages to the user if any errors or problems occur 4. The interface must be consistent across the different screens within the application 5. The screens within the interface must not take more than 5 seconds for a new user to understand 6. The system shall allow the user to remove books from their recent books listCarrie Louise Hall Chapter 3 | Page 25
    • 3.2.5 Reliability requirements 1. The application shall function as expected when there is an internet connection of any speed 2. The application shall have 95% reliability, i.e. will not fail3.2.6 Supportability requirements 1. The application shall run on Android 2.1 and above 2. The interface for the application shall be able to be translated into other languages3.2.7 Speed Requirements 1. Initial loading should be no more than 3 seconds for the splash page, which should be cancellable on click 2. Response time should be no more than 2 minutes when loading data on a 3G connection 3. Response time should be no more than 1 minute when loading data on a wireless connection3.3 Data sources & APIsDuring the early stages of this project it became clear that there was a lot of information aboutbooks available from various sources, and there was some overlap in the data provided. It wasdecided to integrate many sources in order for the system to gracefully degrade, so that if there is afailure to connect to a source the application will still function.Note: The Amazon API is an obvious source of book information and is missing from thebookfriend application, but as of December 2010 it is not permitted to be used on mobile devices.For more information see the Amazon Product Advertising API terms and conditions available at:https://affiliate-program.amazon.com/gp/advertising/api/detail/agreement.html3.3.1 List of data sourcesGoogle BooksGoogle provide a data API which does not require authentication and includes full-text searches forbooks and retrieves book information, ratings and reviews [26]. It returns book data in XML format.BibliotravelBibliotravel is a website which combines books and travel in order to find books that are writtenabout a particular place. It relies heavily on user input for this information and so the list of books isnot comprehensive but it is steadily growing. Bibliotravel do not have a data API but the developerswere contacted and they provided an RSS feed of all the locations of books with links to the booksthemselves. This made the website accessible to a parser without needing to use screen-scraping.GoodreadsGoodreads is a social networking site for readers. Their API requires a developer key and restrictsrequests of the API to one per second. Additionally, the Goodreads name or logo must appear onany location where their data appears, and data cannot be stored for more than 24 hours. The APIprovides book, author information and reviews in XML or JSON format.Carrie Louise Hall Chapter 3 | Page 26
    • LibraryThingLibraryThing is also a social networking site for readers. The APIs are extensive and include tools tocross reference books, so given an ISBN it is possible to find the title and vice versa. The API requiresa developer key and limit usage to 1000 requests per day. It contains a wide variety of informationabout books and authors that is not found in other sources, such as the author place of birth, awardswon, author education history, and quotations from the book.BookmoochThe only restriction when using the API for Bookmooch is the limit of 10 requests per second. Thesite is a community for exchanging used books and uses Amazon’s Product Advertising API for someof its data. Along with book information, the API provides lists of users who want or have the bookto ‘mooch’. The results are in XML format.ISBNDBThe ISBNDB project is a database of books intended to be used for research by expert individuals,libraries and scientists. The data is heavily cross-linked which allows traversal between authors,publishers and subjects very easily by changing the response formatting variables used in therequest.TwitterApplications that use the Twitter API need to register and receive a developer key. The API is quiteextensive but the for context of this application only the ‘search’ API will be used to find tweetsrelating to books or authors. The guidelines for using Twitter content state that the name of the userwho posted the tweet needs to be included and that the content of the tweet must not be modifiedin any way.FlickrSimilar to the Twitter API, the Flickr API contains a large range of functions but only the ‘search’function for photos is used for this application. The search function allows a free text search andreturns results in XML or JSON format.Carrie Louise Hall Chapter 3 | Page 27
    • 3.3.2 DiagramThe following diagram (Figure 16) shows the APIs used related to the functions that are present inthe bookfriend application.Figure 16: APIs used and functions they perform3.4 SummaryThis chapter specified the requirements and features of the bookfriend application, as well aslisting the data sources used to gather information about books for use in the application.Carrie Louise Hall Chapter 3 | Page 28
    • Chapter 4. DesignThe Design chapter will discuss the issues that are raised when developing mobile applications, anddiscuss the Android guidelines and best practice for application design. The chapter will also reviewthe designs for the bookfriend application.4.1 Developing for mobile devices4.1.1 Hardware considerationsDevelopers for desktop or web applications in recent years have gradually moved away from theidea that hardware is the bottleneck for applications, as hardware is increasingly powerful and lessexpensive. Although there are advanced capabilities of mobile devices including accelerometers,GPS, Wi-fi connectivity, touch-screens and environmental sensors, they are still limited incomparison to desktop computers due to the size of the device and inability of upgrades. Mobiledevices generally have [21]:  Low processing power  Limited RAM  Limited permanent storage capacity  Small screens with low resolution  High costs associated with data transfer  Slow data transfer rates with high latency  Unreliable data connections  Limited battery lifeLow-specificationTo combat some of these potential problems, developers must be aware and optimize code as muchas possible so that applications run quickly. At the start of this project, Android applications wereonly installed to the internal phone memory and did not allow applications to be installed to an SDcard, so applications needed to be as small as possible when compiled. However, Android recentlyupdated their SDK to allow this so compiled size is less of an issue.Low connection speedsMobile devices have an unreliable connection and a wide range of connection speeds [27]. In thisrespect, the portability of mobile devices is both a blessing and a curse to mobile developers.Applications should ensure that if network connections are essential, they will respond within asuitable time. Furthermore applications should be able to handle losing connections in the middle ofa process [21].4.1.2 Android Best PracticesAndroid provide several areas that they believe should be the main considerations for an Androiddeveloper, and this includes guidelines on design best practices. These areas are performance,responsiveness and seamlessness.Carrie Louise Hall Chapter 4 | Page 29
    • PerformanceDesigning for performance ensures that applications are fast and do not waste battery life. Theguidelines that Android provide to improve performance are:  Avoid creating unnecessary objects – garbage collection has a direct impact on user experience  Make methods static if there is no need for access to an object’s fields – this makes invocations 15-20% faster  Avoid getters/setters – instance field lookups are much less expensive than virtual method calls  Use ‘double’ rather than ‘float’ where possible  Use enhanced for-loop syntax, e.g. public void loop( ) { int sum = 0; for ( Foo a : mArray ) { sum += a.mSplat; } }ResponsivenessResponsive applications are those that do not feel sluggish, take a long time to process input, orfreeze for a significant time. If an application does not respond to an input event within 5 secondsthen the Android system will show an Application Not Responding (ANR) dialog (shown in Figure 17).Figure 17: Application Not Responding (ANR) dialogIf the application has time-consuming background processing, to avoid ANR applications shouldshow users that progress is being made, e.g. by using a ProgressBar.Carrie Louise Hall Chapter 4 | Page 30
    • SeamlessnessApplications should interact seamlessly with the Android system. To do this developers should:  Bear in mind that mobile devices are prone to changes in activity at any time, e.g. if a phone call is received. Applications need to save their data and state in such an event  Use threading to perform expensive tasks, Android provide an AsyncTask for this purpose  Keep screens to a minimum, i.e. do not overload a screen  Use system themes where possible in order to maintain consistency across applications4.1.3 CompatibilityThe range and number of Android devices available means a potentially huge audience forapplications [28]. The manifest file of an application can specify the minimum requirements of anapplication so devices that do not meet the requirements will not be able to download theapplication from the Android Market. As previously mentioned, new versions of Android arereleased regularly. Android commit to protecting applications developed for older versions so thatthey are ‘future-proof’.4.1.4 Screen TypesApplications should be intuitive and easy to use when developing an application for a small screen.This can be achieved by reducing the number of controls and prioritizing the most importantinformation.Device screen sizes are separated into the following categories:  Small  Normal  Large  XlargeScreen densities are split into these categories:  ldpi (low)  mdpi (medium)  hdpi (high)  xhdpi (extra high) Figure 18: How the Android platform maps screen densities and screen sizesImage available from: http://developer.android.com/guide/practices/screens_support.htmlCarrie Louise Hall Chapter 4 | Page 31
    • In Android it is possible to provide custom resources, such as images, depending on the screen sizeor screen density. Screen density is based on screen resolution and refers to the spread of pixelsacross the physical width and height of the screen. UI elements on low density screens will appearlarger than on higher density screens.It is important to ensure that all of the layouts used within each screen of the application will scalesuccessfully on differently sized devices. This can be achieved in the XML layouts by following thesebasic principles: 1. Do not specify dimensions of elements in pixels, rather use wrap_content or fill_parent 2. Use density or resolution specific resources 3. Avoid AbsoluteLayout as it enforces fixed positions 4. Use density related pixel sizes for text size4.1.5 Android User Interface GuidelinesIcon DesignAndroid provides some guidelines for designing launcher icons to represent applications on theHome screen. Icons should be:  Front-facing and top-lit  Clean and contemporary  Simplified and appropriate for small screens  Feature a part of an application as a symbolic representation  Feature non-glossy, textured materialAndroid provide images for use in Activities, menus and list items. To ensure consistency, theseimages should be used where possible.4.1.6 Guidelines used within bookfriendThe bookfriend application was written aligned with the guidelines set out earlier in this chapter.Different resources were used to account for multiple screen types, and layouts were generallyRelativeLayout styles which allowed proper scaling of elements. The following baselineassumptions were made to ensure the bookfriend application reached the largest amount of users: 1. The network connection is slow 2. The devices do not have a touchscreen or keyboard 3. The battery life is shortUsing these principles ensures that the application can cope with the ‘worst case’ scenario.Carrie Louise Hall Chapter 4 | Page 32
    • 4.2 Designs for bookfriend4.2.1 Logo and iconThe logo was designed early in the development process and adheres to Android’s icon guidelines.The idea behind it came from the need to show a book to represent the purpose of the application.Other book applications on Android often show an image of a book and it was desired to have anicon that is unique. Some examples of icons used by other books are shown in Figure 19:Figure 19: Launcher icons used by Android book applicationsFigure 20: The bookfriend logoThe launcher icons shown in Figure 21 provide an example of how different icon sizes can beprovided to scale up and down as necessary. These icons represent the application on the homescreen.Figure 21: The bookfriend launcher iconsCarrie Louise Hall Chapter 4 | Page 33
    • Figure 22: A menu screen and home screen and with the bookfriend launcher icon displayed4.2.2 FontThe font used for the logo is Colaborate-Bold which is an OpenType font.Figure 23: Font used in the bookfriend application4.2.3 Wireframe 1. User enters a book title, ISBN or author 2. The system will display the most likely book to the user. In the case of more than one book a list of multiple books will be shown. 3. The system will show results to the user, with some information shown and the rest separated into high level sections.Figure 24: Wireframe designCarrie Louise Hall Chapter 4 | Page 34
    • 4.2.4 Photoshop designThe first design for the application has many of the same features that are found in the currentversion. The theme was brown and beige to connote the idea that the application was about books,and titles were used to separate items of information. The design was updated to make it morereadable and usable by including a home button, making the background lighter, increasing the linespacing and minimising the information displayed on the main screen.Figure 26: Version 1 of the interface design Figure 25: Final design of the interfaceCarrie Louise Hall Chapter 4 | Page 35
    • Chapter 5. ImplementationThe implementation section will discuss the development process and how the work was divided intoiterations. It then highlights the design of the code itself following coding best practices and utilisingdesign patterns. Detailed discussion of some more complex implementation is explored and finallythe project architecture is shown in order to demonstrate how the system components areconnected.5.1 Development Process5.1.1 Development environmentThe Android SDK was installed which comes bundled with an AVD manager tool (Figure 27: The AVDManager’s Available Packages panel which shows SDK components ) which allows downloading ofmultiple platform versions (frequently used for testing) as well as samples and documentation.The project was developed using the Eclipse IDE with an Eclipse plugin called the AndroidDevelopment Tools (ADT). The ADT plugin gives developers a fully integrated environment withinEclipse to create and build Android applications, which includes creating user interfaces, addingAndroid framework components using custom XML editors, debugging applications and exporting.apk files for distribution.Figure 27: The AVD Manager’s Available Packages panel which shows SDK componentsCarrie Louise Hall Chapter 5 | Page 36
    • 5.1.2 Agile DevelopmentAt the beginning of the project it was decided that an agile approach would be more beneficial thana traditional approach for several reasons, namely: 1. There was a high learning curve for Android and using web APIs 2. The likelihood of requirements changing was very high as sources of book data are frequently updated and added 3. The external environment is very fast paced; this refers to updates to the Android SDK, frequency of new applications on the Android market, and changes to the terms and conditions of use for data.Agile development is a method of building software following fundamental principles and acceptsthe idea that changes in projects are common [29].It is ideally suited to small teams that have nofixed upfront requirements.There are many agile methodologies and common guidelines include [29]:  Focus on completing features rather than tasks  Work with change instead of preventing it  Documentation is secondary to working functionality  Time-boxing can be used to ensure work is prioritisedThis project was split into several phases which were tracked using Basecamp6, an online projectmanagement tool which allowed flexible milestones and to-do lists. Requirements Review Design ImplementationFigure 28: Agile development process6 http://basecamphq.com/Carrie Louise Hall Chapter 5 | Page 37
    • 5.1.3 Phases of developmentBefore each iteration, informal planning was undertaken using a whiteboard and the developmenttime was estimated. Often the features were developed independently of the overall project sothere was no instability within the application.Phase 1: Book InputIn this phase the initial Android application is set up and the functionality to search for books inmultiple ways is developedIteration 1: Beginning APIsThe Google Books API is examined using a Java project with the aim of understanding how to send arequest and obtain results from the API.Iteration 2: Book Input PhaseThis phase is the beginning of the Android implementation and involves setting up several screenswhich allow the user to type in the name of a book and have a list of books presented to them byusing the Google Books API code previously written.Iteration 3: Find Books by LocationThe Bibliotravel feed of locations are geo-coded and mapped using a Google Map view in theAndroid application.Iteration 4: Scanning PhaseThe ZXing Android library for scanning barcodes is added and integrated into the Androidapplication.Phase 2: Gathering Book DataUsing a Java project, the different APIs are integrated into a set of basic re-usable components.Iteration 1: Core ComponentsCreation of basic components are implemented such as Book, Review and ImageGallery.Iteration 2: Google integrationBook information from Google is integrated into core components.Iteration 3: GoodreadsInformation from Goodreads is integrated into core components.Iteration 4: Flickr APIInformation from Flickr is integrated into core components.Carrie Louise Hall Chapter 5 | Page 38
    • Phase 3: Integrating Book DataAt this point we have some information about books which needs to be moved to the Androidapplication. During this phase a bridge is created between the API connectors and the screens. Toseparate the components, the façade design pattern is used to create a single point of contactbetween the two sub-systems.Iteration 1: IntegrationAll the core components are added to the Android project and tested to ensure data is stillretrievable.Iteration 2: FaçadeA BookMashup is created with functions to call the API classes. From this point on no calls to the APIclasses are made from within the Android classes.Iteration 3: Calling the FaçadeThe screens which were previously filled with dummy data are populated with information from theAPIs, called through the BookMashup.Iteration 4: TestingThe application is tested on a wide range of books in order to locate and correct any bugs with theAndroid layouts or the back-end functionality.Phase 4: Performance enhancingThe code is evaluated to ensure that it will run quickly and follows best practices.Iteration 1: Background processesTime consuming API calls are moved onto background threads so that the user interface does nothang when data is being retrieved. The data is then fed in as it becomes available meaning the timethe user has to wait for some data is greatly reduced.Iteration 2: RefactoringDuring this iteration the project is refactored to ensure that there is no duplicated or unused code,and any repeated information is abstracting into hierarchies.Iteration 3: Book InputThis phase includes validating ISBN numbers and matching the most likely book to the keyword thatthe user entered, rather than displaying a list of books.Carrie Louise Hall Chapter 5 | Page 39
    • Phase 5: Integration of more APIsMore APIs can be added easily to the project at this stage, as the hierarchy is established and fullyworking, so new APIs simply need a list of elements to retrieve and a place on the screens to displaythe data.Iteration 1: LibraryThing APIInformation from LibraryThing is integrated into core components.Iteration 2: BookMooch APIInformation from BookMooch is integrated into core components.Iteration 3: Data fallbackSeveral sources contain the same information so the system should use other sources if one is notavailable.Phase 6: User InterfaceAt this stage there Is a lot of information about books and a number of screens which are tidied up toensure consistency and evaluated to make sure they are intuitive.Iteration 1: AnalysisThe screen designs were examined and the flow through the screens edited if necessary.Iteration 2: Ensure consistencyThe menu bars, text spacing, margins and buttons must be consistent across screens.Iteration 3: User feedbackWhen a background task is being undertaken the user needs to be informed by unobtrusive meanssuch as loading images.Phase 7: Integration of more APIsThe addition of more APIs is undertaken. As every API is added, the screens are coded to the samestandard as the refactored code, designed to be compatible with the other screens, and tested toensure no inconsistencies surface.Iteration 1: Twitter APIInformation from Twitter is integrated into core components.Iteration 2: ISBNDB APIInformation from ISBNDB is integrated into core components.Carrie Louise Hall Chapter 5 | Page 40
    • 5.2 Architecture5.2.1 Project hierarchyBookfriend src bookfriend Contains the Activities within the Application adapters Contains Adapters for binding data to screens barcode Contains classes to integrate the barcode scanner core Contains basic classes such as Book, or Tweet helpers Contains API connector classes isbn Contains classes to validate ISBN gen Created by Android automatically when built and contains just one file, R.java, which is an index to all of the resources contained within the application. assets Contains the font used for the bookfriend title lib Contains external libraries used by the bookfriend application res drawable Contains images that are independent of screen type drawable-hdpi Contains images for high-definition screens drawable-ldpi Contains images for low-definition screens drawable-mdpi Contains images for medium-definition screens layout Contains the layout XML files for each Activity menu Contains the menu XML files values Contains XML files for non-code resources AndroidManifest.xml The Manifest file for the bookfriend application.Carrie Louise Hall Chapter 5 | Page 41
    • 5.2.2 Package diagramThe following diagram (Figure 29) show the packages used in the bookfriend application. The size ofthe packages in the diagram demonstrate the relative size of each package within the code.Figure 29: Packages used within the bookfriend application5.2.3 Core components class diagramThese components are provide the base for the application and are independent from the Androidfunctionality.Figure 30: Core components class diagramCarrie Louise Hall Chapter 5 | Page 42
    • 5.2.4 Helper components class diagramFigure 31: Helper components class diagram5.2.5 Android classesA class diagram is not appropriate to demonstrate the Android classes because each one representsa screen and they do not communicate with each other. Rather, the next diagram (Figure 32)explains the flow of screens within the application. The yellow stars represent screens that contain acustom adapter which will be explained in the next section.Figure 32: Android classesCarrie Louise Hall Chapter 5 | Page 43
    • 5.3 Object-oriented design5.3.1 Design PatternsDesign Patterns are a named and well known problem/solution pair for any programming context[1]. Named patterns are powerful and succinct yet connote a lot of information [30] and helpdevelopers with various levels of experience to communicate easily. One of the important things tonote about design patterns are that they do not provide exact implementation details, rather theychange the way developers think about problems by providing a set of principles.These principles are called General Responsibility Assignment Software Patterns (GRASP) and arebased upon patterns of assigning responsibility, which help developers to understand object design.The ‘Gang of Four’ (GoF) patterns are a set of 23 named design patterns which build on GRASPprinciples.This next section will first highlight some the GRASP principles that apply to the development of thebookfriend application, and continues to discuss GoF design patterns that were used.Chapter 4 of this report highlighted some Android guidelines for developing responsive and efficientapplications and some of these guidelines contradict those set out by the GRASP principles. TheAndroid guidelines were favoured over these principles when they were in direct contradiction.GRASP principlesInformation ExpertA class should be given responsibility only when they have the information necessary to fulfil theresponsibility.CreatorOnly assign class B the responsibility to create class A when:  B contains / aggregates A  B records A  B closely uses A  B has the initialising data for ALow CouplingDependencies and links between classes should be kept to a minimum so that changes to code makeless impact.High CohesionEach class should be focused on one task so that they are easier to understand and maintain.PolymorphismWhen alternative behaviours are present for a class, assign responsibility using polymorphicoperations that implement a common interface.Carrie Louise Hall Chapter 5 | Page 44
    • Pure FabricationCreate fabricated classes to interface with real-world concept classes when necessary to keepcoupling low and cohesion high.IndirectionAssign intermediate objects the responsibility to mediate between components in order to keepcoupling low.Protected VariationsIdentify points of variation and provide stable interfaces around them. Also known as InformationHiding.GoF design patternsFaçadeFaçades are a common unified interface to a disparate set of classes or subsystems [1]. By using theFaçade Pattern a complex subsystem can be accessed though a single, easy-to-use interface.SingletonFaçades are often accessed via the Singleton pattern and ensures that only one instance of an objectis created. In Java this can be ensured by making the constructor private so that instances of theclass cannot be instantiated. It moves away from the idea that objects need to be passed around andinstead can be accessed globally without creating multiple objects. To do this, the method to returnthe singleton must be static and it can be synchronised so it is thread-safe.AdapterAdapters are used to resolve incompatible interfaces by using Polymorphism to provide a stableinterface.ObserverThe idea of separation of concerns aims to keep the application logic separated from the userinterface. The Observer pattern “defines a one-to-many dependency between objects so that whenone object changes state, all of its dependents are notified and updated automatically” [31].Carrie Louise Hall Chapter 5 | Page 45
    • Decisions for the bookfriend applicationFaçadeThe BookMashup is a Pure Fabrication and was created as a Façade created using a Singleton andpromotes Indirection and Low Coupling between the GUI classes and the core components.The Facade class calls various methods from within the Helper classes to get information aboutbooks. It also performs some more complex functions to organise the data, which keeps the APIclasses Highly Cohesive.An interesting point to note, is the generic Façade pattern encourages lazy initialisation which meansthat the instance is not created until it is requested. Lazy initialisation is preferred as it avoidsexpensive creation work if the instance is never actually accessed. However, eager initialisation wasused for the bookfriend application for the following reasons: 1. The BookMashup instance will always be needed. 2. In eager initialisation an there is no check if the instance is null. private static BookMashup instance = new BookMashup( ); /* Gets the bookmashup instance */ public static BookMashup getInstance( ) { return instance; } private BookMashup( ) { } Figure 33: The code to create the BookMashup Façade class within the application Figure 34: Diagram to show how the Façade separates the application from the interfaceCarrie Louise Hall Chapter 5 | Page 46
    • AdapterThe API class hierarchy is an example of the Adapter pattern. All of the classes are subclasses ofAPIConnector, which is focused on creating and maintaining a connection to a data source. Thisleaves the API classes solely responsible for parsing the response ensuring all classes are HighlyCohesive and guarantees Protected Variations.Traditionally the class names should include ‘Adapter’, i.e. ClassAdapter. However, Adapters areused within Android as a bridge between data and the graphical interface and for this reason the APIclasses were named ‘Helper’, as shown in Figure 35.Figure 35: Adapter pattern in the bookfriend applicationObserverIn the bookfriend application the Android Adapter classes are examples of the Observer patternwhich are Highly Cohesive and provide Protected Variations. Figure 36: Diagram representing the Observer patternAn example of an Adapter using the Observer pattern is for the generation of the list of bookswhen a user enters a keyword. It is possible in Android to simply attach an ArrayList of elementsto a BaseAdapter.Carrie Louise Hall Chapter 5 | Page 47
    • In the bookfriend application more customization was required so that the layout could include abook title, author name, and book image as shown in Figure 37.Figure 37: The bookfriend customized list viewBefore the user enters a keyword, the ListView element below the text box is empty. Once theysend their request, a loading image is shown and the request to the Google Books API is made on abackground thread using Android’s AsyncTask. Once the list of books is retrieved and convertedinto an ArrayList, an event is published to tell the system that the activity has completed whichprompts the ArrayList to be bound to the ListView.The full code listing for an adapter is in Appendix 1.5.4 Implementation DetailsIn this section more details about various aspects of the application will be discussed.5.4.1 Retrieving data from a data sourceAndroid does not provide any classes for an application to retrieve data from a web source.However, as Android is written in Java, it was possible to utilise other Java classes, in this caseHttpUrlConnection, in order to open connections and retrieve data. The connection to a datasource is made only in the APIConnector class mentioned in the Adapter Design Pattern sectionearlier in this chapter. The URLs to connect to are found within the subclasses of APIConnectorand are passed into the superclass, which opens a connection to the URL provided using theopenConnection method. Next, the details of the connection are attached which include the readand connect timeout in milliseconds and the type of HTTP request required which in this case is GET.The connection is then madr.If successful, an InputStream is used to read the response by the data source and aDocumentBuilder parses the request into a Document. The root of the document is saved to avariable which is then parsed by the individual classes that extend the APIConnector. Finally theconnection is closed. Errors during any of these steps are handled by writing errors to the log andreturning an empty result which then will display a notification on the screen.Carrie Louise Hall Chapter 5 | Page 48
    • 5.4.2 Searching for a bookManual entryThe bookfriend application allows the user to search by book keyword, author, or ISBN. In theorythe user can search any combination of keywords and still retrieve the correct results, but thisseparation has been made as there are slight differences in how a search is performed in each case.Figure 38: Entering a bookWhen searching by ISBN the system first validates the ISBN is correct by using the check digit at theend of the ISBN which has an 11-digit range from 0 to 10 (where 10 is represented by X). In thisapplication this check was achieved by including the Apache commons package into the bookfriendproject. Using this validation means that incorrect ISBNs are found very quickly in comparison tosending the ISBN through to the Google Books API, which would return no results for an incorrectISBN.If a book keyword is chosen then the user can enter any keyword including titles, keywords,descriptions and subject and the query is sent as a request to the Google Books API.An author search returns more results initially than a book search and also modifies the request toinclude the inauthor search operator which only searches the author field for a match.http://books.google.com/books/feeds/volumes?q=inauthor:jane+austenBarcode scanningThe functionality for barcode scanning comes from another Android application named BarcodeScanner created by ZXing. Barcode Scanner is not included as part of the core application and due tothis, it is necessary to have the application installed onto the device. The bookfriend applicationfirst checks to see if the application is installed, if it is then it carries on as normal and if not then itprompts the user to install the application. This is shown in Figure 39.Figure 39: Diagram to show barcode scanningCarrie Louise Hall Chapter 5 | Page 49
    • Next the system loads the Barcode Scanner application which runs the camera and the user can scana barcode. The barcode is then sent back to the bookfriend application which validates if it is acorrect ISBN. If it is not correct then a notification is shown to the user. Once a correct ISBN has beenfound, the system queries the Google Books API which returns the book.Searching by locationBibliotravel provided a feed of locations with books for each location they have in their database.Each location has a longitude and latitude value, which was then translated into an AndroidGeoPoint. A MapView was created containing an Overlay with these items and a marker image(shown in Figure 40). Once a location is selected, the application requests the books about thatlocation from Bibliotravel and displays them to the user.Figure 40: Android MapView for searching books by location5.4.3 Finding book locationsMapViews are also used to display locations that are mentioned within a book. These fall under thecategories of book locations, publisher location and author place of birth, and comes from theLibraryThing API as place names e.g. London. To find the latitude and longitude of the location, itmust be geocoded using the Android GeoCoder class. The full code listing for the Overlay can befound in Appendix 2.A separate Overlay was created for each of these categories. Figure 41 shows the marker itemsthat are used to represent these locations.Figure 41: Marker images for displaying book locations, publisher location and author birthplaceCarrie Louise Hall Chapter 5 | Page 50
    • 5.4.4 Ensuring data qualityAs mentioned in Chapter 2, one of the most difficult challenges in creating mashups is ensuring thedata is correct.Unique referencesRather than searching for strings such as author name or book title, more specific identification wasprovided in the request for data. Information about a particular book was referenced by its ISBNwhere possible. An issue was raised whereby if the book was a specific edition then less informationmay be retrieved which is not desirable for items such as plot summary or genres. However, forreviews this was a positive aspect as the reviews were more relevant.In addition to this, some APIs use custom internal ids for elements such as authors. In such ascenario, the id was retrieved and used to formulate a request which led to more accurate results.Searching for tweetsThe Twitter API is unique in the way it searches for matching tweets because it does not search for aphrase, rather it searches for the words in any order. This means that a search for WutheringHeights is likely to find tweets that are related to the book itself, but a search for Lost in a GoodBook may find unrelated tweets. To combat this, the search for tweets in the bookfriend applicationinitially searches for the book and the author, and progressively removes search items until enoughresults have been found. This is shown in Figure 42. Figure 42: Activity diagram showing flow of Twitter dataCarrie Louise Hall Chapter 5 | Page 51
    • 5.4.5 System reliability and fallbackThe system has 8 different data sources and many of these overlap with regard to the content aboutbooks that they provide. An API may fail to retrieve data for several reasons: 1. The API is unavailable due to server-side failure or too many requests by the application 2. No data was available about a particular aspect, e.g. book summaryOne of the key aspects of the bookfriend application is that if a data source is unavailable, othersare used. These are prioritised so that the most reliable data source is the primary source. Thereliability of the data source refers to the quality of the data that is retrieved rather than thelikelihood of unavailability.Book image previewThe order of data sources for a book image preview was 1. Bookmooch 2. Goodreads 3. GoogleThe images retrieved using the Google Books API were found to be physically small and low qualityso were chosen to be the least prioritised image source. However, the larger images fromBookmooch and Goodreads were not available for some books. The images shown in Figure 43 showthe sizes of the images from these data sources.Figure 43: Images retrieved from the Bookmooch, Goodreads, and Google API (shown to scale)This fallback method was achieved in the application by requesting a Bookmooch image first and ifone is found then it is retrieved, else it moves onto the Goodreads API where the process is repeatedand finally the Google API is used. The code snippet is shown in Appendix 3.Carrie Louise Hall Chapter 5 | Page 52
    • Book summaryRetrieving a book summary functions in a similar way to book images. One issue was raised duringthe development whereby sometimes book summaries are retrieved that are not complete or arebadly formatted. More common however was that some summaries are more detailed than othersand it was for this reason it was decided that summaries should be able to be manually changed bythe user. The user can bring up a menu and choose to change the book summary and are thenshown another screen displaying the available summaries, where they can select to save thatsummary as the book summary. If the book is retrieved again through the recent books menu thenthe updated summary is shown.5.4.6 Graceful degradationThere are some aspects to the bookfriend application that have only one source of information, suchas awards and film adaptations of books from LibraryThing. If this information is not available abouta book it may be due to a failed connection or the book itself may not have any of this data. In eitherevent, the system does not show the link in the list to avoid confusion with the user.Figure 44: List of options with no Movies option5.4.7 Cleaning dataAt various stages when running the application and retrieving information, data needs to betransformed so it is in a usable format.User inputThe user input needs to be trimmed of any extra whitespace and spaces must be converted into plussymbols ready for the transformation into a valid request to the Google Books API. A request ismade to the following URL, where bookToSearch is replaced by the converted string. http://books.google.com/books/feeds/volumes?q= + bookToSearch + "&start- index=" + startIndex + "&max-results=" + maxResults;Carrie Louise Hall Chapter 5 | Page 53
    • Data retrievedSome of the information retrieved using the LibraryThing API was contained within a single elementand it was necessary to format these strings in order to style them in a readable arrangement. Theextract below is an example of some strings retrieved for awards that a book has won.Waterstones Books of the Century (1997, No 24)ALA Best books (1979)Guardian top 100 (Sci fi and fantasy)The format is not consistent but a more readable format would be to move the information withinbrackets to a new line. The following examples are of film adaptations that contain a similar issue.Hitchhikers guide to the Galaxy (1981 | tt0038937)Hitchhikers guide to the galaxy (1984 | VG | tt8988348 )The bookfriend application splits the string at the brackets and displays this information on the linebelow. In the case of film adaptations, the text in the brackets before the first pipe symbol (|) areshown. The final result is:Waterstones Books of the Century1997, No 24ALA Best books1979Guardian top 100Sci fi and fantasyALA Best books1979Hitchhikers guide to the Galaxy1981Hitchhikers guide to the galaxy19845.4.8 Ensuring compatibility across devicesOne of the requirements of the application is the application needs to be consistent across manydevices and as such should not explicitly define the sizes of elements on the screen. In all screenswhere possible, the Android RelativeLayout was used, which aligns elements relative to siblingelements and allows nesting of layouts which is used to create complex layouts.Carrie Louise Hall Chapter 5 | Page 54
    • The following diagram (Figure 45) shows the layout for the main screen in the bookfriendapplication. It contains two layouts; one for the title bar and the other for the rest of the elements.The XML layout can be found in Appendix 4. Key Element LayoutFigure 45: Diagram showing XML layout for bookfriend main screen5.5 Improving the user experience5.5.1 Finding one particular bookWhen a user is manually searching for books, generating a list from Google Books can be time-consuming. If a user is searching for a particular book, e.g. ‘The Eyre Affair’, then the applicationdisplaying a list of books that match is unimportant and wastes time as the book they are looking foris likely to come first in the list.The bookfriend application deals with this problem by following the following steps 1. The user types a query with the ‘book’ option selected 2. A connection is made to the Google Books API requesting only one book 3. This book title is matched to the user query and if it ‘matches’ then this book is shown to the user to confirm Alternative Scenario 4. If the book title does not match then another connection is made to the Google Books API requesting more books starting at item 2 onwards. 5. The books are then added to the list for the user to chooseCarrie Louise Hall Chapter 5 | Page 55
    • The book titles are matched using Levenshtein distance. The Levenshtein algorithm is designed tomeasure the similarity of strings by calculating the number of edits that are needed to turn onestring into another [32]. An implementation of the algorithm in Java has been made publiclyavailable by Apache in their ‘commons’ package and was included in the bookfriend project. Anexample of how this affects searching for books using the bookfriend application is as follows. Theuser types a phase into the search box:fforde eyre affairThe system requests for a list of books from the Google Books API and the first book returned is:The Eyre AffairJasper FfordeThe calculated distance is 7 and the system has a maximum tolerance of 12. This number isdeliberately set high as it was decided that recall is preferable to precision. That is, it is preferredthat sometimes the application is incorrect in its assumption of the books matching rather thansometimes not matching books that are the same.5.5.2 Speed of resultsThe speed of the application was an important consideration in the development of bookfriend. Asinformation is gathered from data sources and cannot be stored, there is a limitation on how fastthe application can respond. To improve performance, the application was coded to Android bestpractices which included creating the minimum amount of objects and accessing variables directly.Major performance boosting techniques included the use of threading, and improving the way inwhich the data from a data source was accessedThreadingTo guarantee that the application will not show an ANR dialog, it must respond within a shortamount of time which could be difficult if the application is retrieving data. In this scenario, thescreen was loaded but was filled with placeholder “loading” data. For a fast WIFI connection this isshown for less than a second but the delay becomes more pronounced on a slower connection.Android provide an AsyncTask class to enable operations to be run on a background thread andpublish results on the user interface thread, which usually means changing the contents of elementson the screen. AsyncTask is an abstract class which has the following methods:  onPreExecute( ) – this method is run before the background thread begins and can be used to set up the task, such as starting the animation of a loading image  doInBackground( ) – this method is the main background thread and is used for background computation. It cannot modify the user interface layer.  onProgressUpdate( ) – during a complex background task, a publishProgress method can be called in the doInBackground method which will then call this method. This method can access the user interface layer so can be used to animate a progress bar.  onPostExecute( ) – this is the final step of the AsyncTask and is called once the doInBackground method has complete and is responsible for updating the user interface to reflect the results of the background thread.Carrie Louise Hall Chapter 5 | Page 56
    • AsyncTasks were used throughout the bookfriend application wherever requests for data weremade. An example is included in Appendix 5. This improved speed as it meant that the user did nothave a lengthy loading screen at any point and instead the data would be shown as it comes in,meaning that quicker retrievals (such as book summaries and genres) could be explored as thelengthier retrievals were completing (such as book reviews and images).Multiple access to a data sourceAs previously mentioned, all API classes are subclasses of APIConnector which is responsible forestablishing, maintaining and destroying a connection to a data source.Although some APIs can return data in both XML and JSON format, others only returned data in XMLso it was decided to retrieve data in XML. This helped to reduce the code required to retrieve datawhich made debugging easier, but the main reason for this choice was due to the way in which thedocument can be processed. Usually responses are sent back as a large document which mayrequire a lot of processing to extract the information needed by the bookfriend application so toimprove speed, this document was accessed at multiple points at the same time to extract only theinformation required. This ensured that parsing of elements not used by the bookfriend applicationwas not performed, and partial requests for data were much faster. The diagram below explains thesteps taken.Step 1. The bookfriend application makes a request for data to the BookMashup façade BookMashupStep 2. The BookMashup sends asynchronous requests for data to each of the APIs needed to fulfilthat request. BookMooch Goodreads BookMashup Flickr …Step 3. Each API opens a connection to the individual APIs and retrieves each response document. request BookMooch BookMooch Helper response APICarrie Louise Hall Chapter 5 | Page 57
    • Step 4. The elements of the response document needed to fulfil the request are extractedasynchronously and separately. response saleData BookMooch bookPrice bookImage bookGenres editorialThe structure of the BookmoochHelper class is shown in Figure 46. The structure is the same inevery helper class where the getX() method provides the URL to connect to and saves the fulldocument response, and the findX() methods are used to jump to the desired part of thedocument response to retrieve the data. Part of the code is included in Appendix 6.Figure 46: Class diagram of the BookmoochHelper and ApiConnector classThe purpose of retrieving data in this way is to separate the sets of information so that if someinformation is quicker to retrieve then it will be displayed on the screen faster. It also means that noparsing is undertaken unless absolutely required, which saves memory.Carrie Louise Hall Chapter 5 | Page 58
    • Chapter 6. Final resultThis chapter will demonstrate the screens within the bookfriend application and how the userinteracts with them. Finally the release of the application is discussed with references to the feedbackthat has been collected.6.1 WalkthroughThe following images will be used to show the user input actions. SPREAD TAP The user touches their The user touches the thumb and forefinger to screen the screen and moves them apart FLICK TOUCH AND HOLD The user touches the The user touches the screen and moves their screen and holds their finger along the screen finger for a second in a flick motion PINCH The user touches their thumb and forefinger to the screen and moves them together Once the user has navigated to the application in their home menu it is loaded and they are shown this screen. The recent books that they have explored are shown to them and can be retrieved again by clicking on the book preview. The three options show the different ways to find books to explore. The first option to explore will be the manual book entry.Carrie Louise Hall Chapter 6 | Page 59
    • The input book screen is loaded, the user types the keyword and selects the type of search (book,author or ISBN). They select the search button which then loads the books below the search box,making it very easy to perform another search.The next example shows how the system shows the book directly if the first book is a likely match tothe user input.Carrie Louise Hall Chapter 6 | Page 60
    • Before continuing to look at the data retrieved, the other ways to input a book will be mentioned.Barcode scanning cannot be demonstrated using the emulator as there no camera functionality. Thethird way to input a book is to browse by location. The next screen is the main summary screen which contains some information about the book and links to more information. Initially they are shown loading messages which are replaced by data as it feeds in.Carrie Louise Hall Chapter 6 | Page 61
    • This is a demonstration of all the information available on this screen, although only some is visibleat any one time. The user can slide the screen up and down to view more information. Note. clicking on another book by the author will load that book into bookfriend.Carrie Louise Hall Chapter 6 | Page 62
    • The next diagram shows how tweets appear on the bookfriend application. The links can be clickedand loaded in the browser.Awards are the next item to be demonstrated. The star images used in this list are Android standardimages.The next diagram shows the characters screen which also uses standard Android icons for the listitem thumbnail.Carrie Louise Hall Chapter 6 | Page 63
    • The next diagram shows the reviews screen, which shows the star rating as well as the review text.Note. The Android emulator does not display the stars correctly.The book used in this walkthrough so far does not contain many places mentioned, so for thepurpose of this walkthrough the next screens are from the book Wuthering Heights.Another feature of the bookfriend application is film adaptations of books. Again the bookWuthering Heights was used for this demonstration.Carrie Louise Hall Chapter 6 | Page 64
    • The next demonstrations will be the explorations of other books. First, other books with the samegenre can be explored by allowing the user to choose between various themes within the book andthen browsing books that have the same theme.Books by the same publisher are shown below.Carrie Louise Hall Chapter 6 | Page 65
    • The next set of diagrams show how the book summary of the book can be changed.Step 1 Step 2 Step 3 Step 4 Step 5The user can press the home button at any time to jump back to the home page, where they will seetheir recent books. Clicking on a recent book will load it, and the user can also delete books from thislist. Also, the book image for Going Postal has changed during the gathering of these screenshots,this shows how different images are used if a web service is temporarily unavailable.Carrie Louise Hall Chapter 6 | Page 66
    • 6.2 Application releaseThe Android Market is used to distribute both free and paid Android applications to compatibleAndroid devices [21]. Bookfriend was released to the Android Market on March 2nd 2011 under thecategory of ‘Books and Reference’. Since that date there have been 156 installs of bookfriend andsome feedback has been retrieved.6.2.1 Android statisticsThe first form of feedback comes from the Android statistics that are provided on the developerwebsite. It shows the platform versions of all the devices that have installed the application as wellas the makes of devices themselves. It also shows the language and country of origin. This helped inthe development as it confirmed the platforms and devices that needed to be tested. The full set ofresults is provided in Appendix 7.6.2.2 Google AnalyticsThe second form of feedback was obtained using Google Analytics. Google Analytics is a free webanalytics solution providing traffic data for websites. Google have provided an SDK for including thisanalysis in Android devices. It allows developers to specify which parts of the application to monitor,such as pageview tracking or event tracking. For this application, all screens had a separate trackingevent so it was possible to see the popularity of pages and other features such as the barcodescanning. Using Google Analytics was complimentary to the Android statistics as it providedpreviously unknown information such as how many visits there were per day, how long a user wason a screen for, and the resolutions of the screens.To set-up Google Analytics, first a unique key needed to be generated using the website. The SDKwas provided as a JAR file which needed to be included on the project buildpath. The unique codewas provided within the BookMashup Façade class.public static String GOOGLE_ANALYTICS = "UA-21705236-1";The code to track a page was included on every relevant screen.tracker = GoogleAnalyticsTracker.getInstance( );tracker.start( BookMashup.GOOGLE_ANALYTICS, 10, this );The full set of results is provided in Appendix 8.6.2.3 SurveyThe final form of feedback was an online survey created on SurveyMonkey7 . This survey was madepublic and the link is provided when a user downloads the application. The full survey is provided inAppendix 9 and the results are in Appendix 10.7 http://www.surveymonkey.com/Carrie Louise Hall Chapter 6 | Page 67
    • Chapter 7. Testing7.1 Testing Methodology7.1.1 Testing environmentAndroid EmulatorPart of the Android SDK is an emulator which is used to run applications directly from within Eclipse.When setting up an emulator developers are able to control the appearance and screen size, as wellas specifying network connection settings.Running on a deviceThe drawback to using the emulator is the response time is lower and the colours are not as clear. Itis possible to run applications directly on Android devices from within Eclipse. The bookfriendapplication was developed using both of these approaches – the device was used primarily and theemulator was used to test different screen types.Android Debug BridgeThe Android Debug Bridge is a tool provided by the Android SDK to manage the state of theemulator or the device running Android. The logcat logging functionality within this is a shell of logoutput for the device enabled. It is also possible to filter messages so it only shows messages thatcontain particular tags as shown below: $ adb logcat BookFriend:I *:SThis shows logs that are tagged with Bookfriend and have the priority of ‘info’ or above. Theremainder of the code sets the rest of the tags (i.e. those not tagged with Bookfriend) to silent.There are five types of log: Verbose (v), Debug (d), Information (i), Warning (w) and Error (e) andmessages can be written to the log as follows: Log.e( "BookFriend", "Scan result null." );EclipseAndroid applications can be debugged using the Eclipse Debug menu in the same way as Javaprojects. If an application is run in debug mode then the Debug window is displayed and breakpointscan be set at various points in the code.Carrie Louise Hall Chapter 7 | Page 68
    • 7.1.2 Verification and ValidationBoth during and after the implementation process, it is vital to ensure that the project meets itsspecifications and delivers the expected functionality [33]. The two important questions to ask are:Are we building the product right?Are we building the right product?VerificationThe first question refers to verifying that the software conforms to the specification, which involveschecking that the functional and non-functional requirements have been fulfilled as well as testing toensure the system is fully-operational, without defects and has high performance and reliability.ValidationValidation is a more general process than verification and the main aim is to ensure the system doeswhat was expected of it.DebuggingAn important process that was undertaken continually throughout the project was debugging. Thiswas achieved by following routes through the system until all possible routes are exhausted. TheAndroid Debug Bridge was loaded and connected to the device so that if a bug is encountered at anystage then the error log will be updated. Bugs are fixed by applying common knowledge to thesituation and looking for characteristic programming errors.7.1.3 Testing StrategyThe application was tested at the end of every relevant iteration of the project. Module testing wascompleted to ensure that the new features introduced in the iteration did not contain bugs and thatthey worked as expected. Integration testing was then taken to ensure that these new features didnot affect the rest of the functionality within the application.The procedure for the testing usually involved running the application on the device as previouslymentioned and inputting data that is both acceptable and extreme in order to monitor how thesystem responds. When new functionality was introduced, the procedure was repeated to ensurethat all screens of the application still functioned as expected. This meant that there was not a needfor a large amount of system testing relating to functionality at the end of the project, as it wascompleted at every stage.A separate testing project was established to ensure the reliability of the data sources used withinthe application. This was independent of the Android functionality but retained the corecomponents and API classes. There were two sets of book data that were used for the various testsrun with this project; namely the top 100 books from the Guardian website and a random collectionof books.A final aspect of the testing was related to the Android screens and ensuring consistency betweendifferent devices. This was tested by creating different devices using the emulator with differentscreen types.Carrie Louise Hall Chapter 7 | Page 69
    • 7.2 Tests undertaken7.2.1 Incorrect user inputThere is only one area in which the user has any input to the bookfriend application that can causedefects, and that area is when inputting a book. The testing for manual entry involved checking thatempty input was rejected by the system with appropriate feedback for the user. Extreme data forthis test included very long strings of text and non-word characters.7.2.2 ISBN validationIf the user has chosen to search for an ISBN then the system must validate the ISBN before sendingthe request for data. If invalid, the system should inform the user and not perform the search.7.2.3 Scan barcodeOne test for the scanning functionality involved checking that the system responds with the correctbook when an ISBN is scanned. The system also should reject a non-ISBN barcode (such as a productbarcode) and provide feedback to the user.7.2.4 Web-service failureThis test simulated a web service failure by changing the request parameters so that either thetarget API URL or key was incorrect. This meant that the system was not able to establish aconnection with the data source and should fall back to using other data sources, or shouldgracefully degrade and not show the user the unavailable actions.7.2.5 Web connection unavailableThe bookfriend application relies on a data connection to retrieve information about books. Thistest was to ensure that the application shows a useful error message if a connection is not available.7.2.6 Web-service missing dataA data source may not contain a particular piece of information, for example a book summary. Inthis scenario another data source should be used until all data sources had been exhausted. As atest, this was difficult to simulate so instead a wide range of books was input into the bookfriendapplication until this scenario occurred.7.2.7 Reliability of all APIsThe previous tests have been aimed at the bookfriend application, but using the application cannotaccurately measure the reliability of the APIs used so the testing project was used. This test wouldrepeatedly requests data from the data sources on a timed basis and monitors the connections.7.2.8 Retrieval of booksThe only data source that is relied upon within the bookfriend application is the Google Books APIwhich is used to retrieve books that the user has searched for. This reliance meant that the datasource must be reliable and must retrieve the correct books most, if not all, of the time. The ISBNs ofsample books were request from the API and the known book title was matched to the retrievedCarrie Louise Hall Chapter 7 | Page 70
    • title. Due to slight inconsistencies with the titles, the test class needed to transform some of thetitles automatically. The code for the test class is in Appendix 11.7.2.9 Frequency of resultsUsing the testing project, requests to all the various data sources were made to find the likelihood ofthe system retrieving data, such as images or book summaries.7.2.10 Operating systemThe bookfriend application started as an Android v2.1 application and several SDK versions weremade available during the implementation, namely v2.1, 2.2, 2.3 and 2.3.3. The emulator was set upwith several devices running these SDK versions and the application was run on each to ensurecompatibility.The results of the tests are available in Appendix 12.Carrie Louise Hall Chapter 7 | Page 71
    • Chapter 8. Conclusions8.1 Project AchievementsThe main objectives of the project were to:Create a useful Android application that finds previously unknown information about any bookincluding author information, book reviews and other feedback, exploration of other books.The bookfriend application at the end of development includes all of this functionality as well asother features so this objective has been fulfilled.Release the bookfriend application for public use in order to gather feedback from real users.The application has many users and a great deal of feedback has been gathered, so this objective hasalso been fulfilled.The application can be installed from the Android market onto any Android device and allows usersto search for books and provides some information about any given book, so these areas of thesuccess criteria have been achieved.Finally, the application does satify the functional and non-functional requirements that have beenspecified in this report.8.2 Lessons learnedOne of the major hindrances to the application being fully seamless and homogenous was from therestriction placed upon developers from some APIs. This meant that some data had to advertise itssource, for example the Goodreads reviews on the review page needed to be labelled as such.More frustrating was the inability to save data, which is the one aspect that prevents the applicationfrom appearing as a single source of book information and could cause user frustration.8.3 Further workDue to the nature of the implementation, it is very straight-forward to add new APIs so more dataabout books could make the application more interesting. It can be argued that in several years,there will be more data available through public APIs so could be a good source of growth.One aspect that was considered during the early stages was localisation. In Android, the text usedwithin the screens can be separated from the code into XML files which can be sent for translation.The language of the data retrieved from the APIs however would not be known. Further work couldbe done with the application so it allows translation of this text automatically into the user’slanguage.Carrie Louise Hall Chapter 8 | Page 72
    • Much more work could be done on the social networking aspects to the application in order to makeit more exciting for the users involved. Some ideas considered were to have ways of finding outother books that people are currently exploring on bookfriend, the ability to leave comments andfeedback on books, and the integration of other social networking sites.8.4 Final RemarksThere is room for expansion of the bookfriend application but it may detract from its core purposeof discovering previously unknown information about books. As it is now, it is a lightweightapplication that does this very well and the feedback about the usability and functionality of theapplication has been very good.From a personal perspective, Android was a steep learning curve but it was learning how to useAndroid well that was painstaking and difficult at times.The project overall was highly enjoyable and I am very pleased with my result. Final word count: 14,992Carrie Louise Hall Chapter 8 | Page 73
    • GlossaryAAbstract class: A class that has no instances and is created solely for other classes to inherit from itAPI: (Application Programming Interface) An interface implemented by a software program toenable interaction with other softwareBBlog: A personal on-line journal usually maintained by an individual with regular commentaries anddiary entriesBreakpoints: A stopping point in a program used for debugging purposes and allows the developerto understand the state of a program at a particular timeBridge: A device or piece of code used to pass messages between two componentsBug: A fault or defect in a computer systemCCache: Auxiliary memory used for high-speed retrievalClass: A construct in object-oriented programming which is used as a template to create objectsClient: A desktop computer or workstation that is capable of connecting and retrieving data from aserverConcurrence: A property of a system in which several computations are executed simultaneously.DDebugging: Identification and removal of errors from a computer systemEEmulator: A system which duplicates the functions and behaviours of another system.GGeo-coding: The process of finding geographic co-ordinates from other geographic data.Carrie Louise Hall Glossary | Page 74
    • GPS: (Global Positioning System) Accurate worldwide navigational facility based on signals retrievedfrom orbiting satellites.HHTTP: (Hypertext Transfer Protocol) The data transfer used on the World Wide WebHTTPS: (Hypertext Transfer Protocol Secure) A combination of HTTP and SSL/TLS protocol to provideencrypted and secure communicationIIDE: (Integrated Development Environment) A GUI workbench for developing applicationsInstance: An object of a given classInstantiation: The process of creating instances of a classInterface: A set of named operations that can be invoked in order for classes to communicate.ISBN: (International Standard Book Number) A 10 or 13 digit number that is used to identify aparticular title and edition of a bookJJar file: A standard way of packaging many Java files in order to distribute librariesJava: A high level programming languageJSON: (Javascript Object Notation) A lightweight computer data interchange formatKKernel: The central component of a computer system used as a bridge between applications anddata processingLLibrary: A collection of classes used to develop softwareMMashup: An application that uses or combines data from two or more sources to create a newserviceCarrie Louise Hall Glossary | Page 75
    • NNamespace: An abstract container which provides context and allows disambiguation for itemsNesting: The process of organizing information into layers containing similar objectsPParser: A computer program that analyses and extracts information from a data sourcePolymorphism: A programming language feature which allows values of different data types to behandled using a uniform interfaceProtocol: A set of rules determining the format and transmission of dataRRadio button: A graphical user interface element that allows the user to choose from a set ofpredefined optionsSScreen scraping: A technique in which a computer program extracts data from human-readablesource such as a websiteSDK: (Software Development Kit) A set of development tools that allow for the creation ofapplications for a particular software framework or hardware platformShell: A piece of software providing an interface for users to access the services of a kernelSSL: (Secure Socket Layer) A cryptographic protocol which provides secure communications overWorld Wide WebStack trace: A report of the execution of a program, often used for debuggingSubclass: A class that inherits properties from a superclassSubsystem: A group of related components that are part of a larger systemSuperclass: Also known as parent class, and is a class from which other classes are definedTThread: A task that is concurrently run by a computer systemTime-boxing: A method to split development into iterations of a fixed length to ensure that the teamdeliver valuable software within a short periodCarrie Louise Hall Glossary | Page 76
    • TLS: See SSLUURI: (Uniform Resource Identifier) A set of characters used to define a name or resource on theinternetUser Interface: The part of a software application that a user sees and interacts withVVariable: A facility for storing dataWW3C: (World Wide Web Consortium) The main international standards organisation for the WorldWide WebWeb service: APIs that can be accessed over a network and executed on a remote system hostingthe requested servicesXXML: (Extensible Markup Language) A flexible text format for creating structured documentsCarrie Louise Hall Glossary | Page 77
    • Appendix 1. BookListAdapter public class BookListAdapter extends BaseAdapter { private Context context; private ArrayList<Book> bookList; public BookListAdapter( Context context, ArrayList<Book> bookCollection ) { this.context = context; this.bookList = bookCollection; } public int getCount( ) { return bookList.size( ); } public Object getItem( int position ) { return bookList.get( position ); } public long getItemId( int position ) { return position; } public View getView( int position, View convertView, ViewGroup parent ) { Book book = bookList.get( position ); return new BookAdapterListView( this.context, book ); } }Carrie Louise Hall Appendix | Page 78
    • Appendix 2. Overlay for book locationsThe following code snippet shows how a set of string locations are transformed into GeoPoints andset to an overlay based on the type of location. Several image resources are used to distinguishbetween the location types. The geocoding is achieved by the getFromLocationName( ) methodwhich retrieves latitude and longitude which is then converted into microdegrees.class BookLocations extends ItemizedOverlay { private List<OverlayItem> locations = new ArrayList<OverlayItem>( ); private Drawable marker; public BookLocations( Drawable marker, ArrayList<Location> places ) { super( marker ); this.marker = marker; // For every location, find the geolocation for ( Location loc : places ) { Geocoder geocoder = new Geocoder( getBaseContext( ), Locale .getDefault( ) ); try { List<Address> addressResult = geocoder.getFromLocationName( loc .getLocationName( ), 1 ); if ( !addressResult.isEmpty( ) ) { Address resultAddress = addressResult.get( 0 ); // Latitude BigDecimal b = new BigDecimal( resultAddress.getLatitude( ) ); BigDecimal c = b.multiply( BigDecimal.valueOf( 1000000 ) ); BigInteger d = c.toBigInteger( ); int e = d.intValue( ); // Longitude BigDecimal i = new BigDecimal( resultAddress.getLongitude( ) ); BigDecimal f = i.multiply( BigDecimal.valueOf( 1000000 ) ); BigInteger z = f.toBigInteger( ); int h = z.intValue( ); GeoPoint g = new GeoPoint( e, h ); if ( loc.getLocationType( ).equals( "BookLocation" ) ) { OverlayItem overlayitem = new OverlayItem( g, loc .getLocationName( ), getString( R.string.mapbooklocations ) + " " + mashup.getBook( ).getTitle( ) ); locations.add( overlayitem ); } else if ( loc.getLocationType( ).equals( "AuthorLocation" ) ) { OverlayItem overlayitem = new OverlayItem( g, loc .getLocationName( ), getString( R.string.mapauthorlocations ) ); locations.add( overlayitem ); } else if ( loc.getLocationType( ).equals( "PublisherLocation" ) ) { OverlayItem overlayitem = new OverlayItem( g, loc .getLocationName( ), getString( R.string.mappublisherlocations ) ); locations.add( overlayitem ); } } } catch ( IOException e ) { Log.e( "BOOKFRIEND", e.toString( ) ); } } populate( ); }}Carrie Louise Hall Appendix | Page 79
    • @Override public void draw( Canvas canvas, MapView mapView, boolean shadow ) { super.draw( canvas, mapView, shadow ); boundCenterBottom( marker ); } @Override protected OverlayItem createItem( int i ) { return locations.get( i ); } @Override protected boolean onTap( int index ) { OverlayItem item = locations.get( index ); AlertDialog.Builder dialog = new AlertDialog.Builder( c ); dialog.setTitle( item.getTitle( ) ); dialog.setMessage( item.getSnippet( ) ); dialog.show( ); return true; } @Override public int size( ) { return locations.size( ); }Carrie Louise Hall Appendix | Page 80
    • Appendix 3. Image fallback This code shows how the bookfriend system chooses between data sources and is located in the BookMashup class. Some of the access to variables within the Book class have been directly accessed which is an Android recommendation.public Drawable getBookPreview( ) { String location = "http://carriehall.co.uk/bookfriend/booknotfound.jpg"; Drawable d = null; //Bookmooch if ( book.ISBN10 != null && !book.ISBN10.trim( ).equals( "" ) ) { bookmoochHelper.getBook( book.ISBN10 ); if ( bookmoochHelper.findBookImage( ) != null && !bookmoochHelper.findBookImage( ).equals( "" ) ) { d = getImage( bookmoochHelper.findBookImage( ) ); if ( d != null ) { return d; } } } // Goodreads grHelper.getGoodReadsReviews( book.getISBN13( ), 1, 6 ); String temp = grHelper.findBookImage( ); if ( !temp.equals( "" ) ) { if ( !temp.equals( "http://www.goodreads.com/images/nocover-111x148.jpg" ) ) { d = getImage( temp ); if ( d != null ) { return d; } } } // Google if ( !book.link.equals( "" ) ) { d = getImage( book.getLink( ) ); if ( d != null ) { return d; } } return getImage( location );} Carrie Louise Hall Appendix | Page 81
    • Appendix 4. XML layout for main screen<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:id="@+id/titleArea" style="@style/TitleLabel" android:layout_width="fill_parent" android:layout_height="wrap_content"> <ImageButton android:id="@+id/jumpHome" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_alignParentRight="true" style="@style/TitleLabelImage" android:scaleType="fitCenter" android:background="@null" android:layout_centerInParent="true" /> <TextView style="@style/TitleLabelText" android:id="@+id/TitleLabel" android:layout_toLeftOf="@+id/jumpHome" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </RelativeLayout> <TextView style="@style/RecentBooksLabel" android:layout_width="fill_parent" android:text="@+string/recent_books" android:layout_below="@+id/titleArea" android:layout_height="wrap_content" android:id="@+id/RecentBooks" android:layout_alignLeft="@+id/TitleLabel" android:layout_alignRight="@+id/TitleLabel"></TextView> <Gallery android:id="@+id/GalleryBooks" android:layout_width="fill_parent" android:layout_below="@+id/RecentBooks" android:layout_height="wrap_content" android:layout_alignLeft="@+id/RecentBooks" android:layout_alignRight="@+id/RecentBooks"></Gallery> <TextView style="@style/SectionLabel" android:layout_below="@id/GalleryBooks" android:id="@+id/FindBookSectionLabel" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/first_search" /> <ListView style="@style/ChooseList" android:id="@+id/FirstView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@+id/FindBookSectionLabel" android:layout_alignLeft="@+id/GalleryBooks" android:layout_alignRight="@+id/GalleryBooks"></ListView></RelativeLayout> Carrie Louise Hall Appendix | Page 82
    • Appendix 5. AsyncTask exampleThis code excerpt demonstrates an asynchronous task in the bookfriend application. The purpose ofit is used to retrieve the other books by an author. It begins by setting the spinning progress bar tovisible as displayed below in . The background task involves invoking the BookMashup and gettingthe author books. Once retrieved, a BookAdapter is established which simply displays book previewsas shown below and sets them so that when clicked the book is loaded. If no books are found asimple message is displayed using a string from the XML resource. private class getAuthorOtherBooksTask extends AsyncTask<Integer, Integer, RecentBooksAdapter> { private ArrayList<Book> books; protected void onPreExecute( ) { progressBar.setVisibility( View.VISIBLE ); } protected RecentBooksAdapter doInBackground( Integer... authId ) { books = bookMashup.getAuthorBooks( authId[ 0 ] ); RecentBooksAdapter bookAdapter = new RecentBooksAdapter( instance, books ); return bookAdapter; } protected void onPostExecute( RecentBooksAdapter bookAdapter ) { progressBar.setVisibility( View.INVISIBLE ); if ( !bookAdapter.isEmpty( ) ) { g.setAdapter( bookAdapter ); g.setClickable( true ); if ( g.isClickable( ) ) { g.setOnItemClickListener( new OnItemClickListener( ) { public void onItemClick( AdapterView parent, View v, int position, long id ) { BookMashup.getInstance( ).setBook( books.get( position ) ); Intent myIntent = new Intent( v.getContext( ), GetSummary.class ); startActivityForResult( myIntent, 13 ); } } ); } ; } else { String[ ] text = new String[ ] { getString( R.string.no_books_found_for_author ) }; ArrayAdapter<String> arr = new ArrayAdapter<String>( instance, android.R.layout.simple_gallery_item, text ); g.setAdapter( arr ); } } }Carrie Louise Hall Appendix | Page 83
    • Appendix 6. BookmoochHelper classThe following code is an excerpt from the BookmoochHelper class. The getBook( ) methodconstructs a URL to request data about a particular book which is referenced by its ISBN. TheretreiveData( ) method is a method of the superclass, APIConnector and returns the fullresponse document. The Bookmooch API response had a bug in which genres could not be extractedproperly unless the document was normalised which moves all text nodes into a normal form. Seethe full blog post about this bug at: http://bookfriend.posterous.com/normaliseThe findX( ) methods parse the document by finding the elements based on the known tag name.These methods can be called asynchronously which means data is retrieved quickly in comparison todoing one set of parsing.public class BookmoochHelper extends APIConnector { private Element docEle; public void getBook( String isbn ) { String url = "http://api.bookmooch.com/api/asin?asins=" + isbn; docEle = retrieveData( url ); if ( docEle != null ) { docEle.normalize( ); } public String findBookImage( ) { if ( docEle != null ) { NodeList nl = docEle.getElementsByTagName( "LargeImage_URL" ); for ( int i = 0; i < nl.getLength( ); i++ ) { return nl.item( i ).getTextContent( ); } } return ""; } public ArrayList<String> findBookGenres( ) { ArrayList<String> genres = new ArrayList<String>( ); Node childNode = null; if ( docEle != null ) { NodeList nl = docEle.getElementsByTagName( "Topics" ); Node reviewNode = nl.item( 0 ); if ( reviewNode != null ) { for ( int j = 0; j < reviewNode.getChildNodes( ).getLength( ); j++ ) { childNode = reviewNode.getChildNodes( ).item( j ); for ( int k = 0; k < childNode.getChildNodes( ).getLength( ); k++ ) { genres.add( childNode.getChildNodes( ).item( k ).getNodeValue( ) ); } } } } return genres; } public String findEditorialReview( ) { if ( docEle != null ) { NodeList nl = docEle.getElementsByTagName( "EditorialReview_Content" ); for ( int i = 0; i < nl.getLength( ); i++ ) { return nl.item( i ).getTextContent( ); } } return ""; }}Carrie Louise Hall Appendix | Page 84
    • System.out.println( "there were " + hashtable.size( ) + " elements " ); System.out.println( "there were " + numberOfTrue + " true matches" ); System.out.println( "there were " + numberOfMaybe + " maybe matches " ); System.out.println( "there were " + numberOfNo + " without matches " ); } private String stripUnwanted( String string ) { String s = string; if ( string.toString( ).toLowerCase( ).startsWith( "the " ) ) { s = string.substring( 4 ); } if ( string.toString( ).toLowerCase( ).startsWith( "a " ) ) { s = string.substring( 2 ); } if ( string.toString( ).toLowerCase( ).startsWith( "at " ) ) { s = string.substring( 3 ); } s = s.replaceAll( "", "" ); return s; } public void getTop100ItemsToTable( ) { hashtable = new Hashtable<String, String>( ); try { FileInputStream fstream = new FileInputStream( "topbooks.csv" ); DataInputStream in = new DataInputStream( fstream ); BufferedReader br = new BufferedReader( new InputStreamReader( in ) ); String strLine; while ( ( strLine = br.readLine( ) ) != null ) { String[ ] split = strLine.split( "," ); String[ ] split2 = split[ 3 ].split( ":" ); hashtable.put( split[ 2 ], stripUnwanted( split2[ 0 ] ) ); } in.close( ); } catch ( Exception e ) {// Catch exception if any System.err.println( "Error: " + e ); } } public void getRandomBooksToTable( ) { hashtable = new Hashtable<String, String>( ); try { FileInputStream fstream = new FileInputStream( "input.csv" ); DataInputStream in = new DataInputStream( fstream ); BufferedReader br = new BufferedReader( new InputStreamReader( in ) ); String strLine; while ( ( strLine = br.readLine( ) ) != null ) { String[ ] split = strLine.split( ":" ); String isbn = split[ 0 ].substring( 0, 10 ); String title = split[ 0 ].substring( 11, split[ 0 ].length( ) ); hashtable.put( isbn, title ); } in.close( ); } catch ( Exception e ) {// Catch exception if any System.err.println( "Error: " + e ); } }} Carrie Louise Hall Appendix | Page 85
    • Appendix 7. Android statisticsPlatform versionDeviceCarrie Louise Hall Appendix | Page 86
    • CountryCarrie Louise Hall Appendix | Page 87
    • Appendix 8. Google AnalyticsThe following screenshots demonstrate the use of the bookfriend application with data gatheredusing Google analytics. The actual figures used within the content section are not representative asthe bounce rate and exit rate do not apply to mobile applications, and not all pageviews arerecorded.Top ContentScreen ResolutionCarrie Louise Hall Appendix | Page 88
    • Visitor LoyaltyMap OverlayCarrie Louise Hall Appendix | Page 89
    • Appendix 9. Survey Continued on next pageCarrie Louise Hall Appendix | Page 90
    • Carrie Louise Hall Appendix | Page 91
    • Appendix 10. Survey resultsThe results from the survey are shown below.How useable and intuitive is the interface of bookfriend? 1 (not intuitive) 2 3 4 5 (easy to use)How reliable were the results? 1 (not reliable) 2 3 4 5 (very reliable)How interesting and useful were the results? 1 (useless) 2 3 4 5 (very useful)Carrie Louise Hall Appendix | Page 92
    • How fast did you find bookfriend when it retrieved data. 1 (very slow) 2 3 4 5 (fast)Which features would you most like to see in bookfriend?1- not interested, 5 – very interestedOption Average ratingBook prices and options to buy a book 2.8More author information (including education and awards) 4More reviews (including filtering of reviews) 4.4Twitter results about the book/author 4Images of book locations 3.4Did you experience any errors when using bookfriend? Yes NoThe error was that the application would not accept numbers into the search bar when the usertried to search for 1984 by George Orwell. At the time of this survey response there were no radiobuttons to select if the user wants to search for ISBN, it was assumed it was an ISBN if it was onlynumeric digits. Upon receiving this report, the radio buttons were added in to ensure this problemdoes not occur.Carrie Louise Hall Appendix | Page 93
    • Will you continue to use bookfriend? Yes NoWould you recommend bookfriend to a frend? Yes NoCarrie Louise Hall Appendix | Page 94
    • Appendix 11. Google API test classpublic class GoogleTester { Hashtable<String, String> hashtable; public static void main( String[ ] args ) { new GoogleTester( ); } public GoogleTester( ) {// use comments to choose which books to load getTop100ItemsToTable( );// getRandomBooksToTable( ); GoogleHelper gHelper = new GoogleHelper( ); Enumeration<String> e = hashtable.keys( ); int numberOfTrue = 0; int numberOfMaybe = 0; int numberOfNo = 0; while ( e.hasMoreElements( ) ) { String key = ( String ) e.nextElement( ); ArrayList<Book> books = gHelper.getGoogleBooks( key, 1, 1, false ); if ( books.size( ) == 0 ) { System.out.println( "no books found for isbn " + key ); numberOfNo++; } else { if ( hashtable.get( key ).toString( ).toLowerCase( ).equals( gHelper.getGoogleBooks( key, 1, 1, false ).get( 0 ).getTitle( ) .toLowerCase( ) ) ) { System.out.println( "true" ); numberOfTrue++; } else { if ( hashtable.get( key ).toString( ).toLowerCase( ).startsWith( stripUnwanted( gHelper.getGoogleBooks( key, 1, 1, false ).get( 0 ) .getTitle( ).toLowerCase( ) ) ) ) { numberOfTrue++; } else { // "Does bookx match BookX?" System.out.println( "Does "" + hashtable.get( key ) + "" match "" + stripUnwanted( gHelper.getGoogleBooks( key, 1, 1, false ) .get( 0 ).getTitle( ) + "" ?" ) ); Scanner sc = new Scanner( System.in ); String res = sc.next( ); if ( res.equals( "y" ) ) { numberOfTrue++; } else { numberOfMaybe++; } } } } } Carrie Louise Hall System.out.println( "there were " + hashtable.size( ) + " elements " | Page 95 Appendix ); System.out.println( "there were " + numberOfTrue + " true matches" ); System.out.println( "there were " + numberOfMaybe + " maybe matches " ); System.out.println( "there were " + numberOfNo + " without matches " );
    • Appendix 12. Testing resultsTC1: Incorrect Manual User InputPurpose The system should not allow empty strings to be searchedPre-requisite NoneTest Data Empty stringSteps Press the go button with no data enteredResult The application passed the test. When the ‘search’ button is pressed with no input, the system rejects the search and shows an Android notification to the user that they need to input a book. This is also the case if only blank spaces are input.TC2: Incorrect ISBNPurpose The system should not allow incorrect ISBNs to be searchedPre-requisite NoneTest Data Random set of characters and the ISBN radio button selectedSteps Enter a set of random numbers, select an ISBN search and press the ‘search’ buttonResult test passed – notification is shown to the user to inform them of invalid ISBNTC3: Scan BarcodePurpose The system should show a notification if a non-ISBN item is scanned using the Barcode ReaderPre-requisite Barcode Reader needs to be installed, and a camera needs to be present.Test Data Product barcodeSteps Scan the product barcodeResult The application passed the test. The system returns to the search book page and displays a notification that the barcode was not an ISBNTC4: Web connection unavailablePurpose The system should show a message that a data source is not availablePre-requisite NoneTest Data The Eyre Affair by Jasper FfordeSteps Set up the device to have no internetResult The application passed the test. Book images fall back to using Google, awards are not shown, and plot summary falls back to using the Google summaryTC5: Web-service failurePurpose The system should not show links to data that has not been retrievedPre-requisite NoneTest Data The Eyre Affair by Jasper FfordeSteps Change the URL or API key of each API one by one and run the application and find the same book.Result The application passed the test. Book images fall back to using Google, awards are not shown, and plot summary falls back to using the Google summaryTC6: Web connection unavailablePurpose The system should show a useful error message if there is no data connection found when searching for a new book.Pre-requisite There should be no data connection on the deviceTest Data The Eyre Affair by Jasper FfordeSteps Load a recent book then search for a new bookResult The application partially failed the test. When loading a recently viewed book then the system correctly displays no information and does not fail. When a new search is done, the system feeds back very quickly but the message is ‘no book found’ which should be changed to mention the connectionCarrie Louise Hall Appendix | Page 96
    • TC7: Web-service missing dataPurpose The system should fall back to using other sources if the web service does not contain any informationPre-requisite NoneTest Data Various booksSteps Keep searching books and viewing the different summaries to see which ones were loaded automaticallyResult The application passed the test, although the expected data for a book was found first by running the java project which has the same API connectors.TC8: Reliability of all APIsPurpose To determine the reliability of the APIsPre-requisite NoneTest Data The Eyre Affair by Jasper FfordeSteps Request data in a loop and monitor the connections and count any failed responsesResult Google: 100% success Goodreads: 100% success Bookmooch: 100% success ISBNDB: not tested Twitter: not tested Bibliotravel: not testedTC9: Retrieval of booksPurpose Determine how accurate the Google Books API is when giving it a set of ISBNs and matching these to titlesPre-requisite NoneTest Data Top 100 books from the Guardian, and random 100 booksSteps Run the GoogleTester class within the BookFriendTester project, and choose which set of books to testResult Top 100 books: 100% accurary Random 100 books: 97% accuracy These results are acceptable so the test is considered a success.TC10: Frequency of resultsPurpose To determine how likely the system is to retrieve data as a wholePre-requisite NoneTest Data Top 100 books from the Guardian, and random 100 booksSteps Run the BookMashupTester class within the BookFriendTester project, and choose which set of books to testResult Top 100 books: Book image: 100% Book summary: 67% Random 100 books: Book image: 100% Book summary: 86% The test results were acceptableTC11: Operating systemPurpose To ensure the system functions on every version of the Android operating system from 2.1Pre-requisite Emulators for each versions of the operating system must be establishedTest Data The Eyre Affair by Jasper FfordeSteps Run through the system along every path, on each of the emulatorsResult Test passedCarrie Louise Hall Appendix | Page 97
    • Appendix 13. Project PlanThe following screen shot is from Basecamp, the online project management tool which was used totrack the development of the bookfriend application.Carrie Louise Hall Appendix | Page 98
    • References1. Larman, C., Applying UML and Patterns. 2004, New Jersey: Pearson Education.2. Shuli Yu, C.J.W., Innovation in the Programmable Web: Characterizing the Mashup Ecosystem Lecture Notes in Computer Science, 2009. 5472: p. 136-147.3. Merril, D. Mashups: The new breed of Web app. 2009 24 Jul 2009 [cited 2010 April 5]; Available from: http://www.ibm.com/developerworks/xml/library/x-mashups/index.html.4. Murugesan, S., Understanding Web 2.0. IEEE IT Professional 2007. 9(4): p. 34 - 41.5. Eric van der Vlist, D.A., Erik Bruchez, Joe Fawcett, Professional Web 2.0 Programming. Wrox Professional Guides. 2006: John Wiley & Sons.6. Yee, R., Pro Web 2.0 Mashups. 2008, New York: Springer.7. Berlind, D., What is a mashup?, in At The Whiteboard Videos. 2006, ZDNet.8. Maximilien, E.M., An Online Platform for Web APIs and Service Mashups. Internet Computing, IEEE 2008. 12(5): p. 32 - 43.9. Nan Zang, M.B.R., Vincent Nasser, Mashups: who? what? why? Extended abstracts on Human factors in computing systems, 2008.10. Matteo Picozzi, M.R., Cinzia Cappiello, Maristella Matera, Quality-Based Recommendations for Mashup Composition. Current trends in web engineering, 2010.11. Wernick, D., API Documentation: How to Explain so Experts will Understand. 2003.12. Ferrate, A., Money, Ads, and Maps: Is Mapvertising the Key to Monetizing Mashups?, in ProgrammableWeb Blog. 2008.13. Francisco Curbera, M.D., Rania Khalaf,William Nagy,Nirmal Mukhi, Sanjiva Weerawarana, Unraveling the Web Services Web. Internet Computing, IEEE 2002. 6(2): p. 86 - 9314. Costello, R., Building Web Services the REST Way. 2007.15. Fielding, R.T., Architectural Styles and the Design of Network-based Software Architectures. 2000, University of California: California.16. Elkstein, M. Learn REST. 2008; Available from: http://rest.elkstein.org/.17. Robbins, J., Web Design in a Nutshell. 3rd ed. 2006, California: OReilly Media.18. Nurzhan Nurseitov, M.P., Randall Reynolds, Clemente Izurieta Comparison of JSON and XML Data Interchange Formats:. 2009, Montana State University.19. json.org. JSON. 2003 [cited 2011 April 20th]; Available from: http://www.json.org/.20. Allamaraju, S., RESTful Web Services Cookbook. 2010, California: OReilly Media.21. Meier, R., Professional Android 2. 2010, Indiana: Wiley Publishing.22. Saha, A.K., A Developer’s First Look At Android, in Linux For You. 2008. p. 3.23. Cook, J., Shelfari an online meeting place for bibliophiles, in Seattlepi. 2006.24. Ian Sommerville, G.K., Requirements Engineering. 1998, San Francisco: John Wiley & Sons.Carrie Louise Hall Appendix | Page 99
    • 25. Pressman, R.S., Software Engineering, a practitioners approach. 5th ed. 2005, New York: McGraw-Hill.26. Google. Data API: Developers Guide, Protocol. 2011 [cited 2011 14th April]; Available from: http://code.google.com/apis/books/docs/gdata/developers_guide_protocol.html.27. Licia Capra, W.E., Cecilia Mascolo, Middleware for Mobile Computing. UCL Research Notes, 2001.28. Google. Android Developers Guide. 2011 [cited 2011 April 22nd]; Available from: http://developer.android.com/guide/practices/compatibility.html.29. Schuh, P., Integrating Agile Development in the Real World. 2005, Massachusetts: Charles River Media30. Eric Freeman, E.F., Head First Design Patterns. 2004, California: OReilly.31. Erich Gamma, R.H., Ralph Johnson, John Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software. 1994, New Jersey: Pearson Education.32. Gilleland, M. Levenshtein Distance. 2001 [cited 2011 19th April]; Available from: http://www.merriampark.com/ld.htm.33. Sommerville, I., Software Engineering. 8th ed. 2007, Essex: Pearson Education.Carrie Louise Hall Appendix | Page 100