Navigating the Framework Jungle for Teaching Web Application Development
Total Page:16
File Type:pdf, Size:1020Kb
Issues in Informing Science and Information Technology Volume 10, 2013 Navigating the Framework Jungle for Teaching Web Application Development Joseph T. Chao Kevin R. Parker Bowling Green State University Idaho State University Bowling Green, Ohio, USA Pocatello, Idaho, USA Bill Davey RMIT University Melbourne, Australia [email protected] [email protected] [email protected] Abstract Studies indicate that information systems and computer science programs should place more em- phasis on software design topics. Because little significant software in a commercial environment is developed using only programming skills, students without exposure to design patterns and frameworks will be ill-prepared for the workforce. This paper investigates whether PHP-based web development courses should use PHP frameworks to guide program development and how to select an appropriate framework. The paper begins with a literature review of the concept of de- sign patterns, particularly the Model-View-Controller (MVC) pattern. We review studies that ar- gue that design patterns and frameworks are essential pedagogical tools. Finally, we report on our work to select an appropriate framework for incorporation into web development courses as well as the process by which some of the major PHP MVC frameworks were assessed to determine which is best-suited for use in an academic environment. Keywords: Web application development, design patterns, Model-View-Controller, software de- sign, PHP MVC framework, software selection. Introduction Software design concepts are often underemphasized in information systems and computer sci- ence curricula. “Textbooks frequently take the approach of demonstrating how to use a particular library or toolkit, spending little time discussing the structure of the program or architectural pat- terns like MVC” (Hanson & Fossum, 2005, p. 120). The IS 2010 Curriculum Guidelines (Topi et al., 2010) state that graduates of undergraduate IS programs should be experts in high level de- sign of enterprise architecture. “Alt- Material published as part of this publication, either on-line or hough the knowledge and skills that IS in print, is copyrighted by the Informing Science Institute. graduates need have recently moved Permission to make digital or paper copy of part or all of these works for personal or classroom use is granted without fee significantly in the direction toward provided that the copies are not made or distributed for profit higher levels of abstraction, individual or commercial advantage AND that copies 1) bear this notice skills related to design and implementa- in full and 2) give the full citation on the first page. It is per- tion are still essential for IS graduates” missible to abstract these works so long as credit is given. To copy in all other cases or to republish or to post on a server or (Topi et al., 2010, p. 20). The Computer to redistribute to lists requires specific permission and payment Science Curriculum (Cassel, 2008) of a fee. Contact [email protected] to request guideline includes eight core hours ded- redistribution permission. icated to design topics such as design Frameworks for Web Application Development patterns, software architecture, structured design, and object-oriented design, but in many pro- grams it seems that several of those topics are not adequately emphasized. Students are often so focused on learning programming language syntax that they fail to see the big picture of applying that language to solving real problems (Hundley, 2008). The purpose of this paper is to review the need to use frameworks in the classroom and if so, how to select the most appropriate framework. We begin by examining the extant literature confirming that educational gains can be made through using frameworks to teach software design concepts. We selected the web application development course as a viable candidate for the inclusion of frameworks because such courses are often PHP based, and there is a variety of PHP frameworks from which to choose. We selected several viable PHP frameworks for consideration, and then applied a structured selection process to determine which framework would best serve our pur- poses. Hence, the scenario for this discussion requires that: • The curriculum includes a course (or courses) in web development. • The decision has been made to use the PHP programming language, generally considered the most commonly used open-source server-side scripting language. Overview of Design Patterns, MVC, and Frameworks While the focus of this paper is on frameworks, frameworks often contain implementations of many cooperating design patterns. Thus, design patterns will serve as the starting point for this overview. Design patterns are a fairly recent concept in software development. They were first proposed in an OOPSLA-87 Panel Session by Cunningham and Beck (1988), who in turn attribute the idea to the architectural work of Alexander (1977). The concept went relatively unnoticed until the semi- nal piece by Gamma, Helm, Johnson, and Vlissides (1993), in which they formalize the concept of design patterns and propose a design pattern template. A design pattern is a reusable solution that designers can apply, with possible modifications, to an application. It presents the interaction of data and methods in multiple classes, describes the im- plementation of classes and features needed for the interaction, and offers insight to problems that may arise in the application. Over the last two decades software professionals have embraced patterns as a means of recording and sharing expert knowledge for building software (Wallingford, 2002). Experience often makes the difference between being a poor and good designer. It seems sensible that students should be exposed to this approach to de- sign. There is a variety of design patterns in widespread use, including the Model- View-Controller (MVC) pattern, Single- ton, Application Controller, Builder, Front Controller, Iterator, Observer, Registry, and State (Paikens &Arnicans, 2008). MVC is arguably the best known, most famous design pattern (Turner & Bedell, 2002). It was originally designed for ap- plications that provide multiple views of the same data, but now it is virtually the Figure 1: MVC Patterns. central feature of modern interactive ap- plications (Morse and Anderson, 2004). 96 Chao, Parker, Davey The key idea behind the MVC pattern was based on the "input-processing-output" view of sys- tems with the goal of separating user interfaces from the underlying data represented by the user interface. Thus, the MVC pattern, as shown in Figure 1, separates the three main components of an application: models, views, and controllers. Models manage application data, views present the user interface, and controllers handle events for views. Separating the internal data models from the interface views that set or display the data allows models to be represented by a variety of views. Further, the model’s algorithmic logic is distinct from the management of the view, thus leading to a simpler program design. The MVC pattern has proven to be very useful in industry and also can be effectively used in stu- dent projects using either traditional or object-oriented methodologies (Zant, 2006). MVC frameworks exist for many languages and systems including Java, Python, PHP, Microsoft ASP, and Apple's Cocoa application environment. The MVC architecture pattern is often implemented with a software framework such as Web- Sphere, Struts, or Zend. A framework defines a family of related applications, and contains ele- ments that are common to those applications (Tao, 2002). Frameworks provide structure by en- forcing naming conventions (directories, files) and rules for constructing a system. They also provide components that aid in the construction of a system. Application developers extend the framework to build custom applications. Thus, a framework is basically a development environ- ment in which programmers can develop applications of all types much easier and faster, includ- ing web applications. A framework may consist of source code libraries, utilities, plug-ins, devel- opment models, and a wide range of tools, the purpose of which is to accelerate the development pace of an application. There is a core of recurring themes in most frameworks (Caspersen & Christensen, 2008): • The framework delivers application behavior at a high level of abstraction. • A framework provides functionality within a well-defined domain, i.e., frameworks ad- dress specific domains like graphical user interfaces, gaming, insurance, telecommunica- tion, etc. • A framework defines the interaction patterns between a set of well-defined compo- nents/objects. To use the framework the developers are required to understand these in- teraction patterns and must program in accordance with them. • A framework is flexible so that it can be tailored to a concrete context, provided that con- text lies within the domain of the framework. • A framework provides reuse of code as well as reuse of design. Figure 2 depicts an example project, built on a PHP framework, in which the software flow is executed in the following way: • The user makes a request for a page from the server. This is either a standard HTTP call or an AJAX HTTP call. • The request is intercepted by index.php, which bootstraps the framework. • After the framework has been bootstrapped it executes the index action of the controller. This action creates an instance of the module data model for the module name provided as part of the URL for the request. • The module data model loads the module XML file and in-turn creates an instance of the text data model. The text data model is responsible for loading the text for the module from all the various sources. • After the module data model is created, the controller then tells it to render the page re- quested. The module finds the page entry in the parsed XML file, reads out the contents, and then renders the page. The actual page rendering generally requires translating paths 97 Frameworks for Web Application Development for the resources on the page (images, flash movies, and the like) and then replacing text placeholders with the correct text.