End User Interaction Let’s look at the sequence

January 31st, 2007

End User Interaction Let’s look at the sequence of actions performed by typical users who visit the web site for shopping. New users coming to the site for the first time register themselves. Existing users authenticate themselves by providing their user id and password. After authentication is successful, the user, having browsed the music/book titles, adds the items to their cart. Additionally, they can view the list of items in their cart. The user might want to change the quantities of the items or delete the items selected earlier. After the user is sure that they want to buy all the items in their cart, they check out. Checking out is the confirmation from the user that they want to buy all the items in the cart. After the user has checked out, all the items in the user’s cart are entered in the database, and these items are shipped to the address of the user, given at the time of registration. After checking out, the user can continue shopping or can decide to log out. Users can also just browse the music and book titles available in the shopping site, without purchasing any items. Sometimes users are interested in viewing the current status of their account, and the status of items (for example whether they have been shipped or not) purchased by them earlier. The flow chart below describes the interaction of the user with the shopping cart application: Page 544
Note: If you are looking for best hosting provider to host and run your tomcat application check Astra tomcat hosting services

Requirement Analysis The first step in developing any

January 31st, 2007

Requirement Analysis The first step in developing any application is to interview the user base to generate a list of features they would want in the application. This is an important input for defining the capabilities of the application. To keep the application simple, let’s assume that after interviewing the end users and customers, the following requirements were generated: . Users should be able to use the application from any mobile device supporting WML 1.1 and later. . Mobile devices need not support cookies, so the application should not use cookies. . The application should be usable from mobile devices. The application should take into account the small display size of these devices. . WML devices have a small memory footprint, so the browser cannot handle large WML pages. The size of the WML page that is returned to the device from the application must always be less than 1400 bytes. . The user transactions should be secure. That is, some basic authentication mechanism will be built into the application to prevent unauthorized persons from making transactions on a user’s behalf. . Users should be able to buy books and music albums from the site. . Users should be able to view a complete list of available books and music albums. . Users should be able to search for books by author and/or title. . Users should be able to search for music albums by artist and/or title. . Users should be able to search the entire database for keywords. . Users should be able to add items to their cart, and decide later whether they would like to buy the selected items. . Users should be able to change the quantities of items, or delete items from their cart. . After the user has checked out, all the items in the user’s cart should be shipped to the user. . Users should be able to view the status of items they have ordered. . The middle tier of the application should be scalable. That is, it should be possible to run multiple instances of the middle tier. In this chapter we will concentrate only on the end user requirements. In real-life, there would be another interface for the site administrators. This interface will allow them to view the transactions done on a particular day, and change the status of the items purchased by users. Page 543
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services

Chapter 16: A WAP Case Study Overview In

January 31st, 2007

Chapter 16: A WAP Case Study Overview In this case study, we will develop a web-based shopping cart application for mobile devices using PHP. This application will allow users to access the shopping site from their mobile devices (mainly phones). Most of the cell phones available in the market today have a built in Wireless Markup Language (WML) browser. Users can browse different WML sites (for example, http://mobile.yahoo.com/home/), using the browser. In developing this application, we will go through the complete life cycle of software development. We will go through the following steps: . Identifying requirements . Choosing the right products and programming language for implementing the application . Designing the application . Implementing the design Page 542
Hint: If you are looking for high quality webhost to host and run your jsp application check Vision web hosting jsp services

Summary In this chapter, we looked at multi-tier

January 30th, 2007

Summary In this chapter, we looked at multi-tier development as a way to develop web sites and applications. The whole idea around multi-tier development is to abstract the data (content), logic, and presentation layers to minimize the interaction between layers. When developing multi-tier applications, the focus should be on design and not on coding. Scalability and performance are fundamentally tied to the way you design and architect your application. The use of OOP and abstraction classes is the key to a successful multi-tiered architecture. We explored several alternatives for the data layer plain files, relational database, XML, and hybrid models. It is important to make sure that the data layer is isolated from the other layers using abstraction classes and APIs, so that it is possible to change the entire data layer without changing the programs using it. We explored the logic layer and the presentation layer, and we also looked into a common HTML based multi-tiered architecture, and a brand new approach using XML. Page 541

Hint: This post is supported by Gama web hosting php services

that create graphical bars. If we do not

January 30th, 2007

that create graphical bars. If we do not have that functionality in the HTML class then we would have to create it. However, there might be other applications using graphical bars that will be favored by this code that they can later reuse the functions. As we can see, no change at all is needed in the logic layer. Presentation and logic are therefore independent. Case 2: Prevent the User from Voting Multiple Times This will imply a change to the logic. We can use cookies to prevent users for voting twice in the same poll. Advanced users can delete the cookies but we can live with that. Once this is decided, we just add the use of cookies and the controls to the logic layer of our application. These changes will not impact on the content or presentation layers. Case 3: A Flash Version The design team strikes again: they now want to present the whole application using nice Flash animations with sound, graphics, and dancing bears. Then we can just create a Flash class that will have the same interface as the HTML class and implement each method of the HTML class using PHP Flash functions. We do not have to change anything else there, but we have a Flash polls application. See Chapter 25 for examples of PHP’s Flash functions. Page 540

Hint: If you are looking for high quality and reliable webspace provider to host and run your jsp hosting application check Sandzak jsp web hosting provider

Operation Description getOptions($pollid) Given a pollid returns an

January 30th, 2007

Operation Description getOptions($pollid) Given a pollid returns an array of optionIds for the given poll getOptionName($optionid) Given an optionId returns the name of the option getOptionVotes($optionid) Given an optionId returns the number of votes for that option addVote($optionid) Increments the number of votes of the given option addOption($pollid,$name) Adds an option to a poll removePoll($pollid) Deletes a poll and its options removeOption($optionid) Removes an option from a poll setCurrent($pollid) Sets the given poll as the current poll We can encapsulate all these functions in a Poll_Data class, which uses a DB object to access the database. If we change the database from MySQL to PostgreSQL we just instantiate a PostgreSQL DB object and the Poll_Data class will work without modifications. The Logic Layer We can identify two different logic modules in the logic layer. Firstly, an administration module where polls can be created, options added and removed, the current poll can be selected, and so on. This can be implemented as simple HTML forms using the presentation layer to draw the forms and the data manipulation layer to operate with the data model. Finally, we need an application module where the user will see the actual poll, vote, and then see the poll result. We do not take care of a user voting more than once in this simplified application. So we can create a Poll_Admin class with all the administrative functions and forms to display in a browser and a Poll_Application class with the functionality to show the poll, process the vote, and show the results. The Presentation Layer In the presentation layer we’ll build an HTML class to generate forms, to display the form, to create tables, and so on. This will be a highly generic class that will grow a lot as we create new applications requiring new presentation features. The data presentation component will have methods to display the poll form, to show the results, and to create forms. This class will be a client to the HTML class: the idea is that no HTML code at all will be present in the data presentation class (only calls to the HTML class are used). The Classic Multi-Tiered Architecture Let’s take a look at what happens if we design and create our poll application using this architecture. First, we can see here that we have a strong separation between the content layer, the logic layer, and the presentation layer. We also achieved independence of the database using the DB abstraction class and independence of the presentation language using the HTML class. Let’s see what happens if we have to modify the application. Case 1: The Poll Result Display Changes We used a table showing the options, the number of votes, and the results. The designers decide they now want to display a graphical representation of the percentage of votes in each option. Using this architecture, we just modify the data presentation layer to use functions in the HTML class Page 539
Hint: If you are looking for good and high quality web space to host and run your java application check Vision java web hosting services

Designing the Poll Application We will now see

January 30th, 2007

Designing the Poll Application We will now see a small example illustrating all the different layers and how to abstract them. We will work with our sample polls application that has polls and a current poll. Each poll has options, and when the user votes, the result of the poll is shown. Designing the Data Model We will use a database for storage so we are going to use a relational model for this application. The tables will have the following structure: polls pollid INTEGER(4) question VARCHAR(80) poll_options pollid INTEGER(4) optionid INTEGER(4) optname VARCHAR(80) votes INTEGER(4) The following script will create these tables: CREATE TABLE polls( pollid INTEGER(4) NOT NULL AUTO_INCREMENT, question VARCHAR(80), PRIMARY KEY(pollid)); CREATE TABLE poll_options( pollid INTEGER(4) NOT NULL, optionid INTEGER(4) NOT NULL AUTO_INCREMENT, optname VARCHAR(80), votes INTEGER(4), PRIMARY KEY(optionid)); CREATE TABLE current_poll( pollid INTEGER(4)); The Content Layer We’ll build the access component for a MySQL database. Here we do not cover the creation of the class since we don’t want to create a working example in this chapter, just the skeleton. We must implement all the operations to our data model in the data manipulation component: Operation Description createPoll($question) Creates a poll returning a pollid getCurrentPoll() Returns the pollid of the current poll Page 538
Note: If you are looking for good and quality webspace to host and run your java application check professional java hosting services

Separating the Layers Now that we have a

January 30th, 2007

Separating the Layers Now that we have a good idea about multi-tier development, it’s time to see how we can achieve it. Basically the task is to separate the identified layers in your application and minimize the interaction between them. Why? Because when you change a layer, the changes reflected to the other layers are proportional to the level of contact between the layers. If the layers are very strongly coupled, changing a layer would usually imply changing the other too. Since changing layers implies programming, we want to minimize the number of hours/lines of coding we need when we change a system. This is a really practical definition of software maintainability. To separate the layers abstractions must be built. Each layer must have a programming abstraction representing it: object-oriented programming, design patterns, and a careful design are the best tools to achieve this task. Minimizing the interaction between layers becomes a must if performance and flexibility over scale are to be retained. A multi-tiered development process should have at least the following goals: . Maintainability . Modular programming . Independence between logic and presentation . Independence between logic and content . Portability . Database independence . Code reusability We will discuss some of the above topics below. Modular Programming Modular programming is important, as you cannot easily separate the different layers we have identified without programming in a highly modular way. Modular programming will lead to isolated and encapsulated modules for each logic element in the system. OOP is the best method to increase modularity in PHP code, as it promotes unit and integration testing, the use of XP methodology, the use of design patterns with OO, and reusability. Also, you should stress code reusability. If you achieve this goal, software will be easier to maintain and you will be able to code less in future applications. Independence between Logic and Presentation Separating logic and presentation is the key to highly maintainable software. The idea is simple if the designers intend to change the presentation of the site, no logic should be modified, and if the editors change the content, no change should be reflected in the logic of an application. Independence between Logic and Content If the editors change the content no change should be seen in the logic of the application. Database Independence If you use a database you don’t have to depend on the database; it must be easy to change the DBMS being used without changing the logic layer of the application. Page 537
Note: If you are looking for cheap and quality provider to host and run your java application check Astra java hosting services

depending on how step 1 was performed. See

January 30th, 2007

depending on how step 1 was performed. See Chapter 21 for an example of XML processing. . XSL Rendering Applying an XSL style sheet renders the document generated in step 2. Specific formatting is applied, resulting in a document applicable to the requesting client. Possible outputs are HTML, PDF, WML, XML, and others. Page 536
Note: If you are looking for inexpensive but high quality provider to host and run your serlvet application check Astra servlet hosting services

The data presentation component uses the presentation language

January 30th, 2007

The data presentation component uses the presentation language component to build layouts and designs for the data. This is the component where you put all the functions needed to render the data. Presentation Languages There are a lot of new presentation languages available that can display pages on browsers and even voice-enabled languages for the phone. This is a short summary of a few presentation languages: . HTML HTML 4.1 is indeed a presentation language. A lot of fixes had been applied to the language to modularize many presentation aspects, mainly involving the use of CSS. HTML with CSS is a popular presentation language and the one that most browsers use today, so it has a lot of importance. If you are going to use HTML as a presentation language we recommend reading the W3C (http://www.w3c.org/) recommendations and use CSS to abstract the style from the content in HTML pages. . XHTML XHTML is an XML-compliant version of HTML by the W3C. It is very similar to HTML but more restrictive: the file must obey XML formatting rules. It is a very good idea to use XHTML instead of HTML for new applications; as it is probable that XHTML will replace HTML in a near future. . HDML HDML is a reduced subset of HTML for handheld devices and PDAs. While some devices can display HTML, there’re a lot of restrictions that apply to the kind of content that a hand held can display. . WML WML is an XML vocabulary for presentation of content in mobile devices, usually phones. WML has features such as forms, paragraphs and tags that a WML-enabled cell phone can display. Most WAP applications today use WML as their presentation language (Chapter 16 contains a multi-tier WML application). . SVG SVG is an XML vocabulary to display graphics. A set of tags can be used to display geometric figures such as circles, rectangles, text, lines, and so on. Graphics are defined in XML in a vectored way (JPG, GIF, and BMP are bitmaps). There are plugins available for browsers and specific tools to display SVG files, SVG graphics can be of great quality and they have many interesting features such as non-deforming zoom (because the graph is vectorial), a scripting language to provide animation features, searchable text in graphic files and so on. You can learn more about SVG from the W3C site (http://www.w3.org/). . VOICE XML Voice XML is yet another presentation language using an XML vocabulary. It is used to build voice enabled sites and applications. An XML vocabulary can be used to voice phrases, accept DTMF codes, and so on. You can visit the W3C site to and find out more about Voice XML. If your web site or application will have to use a huge number of presentation languages then you may find an XML based architecture useful. We will cover XML based architectures later in the chapter. XML-Based Architecture In an XML-based architecture, the idea is that the logic layer of the application will generate XML data, which can be transformed using XSLT to any presentation language that you need: The XML web publishing framework separates web content generation into three different steps: . XML Creation Content owners create and develop the XML file(s). The content owners do not need to know anything about how their content is processed or presented. In our applications, the business logic layer will be responsible for generating the XML content. Some database vendors are enabling their databases to produce XML data directly out of SELECT statements. . XML Processing The XML file is processed. Any intermediate logic is applied here. This step may be eliminated Page 535

Hint: If you are looking for very good and affordable webspace to host and run your tomcat hosting application check Sandzak.com tomcat web hosting provider