MVC pattern

32 results back to index

pages: 420 words: 79,867

Developing Backbone.js Applications by Addy Osmani


Airbnb, anti-pattern, create, read, update, delete, database schema, don't repeat yourself, Firefox, full text search, Google Chrome, Khan Academy, loose coupling, MVC pattern, node package manager, pull request, Ruby on Rails, side project, single page application, web application

Views and Controllers have a slightly different relationship. Controllers facilitate Views’ responses to different user input and are an example of the Strategy pattern. Summary Having reviewed the classical MVC pattern, you should now understand how it allows developers to cleanly separate concerns in an application. You should also now appreciate how JavaScript MVC frameworks may differ in their interpretation of MVC, and how they share some of the fundamental concepts of the original pattern. When reviewing a new JavaScript MVC/MV* framework, remember - it can be useful to step back and consider how it’s opted to approach Models, Views, Controllers or other alternatives, as this can better help you understand how the framework is intended to be used. Further reading If you are interested in learning more about the variation of MVC which Backbone.js uses, please see the MVP (Model-View-Presenter) section in the appendix.

Historically, developers creating desktop and server-class applications have had a wealth of design patterns available for them to lean on, but it’s only been in the past few years that such patterns have been applied to client-side development. In this chapter, we’re going to explore the evolution of the Model-View-Controller (MVC) design pattern and get our first look at how Backbone.js allows us to apply this pattern to client-side development. MVC MVC is an architectural design pattern that encourages improved application organization through a separation of concerns. It enforces the isolation of business data (Models) from user interfaces (Views), with a third component (Controllers) traditionally managing logic, user-input, and coordination of Models and Views. The pattern was originally designed by Trygve Reenskaug while working on Smalltalk-80 (1979), where it was initially called Model-View-Controller-Editor. MVC was described in depth in “Design Patterns: Elements of Reusable Object-Oriented Software” (The “GoF” or “Gang of Four” book) in 1994, which played a role in popularizing its use.

Backbone solves this problem for you, providing a way to cleanly organize code, separating responsibilities into recognizable pieces that are easy to maintain. In “Developing Backbone.js Applications,” I and a number of other experienced authors will show you how to improve your web application structure using the popular JavaScript library, Backbone.js What Is MVC? A number of modern JavaScript frameworks provide developers an easy path to organizing their code using variations of a pattern known as MVC (Model-View-Controller). MVC separates the concerns in an application into three parts: Models represent the domain-specific knowledge and data in an application. Think of this as being a ‘type’ of data you can model — like a User, Photo, or Todo note. Models can notify observers when their state changes. Views typically constitute the user interface in an application (e.g., markup and templates), but don’t have to be.

pages: 671 words: 228,348

Pro AngularJS by Adam Freeman


business process, create, read, update, delete,, Google Chrome, information retrieval, inventory management, MVC pattern, place-making, premature optimization, revision control, Ruby on Rails, single page application, web application

Use AngularJS for more complex single-page web apps, when you have time for careful design and planning and when you can easily control the HTML generated by the server. Understanding the MVC Pattern The term Model-View-Controller has been in use since the late 1970s and arose from the Smalltalk project at Xerox PARC where it was conceived as a way to organize some early GUI applications. Some of the fine detail of the original MVC pattern was tied to Smalltalk-specific concepts, such as screens and tools, but the broader ideas are still applicable to applications, and they are especially well-suited to web applications. The MVC pattern first took hold in the server-side end of web development, through toolkits like Ruby on Rails and the ASP.NET MVC Framework. In recent years, the MVC pattern has been seen as a way to manage the growing richness and complexity of client-side web development as well, and it is in this environment that AngularJS has emerged.

AngularJS applications express functionality through custom elements, attributes, classes, and comments; a complex application can produce an HTML document that contains a mix of standard and custom markup. The style of development that AngularJS supports is derived through the use of the Model-View-Controller (MVC) pattern, although this is sometimes referred to as Model-View-Whatever, since there are countless variations on this pattern that can be adhered to when using AngularJS. I am going to focus on the standard MVC pattern in this book since it is the most established and widely used. In the sections that follow, I explain the characteristics of projects where AngularJS can deliver significant benefit (and those where better alternatives exist), describe the MVC pattern, and describe some common pitfalls. Understanding Where AngularJS Excels AngularJS isn’t the solution to every problem, and it important to know when you should use AngularJS and when you should seek an alternative.

I am going to use the AngularJS convention and use the ng-app attribute and all of the other HTML enhancements that are available. I recommend you do the same, but you can use one of the other approaches if you prefer—or if your development tool chain can’t process nonstandard HTML elements and attributes. 19 Chapter 2 ■ Your First AngularJS App Creating a Data Model AngularJS supports the Model-View-Controller (MVC) pattern, which I describe in Chapter 3. In short, following the MVC pattern requires you to break up the application into three distinct areas: the data in the application (the model), the logic that operates on that data (the controllers), and the logic that displays the data (the views). The data in my to-do application is currently distributed across the HTML elements. The user’s name is contained in the header, like this: ...

Backbone.js Cookbook by Vadim Mirgorod


Airbnb, create, read, update, delete,, Firefox, Google Chrome, MVC pattern, QR code, rolodex, Ruby on Rails, web application

Questions You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it. 4 1 Understanding Backbone In this chapter, we will cover the following points: ff Designing an application with the MVC pattern ff Defining business logic with models and collections ff Modeling an application's behavior with views and a router ff Creating an application structure from scratch ff Writing your first Backbone application ff Implementing URL routing in your application ff Extending an application with plugins ff Contributing to the Backbone project Introduction Backbone.js is a lightweight JavaScript framework that is based on the Model-View-Controller (MVC) pattern and allows developers to create single-page web applications. With Backbone, it is possible to update a web page quickly using the REST approach with a minimal amount of data transferred between a client and a server.

You can visit the following links to get acquainted with other usage examples of Backbone.js: Backbone.js was started by Jeremy Ashkenas from DocumentCloud in 2010 and is now being used and improved by lots of developers all over the world using Git, the distributed version control system. In this chapter, we are going to provide some practical examples of how to use Backbone.js, and we will structure a design for a program named Billing Application by following the MVC and Backbone pattern. We will also refer to this structure in the later chapters of this book. Reading this chapter is especially useful if you are new to developing with Backbone.js. If you feel that you're an experienced developer, you can skip this chapter. 6 Chapter 1 Designing an application with the MVC pattern MVC is a design pattern that is widely used in user-facing software, such as web applications. It is intended for splitting data and representing it in a way that makes it convenient for user interaction. To understand what it does, understand the following: ff Model: This contains data and provides business logic used to run the application ff View: This presents the model to the user ff Controller: This reacts to user input by updating the model and the view There could be some differences in the MVC implementation, but in general it conforms to the following scheme: sees User uses Application View Controller updates manipulates Model synchronizes Storage Worldwide practice shows that the use of the MVC pattern provides various benefits to the developer: ff Following the separation of the concerned paradigm, which splits an application into independent parts, it is easier to modify or replace ff It achieves code reusability by rendering a model in different views without the need to implement model functionality in each view ff It requires less training and has a quicker startup time for the new developers within an organization 7 Understanding Backbone To have a better understanding of the MVC pattern, we are going to design a Billing Application.

We will learn how to create outstanding web applications using lightweight JavaScript framework known as Backbone.js and utilizing the superior rendering power of modern browsers. Backbone.js Cookbook contains a series of recipes that provide practical, step-by-step solutions to the problems that may occur during the frontend application development, using an MVC pattern and a REST-style communication. You will learn how to build Backbone applications by utilizing the power of popular Backbone extensions and how to integrate your app with different third-party libraries. You will also learn how to fulfill the requirements of the most challenging tasks. What this book covers Chapter 1, Understanding Backbone, introduces you to an MVC pattern and Backbone.js framework. You will learn how to design Backbone applications in terms of MVC and will be able to create your first Backbone app using models, views, and routers. Chapter 2, Models, helps you learn about Backbone.Model, the main building block of your application, which stores data and provides business logic.

pages: 190 words: 52,865

Full Stack Web Development With Backbone.js by Patrick Mulder


Airbnb, create, read, update, delete, Debian, MVC pattern, node package manager, Ruby on Rails, side project, single page application, web application

Developing with JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 vi | Table of Contents Preface Web users demand intuitive and responsive interfaces for tracking their finances and browsing catalogs. Unlike desktop or system applications, where interfaces are mostly built with flavors of C, C++, or Java, today’s web browsers only run JavaScript natively. But the same patterns that make graphical user interfaces successful on different plat‐ forms apply to JavaScript as well. Many communities have formed around experimenting and developing ideas for the model-view-controller (MVC) pattern with JavaScript. It seems like every day there is a new idea about how MVC in web browsers should look and why other ideas won’t work for you. In these turbulent times, the Backbone.js library stands out like a lighthouse. Unlike other approaches to JavaScript MVC, Backbone.js is very small and flexible. However, the main difference of Backbone.js compared to its peers is the Backbone “ecosystem.”

The requirements of Munich Cinema are layout first. Before coding, it is advisable to start with a sketch of an interface on paper. This can help you to structure your software later. We’ll use a basic wireframe for interaction ideas, and we’ll learn how to model the interface with Backbone components. We explore the basic contexts for Backbone views and Backbone models. We also touch on the topic of the model-view-controller (MVC) pattern in Backbone.js. Because Backbone.js has no controller, Backbone’s “MV*” pattern will be explained. The examples in this chapter walk you through the basics of rendering a view, triggering state changes with events, and notifying views to re-render. We build on top of the CommonJS module format from the previous chapter. The following topics will be discussed: • Exploring a UI concept with a wireframe • The separation of data and user interface • The basics of Backbone.Events • Rendering a collection of movies • Viewing updates from events 17 Creating a Wireframe Let’s imagine that we’ve been approached by Munich Cinema, a small, fictional cinema, for help in improving the user experience of its online movie schedule.

Send email to 165 Backbone.Collection, sorting/filtering models with, 61–71 Backbone.js dependencies, 2 distributed application design, 6 fetching local copy of, 4 fetching via content delivery networks, 5 fetching with Node’s package manager, 2 philosophy of, 2, 145 Backbone.Model building a data layer, 26 data resolution, 88 DRYer Views and ViewModels, 46 modal view, 125 sorting, 62 wrapping a data store, 101 Backbone.ModelBinder, 39 Backbone.Obscura, 68, 137 Backbone.Router addressing state, 49–55 orchestrating views, 55–60 overview of, 49 Backbone.Sync, 84, 87 Backbone.View basic events, 31 basic rendering, 37 basic view templates, 41 DRYer Views and ViewModels, 46 filtering, 66 handling UI events, 43 modal view, 125 navbar view, 123 parent/child views, 56 rendering a collection, 42 sorting, 62 templates, 74 Backburner, 76 backend-as-a-service providers, 94, 98 bind function, 159 bindAll function, 159 binding, 39 Bluebird library, 103 Bower, 136 Browserify, 10, 29, 136 browsers development console, 15 DOM representation in, 161 packaging modules for, 9 166 | Index security in, 113 (see also authentication) browsing experience mock-up, 19 Brunch, 136 build automation goals of, 77 Grunt, 77 overview of, 135 scaffolding components, 143 tools to improve productivity, 135 Yeoman, 138 C callbacks, 103 Catero, 136 Cavage, Mark, 100 chaining methods, 161 change events, 28 Chaplin framework, 136, 146 child views, 56 className property, 37 click dummy basic CSS for, 25 basic events, 31 basic HTML for, 24 data layer, 26 preparation overview, 24 Cloudflare, 5 Cocoa API, 22, 5 CoffeeScript, 136 collection helpers, 161 collections filtering, 21, 66 pagination, 68 sorting, 21, 62 transforming, 61 Underscore.js helpers, 158 command line interface (CLI) benefits of, 1 bundling modules from, 10 npm (Node package manager), 2 CommonJS modules benefits of, 8 Browserify, 10 Cartero management system, 136 Express.js and Stitch, 13 require in browsers, 9 comparator function, 62 content delivery network (CDN), 5 controllers, 24, 55 convention-over-configuration, 147 cookies drawbacks of, 115, 118 overview of, 114 session management, 118 user signup, 116 CORS (cross origin resource sharing), 99 createUser method, 116 cross-site request forgery (CSRF), 114 cross-site scripting (XSS), 114 D data binding, 39 building the data layer, 26 controlling access to, 113 (see also authentication) representation with models, 21 transforming with Underscore.js, 158 databases non-relational, 98 NoSQL, 98 relational, 98 wrapping data stores behind an API, 101 debuggers, 15 Decker, Kevin, 145 default properties, 27 dependencies managing with Bower, 136 resolving with main.js file, 141 reusing across projects, 8 Underscore.js, 158–160 Document Object Model (DOM) changing multiple nodes at once, 76 manipulation libraries, 2 node types, 161 statelessness and, 19 DOM nodes attaching/removing event handlers, 162 chaining methods on, 161 operating on directly, 161 preventing event bubbling, 162 selecting with jQuery, 161 types of, 161 DRYer views, 46 E Eastridge, Ryan, 145 ECO (embedded CoffeeScript), 75 event bubbling, 162 event handlers attaching/removing, 162 for UI events, 43 event listeners, 39 events change events, 28 default, 31 handling UI events, 43 sources of, 21, 31 Express.js, 13, 100 extend function, 27, 160 F fetching information asynchronous effects, 92 from hosted backend services, 94 overview of, 83, 87 RESTful web service handling, 84 filtering, 66 Firebase, 94 frameworks benefits of, 145 Chaplin, 146 Giraffe, 146 Junior, 146 Marionette, 146 Rendr, 146 Thorax.js, 146 Function.prototype.bind, 159 functional programming, 158 functions binding context to, 159 get, 28 private, 28 set, 28 sharing across multiple objects, 160 G get function, 28 Giraffe, 146 Grunt, 77 Index | 167 H Handlebars, 76 hashes/hashbangs, 50 Homebrew package manager, 157 HTTP requests basic verbs, 84 cookies, 115 sending from JavaScript, 163 signing, 114 HTTP responses, 102 I index.html, 9 inheritance, 160 isomorphic application design, 97 J JavaScript adding moudles from command line, 143 Ajax, 163 basic abstractions for Backbone.js, 1 debugging, 15 distributed application design, 6 HTTP requests from, 163 jQuery basics of, 160 element selection, 161 event handling, 162 Node.js installation, 157 overview of, 157 promises, 102 Underscore.js benefits of, 158 collections/arrays, 158 functions, 159 objects, 160 utility functions, 160 (see also objects) jQuery Ajax browsing experience mock-up, 19 jQuery API for, 163 basics of, 160 chaining methods, 161 collection helpers, 161 element selection, 161 event handling, 162 168 | Index node wrappers, 161 referencing, 35 JSBin, 5 JSFiddle, 5 JSLint/JSHint, 16 JST (JavaScript Templates), 74 Junior, 146 K key-value pairs data representation with, 21 primary keys, 107 syntax considerations for, 28 L LAMP (Linux-Apache-MySQL-PHP), 98 Layout View, 55 Linux, Node.js installation, 157 M Mac OS Homebrew package manager, 157 Node.js installation, 157 main.js file, 141 Marionette, 146 Mincer, 13 mixin functions, 46 mock-ups APIs, 85 browsing experience, 19 data, 149 wireframes, 19 Mockjax, 149 modal view, 125 model parameter, 29 model-view-controller (MVC) pattern, 22 models (see Backbone models) modules Browserify, 10 bundling from command line, 10 choosing, 8 CommonJS, 8 packaging for browsers, 9 RequireJS, 142 Morell, Jeremy, 68 Munich Cinema example API creation, 100 click dummy preparation basic CSS, 25 basic events, 31 basic HTML, 24 data layer, 26 overview of, 24 current web page, 18 preliminary mock-up, 19 project goals, 18 star rating/voting system, 108 synchronizing state in basic sync and fetch, 87 fetching remote movies, 84 goals of, 83 user interface DRYer views/ViewModels, 46 goals for, 35 handling UI events, 43 interfacing the DOM, 36–43 referencing jQuery, 35 N Navbar view, 123 navigate function, 54 navigation view (navbar), 123 NeXTSTEP operating system, 22 noBackend providers, 94, 98 Node.js installation of, 157 package manager, 2 read-eval-print-loop (REPL), 15 nodes (see DOM nodes) non-relational data stores, 98 npm (Node package manager), 2, 8 O object-relational-mapper (ORM), 98 objects customizing interfaces of, 160 rendering within templates, 160 open-source software, 4 P package managers, 13 pagination, 68 parent views, 56 passwords, 113 (see also authentication) persistence, 101, 108 primary keys, 107 private functions, 28 productivity, improving, 135 (see also workflow automation) promises, 103 proxies, 98 publish-subscribe pattern, 31 pushState(), 50 R React.js, 77 read-eval-print-loop (REPL), 15, 29 relational databases, 98 render function, 37 Rendr, 146 representations in RESTful web services, 85 with models, 21 RequireJS adding modules, 142 benefits of, 140 main.js file, 141 RESTful web services, 84 Restify library, 100 router basics addressing state defining routes, 51 goal of, 49 navigating, 54 preparing, 50 orchestrating views Layout View, 55 parent/child views, 56 overview of, 49 S security, 113 (see also authentication) session management Backbone applications API calls, 118 login dialog, 129 modal view, 125 navbar view, 123 cookies, 118 Index | 169 creating new, 131 logout, 132 set function, 28 signing requests approaches to, 114 benefits of, 114 sorting, 62 Sprockets, 13 state addressing with routers defining routes, 51 goal of, 49 navigating, 54 preparing, 50 authentication and, 131 decoupling from UI benefits of, 22 models and collections, 21 MVC pattern, 22 need for, 19 views, 22 synchronizing basic sync and fetch, 87 fetching remote information, 84 overview of, 83 statelessness, 19, 84 Stitch, 13 T tagName property, 37 template property, 41, 75 templates embedded CoffeeScript, 75 Handlebars, 76 JavaScript Templates, 74 overview of, 73 Thorax.js benefits of, 145 getting started application initialization, 150 build tasks, 147 installation/setup of, 147 mock data preparation, 149 overview of, 146 rendering advanced views, 154 Router setup, 152 Thorax.Collection, 152 TodoMVC demo, 24 tokens, access, 114 170 | Index U Ubuntu, Node.js installation, 157 Underscore.js benefits of, 158 collections/arrays, 158 functions, 159 objects, 160 utility functions, 160 user interface decoupling from state benefits of, 22 models and collections, 21 MVC pattern, 22 need for, 19 views, 22 DRYer views/ViewModels, 46 goals for, 35 handling UI events, 43 interfacing the DOM basic rendering, 37 basic view templates, 41 bindings to data changes, 39 rendering a collection, 42 strategy overview, 36 referencing jQuery, 35 V ViewModels, 46 views advanced view templates, 73 Backbone views, 22 data display management with, 23 DRYer view/ViewModels, 46 Layout View, 55 modal view, 125 MVC pattern, 22 navbar view, 123 parent/child views, 56 updating immediately, 39 welcome view, 59 vulnerabilities cross-site request forgery (CSRF), 114 cross-site scripting (XSS), 114 W Walmart’s shopping cart, 147 welcome view, 59 Windows, Node.js installation, 157 wireframes benefits of, 19 creating, 18 workflow, automation of (see build automation) X benefits of, 136, 138 installation of, 138 running, 139 Z Zepto library, 2, 160 XMLHttpRequest object, 163 Y Yeoman application directory, 140 Index | 171 About the Author Before discovering software development for web applications with Java and Ruby in 2008, Patrick Mulder mainly worked as a software engineer on measurement equip‐ ment and electronic devices.

Django Book by Matt Behrens


Benevolent Dictator For Life (BDFL), create, read, update, delete, database schema, distributed revision control, don't repeat yourself,, Firefox, full text search, loose coupling, MVC pattern, revision control, Ruby on Rails, school choice, slashdot, web application

Those three pieces together – data access logic, business logic, and presentation logic – comprise a concept that’s sometimes called the Model-View-Controller (MVC) pattern of software architecture. In this pattern, “Model” refers to the data access layer, “View” refers to the part of the system that selects what to display and how to display it, and “Controller” refers to the part of the system that decides which view to use, depending on user input, accessing the model as needed. Why the Acronym? The goal of explicitly defining patterns such as MVC is mostly to streamline communication among developers. Instead of having to tell your coworkers, “Let’s make an abstraction of the data access, then let’s have a separate layer that handles data display, and let’s put a layer in the middle that regulates this,” you can take advantage of a shared vocabulary and say, “Let’s use the MVC pattern here.” Django follows this MVC pattern closely enough that it can be called an MVC framework.

Django follows this MVC pattern closely enough that it can be called an MVC framework. Here’s roughly how the M, V, and C break down in Django: M, the data-access portion, is handled by Django’s database layer, which is described in this chapter. V, the portion that selects which data to display and how to display it, is handled by views and templates. C, the portion that delegates to a view depending on user input, is handled by the framework itself by following your URLconf and calling the appropriate Python function for the given URL. Because the “C” is handled by the framework itself and most of the excitement in Django happens in models, templates and views, Django has been referred to as an MTV framework. In the MTV development pattern, M stands for “Model,” the data access layer. This layer contains anything and everything about the data: how to access it, how to validate it, which behaviors it has, and the relationships between the data.

T stands for “Template,” the presentation layer. This layer contains presentation-related decisions: how something should be displayed on a Web page or other type of document. V stands for “View,” the business logic layer. This layer contains the logic that access the model and defers to the appropriate template(s). You can think of it as the bridge between models and templates. If you’re familiar with other MVC Web-development frameworks, such as Ruby on Rails, you may consider Django views to be the “controllers” and Django templates to be the “views.” This is an unfortunate confusion brought about by differing interpretations of MVC. In Django’s interpretation of MVC, the “view” describes the data that gets presented to the user; it’s not necessarily just how the data looks, but which data is presented. In contrast, Ruby on Rails and similar frameworks suggest that the controller’s job includes deciding which data gets presented to the user, whereas the view is strictly how the data looks, not which data is presented.

pages: 290 words: 119,172

Beginning Backbone.js by James Sugrue


Airbnb, continuous integration, don't repeat yourself, Firefox, Google Chrome, loose coupling, MVC pattern, node package manager, single page application, web application, Y Combinator

Following design patterns results in the improved readability of source code for any architect or developer and allows you to follow proven techniques and structures in application creation. It was just a matter of time before this much-needed discipline was introduced to the JavaScript world where the most widely used and applicable patterns is among the oldest: Model View Controller. The emergence of real objectoriented JavaScript has allowed many frameworks to adopt variations of this pattern. 3 Chapter 1 ■ An Introduction to Backbone.js Model View Controller Model View Controller (MVC) is a pattern that separates the three main areas of any code base that involves a user interface. The origins of this pattern go way back to the days of SmallTalk, a well-respected language that dealt with object-oriented software before its time, back in the 1970s. Since then, it has become a foundation of any good software system.

To take this understanding one step further, let’s illustrate how the MVC pattern would apply to a typical web application that includes a registration form. The view in this case is the HTML form, which presents the user with the ability to input, or edit, data about themselves. The controller is the code that gets invoked when the user clicks Save. The controller will also apply some validation to the data provided in the form. Finally, the model is our data representation of the user. Figure 1-3 represents this in a sequence diagram. User Registration Form (View) Form Logic (Controller) User (Model) Enter data Validate Validation Feedback Display Save Feedback Save Figure 1-3.  MVC interaction sequence for a registration form This design pattern provides two key benefits: a separation of concerns and code reuse.

function AddressBookController($scope) { $scope.people = [ {"name": "James}, {"name": "Sarah}, ]; }   Some developers might find that Angular is too opinionated, forcing you to write your application in a particular fashion. Ember Ember.js was released in 2011 as a rebranding of SproutCore 2.0. SproutCore is a slightly older framework, which included its own widget set. In an effort to expose the MVC framework that ran underneath SproutCore, without the need to use these widgets, Ember.js was born. Ember can be downloaded from as illustrated in Figure 1-7. 9 Chapter 1 ■ An Introduction to Backbone.js Figure 1-7.  EmberJS web site Ember is another framework that uses a data binding approach, allowing the view to automatically update when the model changes. This data binding works between models too so that if the data in a related object changes, both are kept in sync.

Catalyst 5.8: The Perl MVC Framework by Antano Solar John, Jonathan Rockway, Solar John Antano

Amazon:, create, read, update, delete, database schema, Debian,, Firefox, MVC pattern, Ruby on Rails, web application

As each page generates its own HTML, a request from your web designer to update the layout of a page will involve having to dig through your Perl source code (potentially breaking database queries or other logic), just to change some HTML. In addition, whenever you make a change that affects your entire site or application, you'll have to make the change a number of times—once for each page. Similarly, fixing one bug will entail copying the fix to every other place. This is inconvenient, a waste of time, and just plain boring. Catalyst is an open source Perl-based Model-View-Controller (MVC) framework that aims to solve this problem by reorganizing your web application. Catalyst application architecture Rather than making each location that a user may visit as an individual file, we make each location an action inside a Controller class. Catalyst sits in front of each of these Controllers, and when it receives a request, it dispatches the request to the proper action. When an action is called by the dispatcher, it's in a preconfigured environment—all configuration options have been read from a configuration file at the application start, all databases are connected, all parameters from the request have been parsed, and so on.

We're not just looking for published authors; if you have strong technical skills but no writing experience, our experienced editors can help you develop a writing career, or simply get some additional reward for your expertise. Zend Framework 1.8 Web Application Development ISBN: 978-1-847194-22-0 Paperback: 380 pages Design, develop, and deploy feature-rich PHP web applications with this MVC framework 1. Create powerful web applications by leveraging the power of this Model-ViewController-based framework 2. Learn by doing – create a “real-life” storefront application 3. Covers access control, performance optimization, and testing 4. Best practices, as well as debugging and designing discussion PHP 5 CMS Framework Development ISBN: 978-1-847193-57-5 Paperback: 348 pages Expert insight and practical guidance to creating an efficient, flexible, and robust framework for a PHP 5-based content management system 1.

Catalyst 5.8 The Perl MVC Framework Build scalable and extendable web applications using the Agile MVC framework Antano Solar John BIRMINGHAM - MUMBAI Catalyst 5.8 The Perl MVC Framework Copyright © 2009 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

pages: 244 words: 20,327

Structuring Backbone Code With RequireJS and Marionette Modules by David Sulc

Amazon:, MVC pattern, web application

You can, however, add other attributes to the view definition. You can see the exercise solution at the end of the book. Download from Wow! eBook <> Displaying a Model Now that we’ve covered displaying static content, let’s move on to displaying content containing data from a model. As you may know, one of Backbone’s selling points is the possibility to structure javascript applications with a Model-View-Controller²⁷ (MVC) pattern. In this pattern, we use socalled models to interact with our data, passing them onto views for rendering the information they contain. You can learn more about models in Backbone’s documentation²⁸. So let’s declare a model within our javascript block, above our view declaration: ContactManager.Contact = Backbone.Model.extend({}); That wasn’t very hard. What did we do? We simply declared a model named Contact and attached it to our ContactManager app.

This is because they have different responsibilities: • templates – are basically HTML – govern “how things should be displayed” (what HTML should be in the view, CSS styles, where data should be displayed, etc.) • views – are javascript objects – take care of “reacting to things that happen” (clicks, keeping track of a model, etc.) This can be somewhat confusing if you’re used to working with an MVC web framework such as Rails. In these, the template and view are typically mixed in the “view” part of the MVC: they get data from the model instances provided by the controller, then generate some HTML that is sent to the browser. What you must keep in mind is that once the HTML is rendered by these frameworks, it never gets modified: a new view may get created by the same controller (e.g. on refresh), but this particular instance will never be modified.

Programming Android by Zigurd Mednieks, Laird Dornin, G. Blake Meike, Masumi Nakamura


anti-pattern, business process, conceptual framework, create, read, update, delete, database schema, Debian, domain-specific language,, fault tolerance, Google Earth, interchangeable parts, iterative process, loose coupling, MVC pattern, revision control, RFID, web application

Finally, let’s delete a record using its ID: sqlite> DELETE FROM video WHERE _id = 1; sqlite> SELECT _id, description FROM videos; 2|Epic Fail Bicycle 3|Epic Fail Wagon 4|Epic Fail Sidewalk 5|Epic Fail Motorcycle SQL and the Database-Centric Data Model for Android Applications Now that you have some basic SQL programming knowledge, we can start thinking about how to put it to use in an Android application. Our goal is to create robust applications based on the popular Model-View-Controller (MVC) pattern that underlies well-written UI programs, specifically in a way that works well for Android. Wikipedia has background information on MVC at One fundamental difference between mobile phone apps and desktop apps is how they handle persistence. Traditional desktop-based applications—word processors, text editors, drawing programs, presentation programs, and so on—often use a document-centric form of the MVC pattern. They open a document, read it into memory, and turn it into objects in memory that form the data model. Such programs will make views for the data model, process user input through their controller, and then modify the data model (Figure 10-1).

A more complex widget—one that can nest other widgets—will have to subclass ViewGroup, which is itself a subclass of View. A very complex widget, perhaps used as an interface tool implemented in several places (even by multiple applications), might be an entire package of classes, only one of which is a descendant of View. This chapter is about graphics, and therefore about the View part of the Model-View-Controller (MVC) pattern. Widgets also contain Controller code, which is good design because it keeps together all the code relevant to a behavior and its representation on the screen. This part of this chapter discusses only the implementation of the View. The implementation of the Controller was discussed in Chapter 7. Concentrating on graphics, then, we can break the tasks of this chapter into two essential parts: finding space on the screen and drawing in that space.

Additionally, a more detailed discussion of MVC in Android will lead us into A “Network MVC”. In order to understand the power of the content provider framework, we need to discuss how cursor update events drive dynamic updates of Android UIs. We think it will help to highlight the often-overlooked communications pathways in the traditional MVC programming pattern, where the following occurs: the View delivers user input events to the Controller; the Controller makes modifications to the Model, and the Model sends update events to the View and to any other observer that registers interest in the Model; the View renders the contents of the Model, usually without directly engaging in application logic, and ideally, just simply iterates over the data in the Model. In Android, the MVC pattern works as shown in Figure 12-3, where explicitly: The Model consists of a content provider and the cursors it returns from its query method, as well as the data it holds in its SQLite tables.

pages: 655 words: 141,257

Programming Android: Java Programming for the New Generation of Mobile Devices by Zigurd Mednieks, Laird Dornin, G. Blake Meike, Masumi Nakamura


anti-pattern, business process, conceptual framework, create, read, update, delete, database schema, Debian, domain-specific language,, fault tolerance, Google Earth, interchangeable parts, iterative process, loose coupling, MVC pattern, revision control, RFID, web application, yellow journalism

Finally, let’s delete a record using its ID: sqlite> DELETE FROM video WHERE _id = 1; sqlite> SELECT _id, description FROM videos; 2|Epic Fail Bicycle 3|Epic Fail Wagon 4|Epic Fail Sidewalk 5|Epic Fail Motorcycle SQL and the Database-Centric Data Model for Android Applications Now that you have some basic SQL programming knowledge, we can start thinking about how to put it to use in an Android application. Our goal is to create robust applications based on the popular Model-View-Controller (MVC) pattern that underlies well-written UI programs, specifically in a way that works well for Android. Wikipedia has background information on MVC at One fundamental difference between mobile phone apps and desktop apps is how they handle persistence. Traditional desktop-based applications—word processors, text editors, drawing programs, presentation programs, and so on—often use a document-centric form of the MVC pattern. They open a document, read it into memory, and turn it into objects in memory that form the data model. Such programs will make views for the data model, process user input through their controller, and then modify the data model (Figure 9-1).

A more complex widget—one that can nest other widgets—will have to subclass ViewGroup, which is itself a subclass of View. A very complex widget, perhaps one that is used as an interface tool used in several places (even by multiple applications), might be an entire package of classes, only one of which is a descendant of View. In contrast, this chapter shows you how to roll your own widget, which involves looking under the View hood. It is about graphics, and therefore about the View part of the Model-View-Controller (MVC) pattern. As mentioned above, widgets also contain Controller code— good design because it keeps together all the code relevant to a behavior and its representation on the screen. This chapter discusses only the implementation of the View. The implementation of the Controller was discussed in Chapter 6. Concentrating on graphics, then, we can break the tasks of this chapter into two essential parts: finding space on the screen and drawing in that space.

Additionally, a more detailed discussion of MVC in Android will lead us into A “Network MVC”. In order to understand the power of the content provider framework, we need to discuss how cursor update events drive dynamic updates of Android UIs. We think it will help to highlight the often-overlooked communications pathways in the traditional MVC programming pattern, where the following occurs: the View delivers user input events to the Controller; the Controller makes modifications to the Model, and the Model sends update events to the View and to any other observer that registers interest in the Model; the View renders the contents of the Model, usually without directly engaging in application logic, and ideally, just simply iterates over the data in the Model. In Android, the MVC pattern works as shown in Figure 12-3, where explicitly: The Model consists of a content provider and the cursors it returns from its query method, as well as the data it holds in its SQLite tables.

pages: 157 words: 35,874

Building Web Applications With Flask by Italo Maia


continuous integration, create, read, update, delete, Debian,, Firefox, full stack developer, minimum viable product, MVC pattern, premature optimization, web application

Request dispatching Secure cookies Sessions Jinja2 templates (tags, filters, macros, and more) With that much, you can handle Ajax requests, browser requests, and user sessions between requests; route HTTP requests to your controllers; evaluate form data; respond to HTML and JSON; and so on. That is nice, but is Flask not an MVC framework? Well, that's arguable. If a web framework does not implement an MVC antipattern, such as handling requests in the view or mixing models and controllers, it could potentially facilitate an MVC, which, in my opinion, is as good as it gets because it does not enforce your application structure. Note Flask is not an MVC framework as it does not implement the model layer, although it does not restrict you in any way if you wish to create your own. If you need a simple, single-file web application that receives a form and gives back an answer, HTML or not, Flask will help you with that, easily.

Flask does not come with bundled functionality in terms of database integration, a forms library, administration interface, or migration tools. You can have these through extensions, which will be discussed soon enough, but they are all external to Flask. If you need these extensions right at the beginning of your project and you don't want to set it up (or can't spare the time to), you might do better with a full-fledged MVC all-in one, low-cohesive, and high-coupling framework such as Django. Now, imagine you need to build a website with a single form, such as a clone, which receives a form and returns the current currency trade values; Flask could help conclude your project really fast. Let's think further. What if you need a specific set of libraries to work together in your project and you don't want the web framework getting in the way; that's another very good scenario for Flask as it gives you the bare minimum and lets you put together everything else you may need.

It is less presumptuous about how your application should look or what you should use to make it available. The BSD licensed package has all this! An introduction to Flask and its features The Flask framework is actually a glue, a very nice one, that sticks together the amazing Werkzeug and Jinja2 frameworks, responsible for answering requests and presenting the output (HTML, maybe). In the MVC architecture, also known as Model-View-Controller, Flask covers C and V. But where is M? Flask does not provide you with an integrated model layer out-of-the-box as that is not actually needed for a web application. If you do need to work with a database, just pick your database solution from the many available and create your own model layer, which is not hard, and be happy! The concept of a micro-framework, with good intentions and made just for Flask, is all about giving you the the smallest (but also the most useful) feature set you need, and one that won't get in the way.

pages: 59 words: 12,801

The Little Book on CoffeeScript by Alex MacCaw


Firefox, MVC pattern, node package manager, web application, Y2K

Additional Libraries Stitch and Eco aren’t the only libraries you can use for creating CoffeeScript and Node applications. There are a variety of alternatives. For example, when it comes to templating, you can use Mustache, Jade, or write your HTML in pure CoffeeScript using CoffeeKup. As for serving your application, Hem is a great choice, supporting both CommonJS and NPM modules and integrating seamlessly with the CoffeeScript MVC framework Spine. node-browsify is another similar project. Or if you want to go lower level with express integration, there’s Trevor Burnham’s connect-assets You can find a full list of CoffeeScript web framework plug-ins on the project’s wiki. Chapter 5. The Good Parts JavaScript is a tricky beast, and knowing the parts that you should avoid is just as important as knowing about the parts you should use.

pages: 180 words: 37,187

AngularJS Essentials by Rodrigo Branas


Firefox, MVC pattern, node package manager, single page application, web application

After 3 weeks and only 1.500 lines of code, he delivered the project! Nowadays, the framework is used by more than 100 projects just at Google, and it is maintained by its own internal team, in which Miško takes part. The name of the framework was given by Adam Abrons, and it was inspired by the angle brackets of the HTML elements. [8] Chapter 1 Architectural concepts It's been a long time since the famous Model-View-Controller (MVC) pattern started to gain popularity in the software development industry and became one of the legends of the enterprise architecture design. Basically, the model represents the knowledge that the view is responsible for presenting, while the controller mediates the relationship between model and view. However, these concepts are a little bit abstract, and this pattern may have different implementations depending on the language, platform, and purpose of the application.

^ parameter 45 A AngularJS about 7 architectural concepts 9 built-in services 76 data handling 53 history 8 service, creating 69 URL 12, 120 AngularJS $compile documentation URL 47 AngularJS animation about 48 ngClass directive, animating 50 ngHide directive, animating 50 ngRepeat directive, animating 49 working 48 AngularJS built-in directives ngApp directive 19, 20 ngBind directive 21 ngBindHtml directive 22 ngClass directive 27 ngClick directive 25, 26 ngController directive 20 ngDisable directive 26 ngHide directive 31 ngIf directive 31 ngInclude directive 31 ngModel directive 24 ngOptions directive 28-30 ngRepeat directive 22, 23 ngShow directive 30 ngStyle directive 30 other directives 26 using 19 AngularJS built-in services $timeout service 96 asynchronous implementation 98 backend communication 76 logging strategy 96 AngularJS components $httpBackend service, mocking with 132-139 controller 126 directives 129 filters 128 service 125 testing 124 test, running with Karma 140 application organization refactoring 32 architectural concepts, AngularJS controller 9 framework, setting up 10, 11 model 9 view 9 array, orderBy filter 59 Asynchronous JavaScript and XML (AJAX) 79, 80 autoWatch property 142 B backend communication about 76 AJAX 79 caching mechanism 85 headers 84 HTTP 76 HTTP facade, creating 82 interceptors 85, 86 JSON 76, 77 REST method 77 best practices, scope object 106 bootstrapping process 18 Bower about 156 cache 158 installation 156 packages, managing with 156 used, for installing packages 157 used, for searching packages 156 bower.json file 157 C cache, Bower 158 caching mechanism 85 callback 98 code organization about 12, 13 ways 13 code organization, ways domain style 15 inline style 13 specific style 14 stereotyped style 13, 14 cohesion 67 Common Gateway Interface (CGI) 7 compile function used, for creating directive 47 configuration, Grunt 146 constants 74 Content Delivery Network (CDN) URL 12 controller, AngularJS components testing 126 controller function used, for creating directive 46 coupling 68 currency filter 56 D date filter 56 deferred API about 100 notify(value) function 100 reject(reason) function 100 resolve(result) function 100 dependency injection 68, 69 directive 18, 19 directive configuration compile function, using 47 controller function, using 46 link function, using 43 replace property, using 36 require property, using 44-46 restrict property, using 37, 38 scope property, using 38-41 template property, using 35 templateUrl property, using 36 transclude property, using 42 Directive Definition Object 34 directives, AngularJS components compiling 130 creating 18, 34 digest cycle, invoking 130 element, creating 130 [ 160 ] link function, calling with scope 130 testing 129 directive scope configuring 38 distribution package creating, for performance improvement 147 creating, for quality improvement 147 creating, for security improvement 147 grunt-connect plugin, installing 153-155 grunt-contrib-clean plugin, installing 147, 148 grunt-contrib-concat plugin, installing 149 grunt-contrib-copy plugin, installing 150 grunt-contrib-jshint plugin, installing 148 grunt-contrib-uglify plugin, installing 149 grunt-karma plugin, installing 151 Document Object Model (DOM) 17 domain style 15 E expression about 53, 54 interpolation 53 F factory function about 70 used, for creating services 70-73 filters about 55 creating 61 interacting, with expression 55 testing 128 using, in other components 60 filter usage, with expression about 56, 57 currency filter, using 55, 56 date filter, using 56 json format, using 57 limitTo filter, using 58 lowercase filter, using 58 number filter, using 58 orderBy filter, using 59, 60 uppercase filter, using 60 form validation $dirty object 65 $error object 65 $pristine object 65 about 62 basic validation, adding 63, 64 first form, creating 62 framework, AngularJS setting up 10-12 function, orderBy filter 59 G GET method 76 Git repository 156, 157 Google Web Toolkit (GWT) 8 Grunt configuration 146 distribution package, creating 147 installing 146 workflow, automating with 145 workflow, executing 155 grunt-connect plugin installing 153-155 grunt-contrib-clean plugin installing 147, 148 grunt-contrib-concat plugin installing 149 grunt-contrib-copy plugin installing 150 grunt-contrib-jshint plugin installing 148 grunt-contrib-uglify plugin installing 149 Gruntfile.js file 146 grunt-karma plugin installing 151 H headers, backend communication 84, 85 HyperText Markup Language (HTML) 7 HyperText Transfer Protocol (HTTP) 7 I Immediately-Invoked Function Expression (IIFE) 71 inline style 13 installation, Bower 156 [ 161 ] installation, Grunt 146 installation, grunt-connect plugin 153-155 installation, grunt-contrib-clean plugin 147, 148 installation, grunt-contrib-concat plugin 149 installation, grunt-contrib-copy plugin 150 installation, grunt-contrib-uglify plugin 149 installation, grunt-karma plugin 151 installation, packages Bower used 157 interceptors httpTimestampInterceptor 85 httpUnauthorizedInterceptor parameter 86 request interceptor 85 response interceptor 86 J Jasmine 121 Jasmine testing framework about 122-124 URL 122 JavaScript Object Notation (JSON) 57, 77 jQuery library URL 104 JSHint 121, 147 JSLint 121, 147 K Karma about 140 configuring 141 configuring, browser options 141 installing, prerequisites 140 tests, running with 140-142 L limitTo filter 58 link function attrs 43 calling, with scope 130 ctrl 43 element 43 scope 43 transcludeFn 43 used, for creating directive 43 logging strategy levels 96 low cohesion application 67 lowercase filter 58 M Mocha, Karma 141 Model-View-Controller (MVC) pattern 9 Model-View-Whatever (MVW) 9 modules creating 115 parking application 115, 119, 120 search 115, 118, 119 UI 115-118 N nested controllers, ngController directive 21 new operator 74 ngApp directive 19, 20 ngBind directive 21 ngBindHtml directive 22 ngClass directive about 27 animating 50 ngClick directive 25, 26 ngController directive about 20 nested controllers 21 ngDisable directive 26 ngHide directive about 31 animating 50 ngIf directive 31 ngInclude directive 31 ngModel directive 24 ngOptions directive 28-30 ngRepeat directive about 22, 23 animating 49 ngShow directive 30 ngStyle directive 30 NodeJS 146 Node Package Manager (npm) 141, 146 number filter 58 [ 162 ] O one-way data binding mechanism 103 orderBy filter about 59, 60 array 59 function 59 string property 59 P package.jsonfile file 146, 154, 155 packages installing, with Bower 157 managing, with Bower 156 searching, with Bower 156 using 157 parking application module 115, 119, 120 Plain-Old-JavaScript-Object (POJO) 9 POST method 77 prerequisites, Karma installation NodeJS 140 Node Package Manager(npm) 141 promise API catch(errorCallback) 101 finally(callback) 101 then (successCallback, errorCallback, notifyCallback) 101 provider used, for creating services 75, 76 Q QUnit, Karma 141 R recommended modules, AngularJS 120 replace property used, for creating directive 36 Representational State Transfer (REST method) 77 RequireJS, Karma 141 require property used, for creating directive 44-46 restrict property used, for creating directive 37, 38 Revealing Module Pattern 70, 72, 122 RSpec 122 run function 112 S scope object about 103 best practices 106-110 broadcasting 111, 112 scope property used, for creating directive 38-41 search module 115, 118, 119 services, AngularJS components creating 69 creating, with AngularJS service 74 creating, with factory function 70-73 creating, with provider 75, 76 testing 125 single-page application.

pages: 323 words: 65,306

Programming in CoffeeScript by Mark Bates


don't repeat yourself,, MVC pattern, node package manager, Ruby on Rails, single page application, web application

At the end of that chapter I talked about how we could have written that code somewhat differently, but doing so would have meant that we basically rewrote the Backbone.js1 framework. Because I’m not typically in favor of reinventing the wheel, I thought we could, instead, see what our application would look like if we used Backbone instead of jQuery to write our client-side code. What Is Backbone.js? Backbone is a client-side MVC2 framework written in JavaScript by Jeremy Ashkenas,3 the creator of a little language known as CoffeeScript.4 Backbone helps us to write highly responsive client-side applications using JavaScript, or in our case, CoffeeScript. Backbone has three separate parts. The first is the View layer. Views let us wrap up the rendering of elements on the screen and then watch those elements for changes and respond accordingly.

The second was the popularity of JavaScript libraries, such as Prototype,3 that made writing cross-browser JavaScript much simpler. You could use AJAX to make your applications more responsive and easier to use and a library like Prototype to make sure it worked across major browsers. In 2010, and certainly in 2011, the Web started evolving into “single page” applications. These applications were driven through the use of JavaScript frameworks, such as Backbone.js.4 These frameworks allowed the use of an MVC5 design pattern using JavaScript. Whole applications would be built in JavaScript and then downloaded and executed in the end user’s browser. This all made for incredibly responsive and rich client-side applications. On the developer’s side, however, things weren’t all roses. Although the frameworks and tools made writing these sorts of applications easier, JavaScript itself proved to be the pain point. JavaScript is at times both an incredibly powerful language and an incredibly frustrating one.

Unless otherwise indicated, you should be able to run the examples in your terminal, like so: > coffee So now that you know how to run the examples in this book, as soon as you have CoffeeScript installed, why don’t you meet me at Chapter 1 and we can get started? See you there. xxiii xxiv Programming in CoffeeScript notes 1. 2. 3. 4. 5.–view–controller 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. missing 22. Part I Core CoffeeScript In this first half of the book we are going to cover everything you’ve ever wanted to know, and everything you’ll ever need to know, about CoffeeScript.

pages: 266 words: 38,397

Mastering Ember.js by Mitchel Kelonye


Firefox, MVC pattern, Ruby on Rails, single page application, web application, WebRTC, WebSocket

Therefore, a better understanding of the following will be gained at the end of the chapter: Ember.js's origin Downloading Ember.js and its dependencies Creating a basic Ember.js application Ember.js application concepts The origin of Ember.js Ember.js is a fun and productive open source JavaScript framework used for creating ambitious web applications. It powers complex client-side applications and guarantees development productivity through use of common web conventions over trivial configurations. Its official website is It was forked from SproutCore by Yehuda Katz and Tom Dale. SproutCore is an MVC framework that strives to provide a robust JavaScript widget toolkit similar to Apple's Cocoa API for Max OS X. The additional user interface widget feature was found to be unnecessary to most developers, hence the fork. The result was a more lightweight, easy-to-use library that still lived up to the promise of: Reducing development time Creating robust applications through use of common client-side web application development best practices Friendly API that makes client-side programming fun Ember.js has a wide range of applications.

pages: 134 words: 29,488

Python Requests Essentials by Rakesh Vidya Chandra, Bala Subrahmanyam Varanasi


create, read, update, delete,, MVC pattern, natural language processing, RFC: Request For Comment, RFID, supply-chain management, web application

Now install the following packages with your virtual environment activated: (survey)~ $ pip install flask flask-sqlalchemy requests httpretty beautifulsoup4 Survey – a simple voting application using Flask To create the survey application, we are going to follow an approach which will give you an easy understanding of the ins and outs of the application and also will make this process of developing a joyride. [ 90 ] Chapter 7 Our development procedure drives you through the process of getting you introduced to all the functions that the project deals with. And then, we will implement each and every function step-by-step. During the development process we will be following the Model-View-Controller (MVC) design pattern, which is popular for developing web applications. The main aim of the survey application is to record the number of responses — 'yes', 'no' and 'maybe' - for the created survey questions. Basic file structures For developing a Flask application, we are following a specific structure to organize the contents of our application. Here is the file structure of the application that we are going to develop: Here is a description of all the files and folders present in our application's file structure: Name of the File/Folder Description Invokes the application development server to startup.

[ 106 ] Index A Access tokens, Facebook API App Access Token 57 Client Token 57 obtaining 57 Page Access Token 57 User Access Token 56 Application Programming Interface (API) 1, 50 B base template 101 basic authentication about 29 advantages 29, 30 flow 30 using, with Requests 30 BeautifulSoup about 69 document parsers 69 installing 69 objects 69 tree, modifying 76 tree, navigating 73 tree, navigating back and forth 75 tree, navigating down 73 tree, navigating sideways 74, 75 tree, navigating up 75 tree, searching 73 web scraping tasks 71, 72 Body Content Workflow about 22 keep-alive facility 23 uploads, streaming 23 built-in response status codes viewing 11 C Chrome DevTools 68 Chunked Responses 46 chunk encoded Requests sending, with generator 24 cookies accessing, with Requests 13 custom authentication 38 custom headers about 8 URL 9 D data types 66 database instance, survey application creating 94 database models, querying 96, 97 model, defining 94, 95 tables, creating 96 Digest authentication about 31 using, with Requests 32 document parsers 69 E errors and exceptions ConnectionError 16 HTTPError 16 [ 107 ] Timeout 16 TooManyRedirects 16 URL 16 event hooks used, for obtaining request method arguments 24, 25 extensions 87 F Facebook API about 56 Access tokens 56 albums, retrieving 59 feed, retrieving 59 friends list, retrieving 58 key, obtaining 56, 57 user profile, getting 57, 58 FireBug Add-on 68 Flask about 87 application, creating 88, 89 features 88 installing 89, 90 required packages, installing with pip 90 Flask micro-framework 101 Flask-SQLAlchemy about 90, 93 used, for writing models 93 form-encoded data sending 9 G generator used, for sending chunk encoded Requests 24 Graduate Record Examinations (GRE) word lists 77 grant types, OAuth 2.0 about 38 Authorization code grant 38 Client credentials grant 38 Implicit grant 38 Resource owner password credentials grant 38 H HTTPAdapter 27 HTTP libraries 68 HTTP request about 1, 2 methods 2 Request Header fields 2, 3 Request URI 2 HTTPretty about 42 headers, setting 44 HTTP requests, mocking 45 installing 42 working with 42, 43 HTTP verbs DELETE method 26 GET method 26 HEAD method 26 OPTIONS method 27 PATCH method 27 POST method 26 PUT method 26 Hypertext Transfer Protocol (HTTP) 1 J Jinja2 88 K Kerberos authentication about 32-35 Authentication Server 32 Host Machine 32 Ticket Granting Server 32 ticket granting ticket (TGT) 33, 34 using, with Requests 35 L link headers used, for describing APIs 27 M micro framework 87 [ 108 ] model about 93 defining 93 Model-View-Controller (MVC) 91 multipart encoded files posting 10 O OAuth 2.0 about 37 grant types 38 OAuth authentication about 35 OAuth 1.0 36, 37 OAuth 1.0, using with Requests 37 OAuth 2.0 37, 38 Object Relational Mapper (ORM) 90 objects, BeautifulSoup BeautifulSoup object 70 comments 70 NavigableString 70 tags 69 P prepared Requests using 20, 21 productive usage checking, with timeout parameter 15 Python modules httplib2 3 Requests 3 urllib2 3 Python Package Index (PyPi) 42 R reddit API about 60 account 60 account information, modifying 61, 62 fullnames 60 listings 60 modhashes 60 new account, registering 60 parts 60 simple search, performing 62 subreddits, searching in 63 REpresentational State Transfer (REST) 50 Requests basic authentication, using with 30 creating 5, 6 Digest authentication, using with 32 essence 5 Kerberos authentication, using with 35 OAuth 1.0 authentication, using with 37 parameters, persisting with Session objects 18 redirection tracking, with request history 14 used, for accessing cookies 13 used, for verifying SSL certificate 21 versus urllib2 3-5 Requests for Comments (RFC) 13 Requests object, parameters auth 19 cookies 19 data 19 files 19 headers 19 hooks 19 Method 19 params 19 URL 19 response content about 6-8 custom headers 8 form-encoded data, sending 9 multipart encoded files, posting 10 types 8 response headers viewing 13 responses dynamic responses, through callbacks 47 rotating responses 45, 46 streaming responses 46, 47 structure 19, 20 RESTful API 50 retweet 54 [ 109 ] S scraping 67 semistructured data 67 Session objects used, for persisting parameters across Requests 18 SSL certificate verifying, with Requests 21 streaming API encoding 25 HTTP verbs 26, 27 iterating 25 Streaming Requests URL 25 structured data 66 survey application building 92 creating 90 database instance, creating 94 executing 104 file structure 91 models, defining 93 models, writing with Flask-SQLAlchemy 93 unit tests, writing 105, 106 URLs, designing 93 T tasks, web scraping semistructured document, modifying 68 semistructured document, navigating 68 semistructured document, searching 68 template about 101 base template 101 details of survey template, displaying 103 list of questions, displaying 102 new survey template, creating 102 vote template, casting 103 template inheritance 101 timeout parameter used, for checking productive usage 15 Transport Adapter 27 Twitter API about 50 authentication request, creating 52 favorite tweet, getting 52 followers list, accessing 54 key, obtaining 51 retweet 54 simple search, performing 53 trends, accessing 55 URL 51 user status, updating 55 types, of data semistructured data 67 structured data 66 unstructured data 66 U unit tests writing, to survey application 105, 106 unstructured data 66 urllib2 examples, URL 4 versus Requests 3-5 V view about 97 new survey, creating 98 new survey question, creating 98 new vote form, creating 100 survey, deleting 100 survey, displaying 99 survey questions, listing 98 survey, updating 99 vote, casting 100 virtual environment wrapper 89 W web scraping about 65-67 dos and don'ts 67 process 68 [ 110 ] requisites 68 tasks 68 web scraping bot about 77 building 76 data, discovering to scrape 80, 81 desired data, drawing 81-85 dos and don'ts 78 HTTP client, using 79 URL/URLs, identifying 78 web scraping tools about 68 utilizing 81 Web Server Gateway Interface (WSGI) protocol 88 Where on Earth ID (woeid) 55 [ 111 ] Thank you for buying Python Requests Essentials About Packt Publishing Packt, pronounced 'packed', published its first book, Mastering phpMyAdmin for Effective MySQL Management, in April 2004, and subsequently continued to specialize in publishing highly focused books on specific technologies and solutions.

pages: 48 words: 10,481

Instant Ember.JS Application Development: How-To by Marc Bodmer


don't repeat yourself, Firefox, Google Chrome, MVC pattern, web application Table of Contents Preface 1 Instant Ember.js Application Development How-to 7 Setting up Ember.js (Simple) Creating an Ember model/object (Simple) Enhancing an Ember object (Simple) Creating an Ember controller (Simple) Handlebar HTML templates (Simple) Creating an Ember view (Simple) Routing for your application (Medium) Common parts of an application (Medium) Handling external data (Advanced) 7 10 12 16 18 21 25 30 33 Preface Ember.js is a frontend MVC JavaScript framework that runs in the browser. It is for developers who are looking to build ambitious and large web applications that rival native applications. Ember.js was created from concepts introduced by native application frameworks, such as Cocoa. Ember.js helps you to create great experiences for the user. It will help you to organize all the direct interactions a user may perform on your website. A common use case for Ember.js is when you believe your JavaScript code will become complex; when the code base becomes complex, problems about maintaining and refactoring the code base will arise. MVC stands for model-view-controller. This kind of structure makes it easy to make modifications or refactor changes to any part of your code.

pages: 509 words: 92,141

The Pragmatic Programmer by Andrew Hunt, Dave Thomas


A Pattern Language, Broken windows theory, business process, buy low sell high,, combinatorial explosion, continuous integration, database schema, domain-specific language, don't repeat yourself, Donald Knuth, general-purpose programming language, George Santayana, Grace Hopper, if you see hoof prints, think horses—not zebras, index card, loose coupling, Menlo Park, MVC pattern, premature optimization, Ralph Waldo Emerson, revision control, Schrödinger's Cat, slashdot, sorting algorithm, speech recognition, traveling salesman, urban decay, Y2K

Tip 42 Separate Views from Models By loosening the coupling between the model and the view/controller, you buy yourself a lot of flexibility at low cost. In fact, this technique is one of the most important ways of maintaining reversibility (see Reversibility, page 44). Java Tree View A good example of an MVC design can be found in the Java tree widget. The tree widget (which displays a clickable, traversable tree) is actually a set of several different classes organized in an MVC pattern. To produce a fully functional tree widget, all you need to do is provide a data source that conforms to the TreeModel interface. Your code now becomes the model for the tree. The view is created by the TreeCellRenderer and TreeCellEditor classes, which can be inherited from and customized to provide different colors, fonts, and icons in the widget. JTree acts as the controller for the tree widget and provides some general viewing functionality.

., 273 McCabe Cyclomatic Complexity Metric, 242 Member variables, see Accessor functions Memory allocation, 135 Metadata, 144, 203 business logic, 146 configuration, 147 controlling transactions, 39 decoupled code, 145 and formal methods, 221 in plain text, 74 Metric, 242 Meyer, Bertrand, 31n, 109, 184, 264 Meyer, Scott, 265 Microsoft Visual C++, 198 Microsoft Windows, 46 Mini-language, 59 data language, 60 embedded, 62 imperative, 60 parsing, 62 stand-alone, 62 Mixing board, 205 MKS Source Integrity, 271 Model, 160 calculations, 67 components and parameters, 66 and estimating, 66 executable documents, 251 view, 162 Model-view-controller (MVC), 38, 160 Modular system, 37 coding, 138 prototyping, 55 resource allocation, 135 reversibility, 45 testing, 41, 190, 244 More Effective C++, 265 Mozilla, 273 Multithreaded programming, 154 MVC, see Model-view-controller The Mythical Man Month, 264 N Name, variable, 249 Nana, 114, 268 Nest allocations, 131 Nested loop, 180 Netscape, 145, 273 Newsgroup, 15, 17, 33 Nonorthogonal system, 34 Normalize, 30 Novobilski, Andrew J., 189n O() notation, 178, 181 Object coupling, 140n destruction, 133, 134 persistence, 39 publish/subscribe protocol, 158 singleton, 41 valid/invalid state, 154 viewer, 163 Object Management Group (OMG), 270 Object Pascal, 29 C interface, 101 Object-Oriented Programming, 189n Object-Oriented Software Construction, 264 Obsolescence, 74 OLTP, see On-Line Transaction Processing system OMG, see Object Management Group On-Line Transaction Processing system (OLTP), 152 Options, providing, 3 Ordering, see Workflow Orthogonality, 34 coding, 34, 36, 40 design, 37 documentation, 42 DRY principle, 42 nonorthogonal system, 34 productivity, 35 project teams, 36, 227 testing, 41 toolkits & libraries, 39 see also Modular system Over embellishment, 11 P Pain management, 185 paint() method, 173 Painting, 11 Papua New Guinea, 16 Parallel programming, 150 Parrots, killer, see Branding Parsing, 59 code generators, 105 log messages, 196 mini-language, 62 strings, 155 Partitioning, 168 Pascal, 29 Passive code generator, 103 Performance testing, 241 Perl, 55, 62, 99 C/Object Pascal interface, 101 database schema generation, 100 home page, 267 Java property access, 100 power tools, 270 test data generation, 100 testing, 197 and typesetting, 100 Unix utilities in, 81 web documentation, 101 Perl Journal, 263 Persistence, 39, 45 Petzold, Charles, 265 Pike, Rob, 99 Pilot landing, handling, etc., 217 who ate fish, 34 Plain text, 73 vs. binary format, 73 drawbacks, 74 executable documents, 251 leverage, 75 obsolescence, 74 and easier testing, 76 Unix, 76 Polymorphism, 111 Post-it note, 53, 55 Powerbuilder, 55 The Practice of Programming, 99 Pragmatic programmer characteristics, xviii e-mail address, xxiii Web site, xxiii Pre- and postcondition, 110, 113, 114 Predicate logic, 110 Preprocessor, 114 Presentation, 20 Problem domain, 58, 66 metadata, 146 Problem solving, 213 checklist for, 214 Productivity, 10, 35 Programming by coincidence, 173 Programming staff expense of, 237 Programming Windows, 265 Project glossary, 210 “heads”, 228 saboteur, 244 schedules, 68 see also Automation; Team, project Project librarian, 33, 226 Prototyping, 53, 216 architecture, 55 disposable code, 56 kinds of, 54 and programming languages, 55 and tracer code, 51 using, 54 Publish/subscribe protocol, 158 Pugh, Greg, 95n Purify, 136 PVCS Configuration Management, 271 Python, 55, 99, 267 Q Quality control, 9 requirements, 11 teams, 225 Quarry worker’s creed, xx Quicksort algorithm, 180 R Rational Unified Process, 227n Raymond, Eric S., 273 RCS, see Revision Control System Real-world data, 243 Refactoring, 5, 185 automatic, 187 and design, 186 testing, 187 time constraints, 185 Refactoring browser, 187, 268 Refinement, excessive, 11 Regression, 76, 197, 232, 242 Relationship has-a, 304 kind-of, 111, 304 Releases, and SCCS, 87 Remote Method Invocation (RMI), 128 exception handling, 39 Remote procedure call (RPC), 29, 39 Repository, 87 Requirement, 11, 202 business problem, 203 changing, 26 creep, 209 DBC, 110 distribution, 211 documenting, 204 in domain language, 58 expressing as invariant, 116 formal methods, 220 glossary, 210 over specifying, 208 and policy, 203 usability testing, 241 user interface, 203 Researching, 15 Resource balancing, 129 C++ exceptions, 132 checking, 135 coupled code, 130 dynamic data structures, 135 encapsulation in class, 132 Java, 134 nest allocations, 131 Response set, 141, 242 Responsibility, 2, 250, 258 Reuse, 33, 36 Reversibility, 44 flexible architecture, 46 Revision Control System (RCS), 250, 271 Risk management, 13 orthogonality, 36 RMI, see Remote Method Invocation Rock-n-roll, 47 RPC, see Remote procedure call Rubber ducking, 3, 95 Rules engine, 169 S Saboteur, 244 Samba, 272 Sample programs, see Example code Sather, 114, 268 SCCS, see Source code control system Schedule, project, 68 Schrödinger, Erwin (and his cat), 47 Scope, requirement, 209 Screen scraping, 61 Scripting language, 55, 145 Secure hash, 74 sed, 99 Sedgewick, Robert, 183 Self-contained components, see Orthogonality; Cohesion Semantic invariant, 116, 135 sendmail program, 60 Sequence diagram, 158 Server code, 196 Services, design using, 154 Shell, command, 77 vs.

In an orthogonally designed system, you would need to change only those modules associated with the user interface to handle this: the underlying logic of controlling the plant would remain unchanged. In fact, if you structure your system carefully, you should be able to support both interfaces with the same underlying code base. It's Just a View, page 157, talks about writing decoupled code using the Model-View-Controller (MVC) paradigm, which works well in this situation. Also ask yourself how decoupled your design is from changes in the real world. Are you using a telephone number as a customer identifier? What happens when the phone company reassigns area codes? Don't rely on the properties of things you can't control. Toolkits and Libraries Be careful to preserve the orthogonality of your system as you introduce third-party toolkits and libraries.

Python Web Development With Django by Jeff Forcier


create, read, update, delete, database schema, Debian, don't repeat yourself,, Firefox, full text search, Guido van Rossum, loose coupling, MVC pattern, revision control, Ruby on Rails, Silicon Valley, slashdot, web application

Safety Because you are rarely executing your own SQL queries when using an ORM, you don’t have to worry as much about the issues caused by malformed or poorly protected query strings, which often lead to problems such as SQL injection attacks. ORMs also provide a central mechanism for intelligent quoting and escaping of input variables, freeing up time otherwise spent dealing with that sort of minutia.This sort of benefit is common with modularized or layered software of which MVC frameworks are a good example.When all the code responsible for a specific problem domain is well-organized and selfcontained, it can often be a huge time-saver and increase overall safety. Expressiveness Although not directly related to the definition of models, one of the greatest benefits of using an ORM (and certainly one of the largest differences, compared to writing raw SQL) is the query syntax used to obtain records from the database.

In this section, we expand further on those concepts, discussing the programming methodologies involved and an overview of how Django implements them (with details and examples in chapters to come). Separating the Layers (MVC) The idea of breaking down a dynamic application (Web or otherwise) has been around for some time, usually applied to graphical client-side applications, and is generally known as the MVC (Model-View-Controller) paradigm.As you can expect, this means the application is segregated into the model, which controls the data, the view, which defines 79 80 Chapter 3 Starting Out how to display data, and a controller, which mediates between the two and enables the user to request and manipulate the data. Compartmentalizing an application in such a manner enables the programmer to be flexible and encourages code reuse among other things.

See also Django applications admin application changing list display, 68-69 creating blog posts, 67-69 customizing, 235-240 login, 66-67 setup, 65-66 troubleshooting, 66 anonymous functions (Python) in, 39 Django architectural overview, 82 block tags, 71 blog aggregator, 338 caching, 226, 265 backend types, 272-274 baseline, determining, 265-266 cache type, setting, 266 middleware, adding, 266 strategies for, 267-271 testing, 266-267 codebase customizing, 264 testing, 279-281 community, contributing to, 337-338 core philosophies of, 82 DRY (Don’t Repeat Yourself), 84 modularity, 84-85 as Pythonic, 84 rapid development, 85 custom managers, 248 default object set, changing, 248-249 methods, creating, 249-250 methods, naming, 249 databases, setup, 62-65 decorators cache_control, 269 cache_page, 268 stringvalue, 258 described, 7 development of, 2 dictionaries in, 28, 225 documentation, 338 downloadable file generation, 243 charts and graphs, 246-248 CSV (comma-separated values) files, 245-246 Nagios configuration files, 243-244 vCards, 244-245 downloading development version, 302 packaged releases, 302 exception handling, 33 filters, 229 fixtures, 65, 113-115 forms, 142 data normalization, 150 defining, 142-143 displaying, 150-152 filling out, 147-149 model-based forms, 143-146 subclassing, 146-147 validating, 149-150 widgets, 152-154 function objects (Python) in, 37-38 hooking into Apache Web server with mod_python, 304-305 imports (CMS example application), 188 installing, 302-303 interactive interpreter (Python) usage, 9-10 keyword arguments (Python) in, 42 managers, 249 349 350 Django models admin options, 101-102 classes (Python) and, 46-47 CMS example application, 186-189 creating and updating databases, 103-104 default ordering, setting, 74 defining, 91 designing, 62 encapsulation of methods, 89-90 enumerate function (Python) in, 30 field types, 91-92 inheritance, 97-100 Meta class, 100-101 non-Django SQL features, usage of, 112-115 ORM (Object-Relational Mapper), advantages of, 89-91 photo gallery example, 160-161 portability, 90 primary keys, 92-93 query syntax, ease of use, 90 querying databases, 104-112 registering, 66 relationships, 93-96 security, 90 uniqueness, enforcing, 93 MVC (Model-View-Controller) architecture in, 80 projects, creating, 58-59 raw strings, 22 superusers, creating, 65 Syndication application, 240 feeds, configuring, 240-241 feeds, URLs for, 242 Universal Feed Parser, 242-243 templates, 70, 135 base templates, creating, 73-74 for CMS example application, 196-198 contexts, 135-136 creating, 70-71 embedding JavaScript actions in, 215 extending, 250-260 filters, 75, 137-138 for Flatpages application, 184 inclusion, 141 inheritance, 139-141 language syntax, 136-137 liveblog example application, 209 photo gallery example, 173-179 tags, 136, 138-141 tuples in, 24-25 URL patterns, 70 creating, 72 URLs, 117 callable views, 121-122 HTTP request-response model, 122-127 include function, 120-121 multiple patterns objects, 119-120 url method, 119 URLconfs, 59, 117-118 Django applications utility scripts, 261 cron jobs, 262-263 data import/export, 263-264 variable tags, 70 view functions, 70 creating, 71-72 liveblog example application, 216-218 views, 127 custom views, 131-132 generic views, 128-131, 221.

Exploring ES6 - Upgrade to the next version of JavaScript by Axel Rauschmayer


anti-pattern, domain-specific language,, Firefox, Google Chrome, MVC pattern, web application, WebSocket

The proxies intercept the get operation that is triggered by the bracket operator. ⁷ Meta programming with proxies 505 function createArray(...elements) { let handler = { get(target, propKey, receiver) { let index = Number(propKey); // Sloppy way of checking for negative indices if (index < 0) { propKey = String(target.length + index); } return Reflect.get(target, propKey, receiver); } }; // Wrap a proxy around an Array let target = []; target.push(...elements); return new Proxy(target, handler); } let arr = createArray('a', 'b', 'c'); console.log(arr[-1]); // c Acknowledgement: The idea for this example comes from a blog post⁸ by 28.4.6 Data binding Data binding is about syncing data between objects. One popular use case are widgets based on the MVC (Model View Controler) pattern: With data binding, the view (the widget) stays up-to-date if you change the model (the data visualized by the widget). To implement data binding, you have to observe and react to changes made to an object. In the following code snippet, I sketch how observing changes could work for an Array. let array = []; let observedArray = new Proxy(array, { set(target, propertyKey, value, receiver) { console.log(propertyKey+'='+value); Reflect.set((target, propertyKey, value, receiver); } }); observedArray.push('a'); Output: ⁸ Meta programming with proxies 506 0=a length=1 Data binding is a complex topic.

Refactoring: Improving the Design of Existing Code by Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts


conceptual framework, database schema, index card, MVC pattern, place-making, sorting algorithm

You may want several interfaces for similar business logic; the user interface becomes too complicated if it does both; it is easier to maintain and evolve domain objects separate from the GUI; or you may have different developers handling the different pieces. Although the behavior can be separated easily, the data often cannot. Data needs to be embedded in GUI control that has the same meaning as data that lives in the domain model. User interface frameworks, from model-view-controller (MVC) onward, used a multitiered system to provide mechanisms to allow you to provide this data and keep everything in sync. 153 If you come across code that has been developed with a two-tiered approach in which business logic is embedded into the user interface, you need to separate the behaviors. Much of this is about decomposing and moving methods. For the data, however, you cannot just move the data, you have to duplicate it and provide the synchronization mechanism.

Example The example in Chapter 1 is a good example of the need for Convert Procedural Design to Objects, particularly the first stage, in which the statement method is broken up and distributed. When you're finished, you can work on now-intelligent data objects with other refactorings. Separate Domain from Presentation You have GUI classes that contain domain logic. Separate the domain logic into separate domain classes Motivation Whenever you hear people talking about objects, you hear about model-view-controller (MVC). This idea underpinned the relationship between the graphical user interface (GUI) and domain objects in Smalltalk-80. 302 The gold at the heart of MVC is the separation between the user interface code (the view, these days often called the presentation) and the domain logic (the model). The presentation classes contain only the logic needed to deal with the user interface. Domain objects contain no visual code but all the business logic.

pages: 196 words: 58,122

AngularJS by Brad Green, Shyam Seshadri


combinatorial explosion, continuous integration, Firefox, Google Chrome, MVC pattern, node package manager, single page application, web application, WebSocket

malicious sites, JSON Vulnerability mandatory fields, Validating User Input manual testing, End-to-End/Integration Tests mathematics functions, Expressions menus, conditional disabling of, CSS Classes and Styles method calls, Communicating Over $http minification, Compilation, Building Your Project minimum/maximum field lengths, The Templates mobile apps, Talking to Servers, Compilation mock data, Organizing Dependencies with Modules model data observing changes with, Observing Model Changes with $watch publishing with scopes, Publishing Model Data with Scopes, Scopes–Scopes storage of, Model View Controller (MVC) model objects, creating, Model View Controller, Working with RESTful Resources model properties, binding elements to, Form Inputs model variables, Model View Controller Model View Controller (MVC) basics of, Model View Controller (MVC), Model View Controller models as basis for apps, The Model basics of, Model View Controller, Relationship Between Model, Controller, and Template model trees in Batarang, Model tab module class, Convenience Methods modules creation of, Model View Controller module methods, AngularJS Module Methods–Convenience Methods number needed, How Many Modules Do I Need? organization of, Where’s the Main Method?

(Unless You Really Want Them) camel-cased names, Naming Your Directive check boxes, Form Inputs, The Check Box child controller, Controllers child scopes, Scopes Chrome browser, Templates Chrome desktop apps, Talking to Servers classes, Client-Side Templates, CSS Classes and Styles click event handler, A Few Words on Unobtrusive JavaScript click notification, A Few Words on Unobtrusive JavaScript client-side templates, Client-Side Templates, Compilation Closure Compiler, Compilation code minification, Compilation code optimization, Compilation combo boxes, The Combo Boxes comparisons, Expressions compilation, Compilation compile property, API Overview, Compile and Link Functions computed results, Observing Model Changes with $watch Config block, Loading and Dependencies configuration files, Project Organization controller property, API Overview controller unit tests, Unit Tests (see also unit tests) controllers adding with Yeoman, Adding New Routes, Views, and Controllers basics of, Model View Controller, Model View Controller, Relationship Between Model, Controller, and Template communication between, The Teams List App: Filtering and Controller Communication defining, Model View Controller file location of, Project Organization in Angular, Model View Controller (MVC), An Example: Shopping Cart nesting of, Separating UI Responsibilities with Controllers, Controllers separating UI responsibilities with, Separating UI Responsibilities with Controllers vs. modules, Organizing Dependencies with Modules working example of, Controllers convenience methods, Communicating Over $http, Convenience Methods cookies, XSRF, Cookies CORS, Talking to Servers credit card objects, Working with RESTful Resources cross-browser compatibility, A Few Words on Unobtrusive JavaScript, Validating User Input CSS classes and styles, CSS Classes and Styles–CSS Classes and Styles currency filter, Formatting Data with Filters, Internationalization and Localization custom error messages, The Templates D data formatting with filters, Formatting Data with Filters passing among scopes, Scopes data binding and templates, Model View Controller–Watching multiple things basics of, Data Binding native speed, Performance Considerations in watch() strategies for, Scopes date filter, Formatting Data with Filters date/time localization, Internationalization and Localization datepickers, Wrapping a jQuery Datepicker debugger breakpoints, Performance Considerations in watch() debugging, Other Awesome Tools declarations, The Declaration declarative event handlers, A Few Words on Unobtrusive JavaScript deepWatch, Observing Model Changes with $watch default headers, Setting HTTP Headers dependency injection basics of, Dependency Injection management of, Service dependencies, Integrating AngularJS with RequireJS organizing with modules, Organizing Dependencies with Modules, Loading and Dependencies dependency loops, Performance Considerations in watch() deployment packages, Integrating AngularJS with RequireJS directive definition object, The Directive Definition Object–Templates directive factory function, Changing the DOM with Directives directives API overview, API Overview–Controllers basics of, Directives, Relationship Between Model, Controller, and Template, Directives creating custom, Changing the DOM with Directives, The Templates, API Overview HTML validation and, Directives discounts, automatic application of, Observing Model Changes with $watch display:block, Hiding and Showing display:none, Hiding and Showing do-what-I-mean declaration, Moving On doA() function, A Few Words on Unobtrusive JavaScript doB() function, A Few Words on Unobtrusive JavaScript document.cookie interface, Cookies DOM (Document Object Model) changing with directives, Changing the DOM with Directives manipulation in Angular, Model View Controller (MVC), Directives, Relationship Between Model, Controller, and Template, Manipulating DOM Elements unit tests and, A Few Words on Unobtrusive JavaScript domReady, Integrating AngularJS with RequireJS doSomething() function, A Few Words on Unobtrusive JavaScript double-curly syntax interpolation, Model View Controller, Displaying Text, CSS Classes and Styles E Edit Controller, Controllers email app, Changing Views with Routes and $location end-to-end tests, End-to-End/Integration Tests errors 404 errors, Considerations for src and href Attributes handling of, The $q and the Promise input error, The Templates login errors, Working with Servers and Login NullPointerException error, Expressions Origin null is not allowed, Templates eval() function, Expressions event handlers, Form Inputs event handlers vs. directives, A Few Words on Unobtrusive JavaScript event listeners, Client-Side Templates event properties, Communicating Between Scopes with $on, $emit, and $broadcast expressions, Expressions, Publishing Model Data with Scopes ExpressJS, Without Yeoman F Factory API call, Convenience Methods factory(), Organizing Dependencies with Modules file upload, File Upload in AngularJS–File Upload in AngularJS filters basics of, An Example: Shopping Cart creating, Formatting Data with Filters formatting data with, Formatting Data with Filters using with repeaters, The Teams List App: Filtering and Controller Communication Firebug, Debugging flow-of-control operators, Expressions for loop, Expressions form elements binding to model properties, Form Inputs hiding/showing, Hiding and Showing form validation controls, Validating User Input, The Templates forward buttons, controllers.js, controllers.js full propagation, Performance Considerations in watch() function binding, Binding select G generic services, Organizing Dependencies with Modules GET requests, JSON Vulnerability, Templates global namespace, Model View Controller, A Few Words on Unobtrusive JavaScript global state, drawbacks of, $location Google Closure, Compilation Google’s content delivery network (CDN), Loading the Script GutHub, The Application H Hashbang mode, HTML5 Mode and Hashbang Mode headers, setting, Setting HTTP Headers Hello, World example, Client-Side Templates, Data Binding History API, HTML5 Mode and Hashbang Mode href attribute, Considerations for src and href Attributes HTML Angular template files, Project Organization HTML extensions directives, Directives HTML sanitization, Sanitizing HTML & the Sanitize Module HTML validation, Directives and HTML Validation HTML5, Changing the DOM with Directives, Directives and HTML Validation, $location, HTML5 Mode and Hashbang Mode HTML5 cookies, Cookies HTTP headers, setting, Setting HTTP Headers HTTP protocol, Talking to Servers I i18n/L10n, Internationalization and Localization IDs, Client-Side Templates, A Few Words on Unobtrusive JavaScript, Templates IE (Internet Explorer), Services, restrict if-else operator, Expressions image tags, Considerations for src and href Attributes index.html, How Do I Get It All Working?

If you’re building an all-Angular application, you should include ng-app as part of the <html> tag, like so: <html ng-app> … </html> This tells Angular to manage all DOM elements in the page. If you’ve got an existing app where some other technology expects to manage the DOM, such as Java or Rails, you can tell Angular to manage only a part of the page by placing it on some element like a <div> within the page. <html> … <div ng-app> … </div> … </html> Model View Controller In Chapter 1, we mentioned that Angular supports the Model View Controller style of application design. Though you have a lot of flexibility in designing your Angular app, you will always have some flavor of: A model containing data that represents the current state of your application. Views that display this data. Controllers that manage the relationship between your model and your views. You’ll create your model using object attributes, or even just primitive types containing your data.

pages: 719 words: 181,090

Site Reliability Engineering by Betsy Beyer, Chris Jones, Jennifer Petoff, Niall Richard Murphy

Air France Flight 447, anti-pattern, barriers to entry, business intelligence, business process, Checklist Manifesto, cloud computing, combinatorial explosion, continuous integration, correlation does not imply causation, crowdsourcing, database schema, defense in depth, DevOps,, fault tolerance, Flash crash, George Santayana, Google Chrome, Google Earth, job automation, job satisfaction, linear programming, load shedding, loose coupling, meta analysis, meta-analysis, minimum viable product, MVC pattern, performance metric, platform as a service, revision control, risk tolerance, side project, six sigma, the scientific method, Toyota Production System, trickle-down economics, web application, zero day

Workflow uses the leader-follower (workers) distributed systems design pattern [Sha00] and the system prevalence design pattern.4 This combination enables very large-scale transactional data pipelines, ensuring correctness with exactly-once semantics. Workflow as Model-View-Controller Pattern Because of how system prevalence works, it can be useful to think of Workflow as the distributed systems equivalent of the model-view-controller pattern known from user interface development.5 As shown in Figure 25-4, this design pattern divides a given software application into three interconnected parts to separate internal representations of information from the ways that information is presented to or accepted from the user.6 Figure 25-4. The model-view-controller pattern used in user interface design Adapting this pattern for Workflow, the model is held in a server called “Task Master.” The Task Master uses the system prevalence pattern to hold all job states in memory for fast availability while synchronously journaling mutations to persistent disk.

We have found that continuous data processing with strong guarantees, as provided by Workflow, performs and scales well on distributed cluster infrastructure, routinely produces results that users can rely upon, and is a stable and reliable system for the Site Reliability Engineering team to manage and maintain. 1 Wikipedia: Extract, transform, load,,_transform,_load 2 Wikipedia: Big data, 3 Jeff Dean’s lecture on “Software Engineering Advice from Building Large-Scale Distributed Systems” is an excellent resource: [Dea07]. 4 Wikipedia: System Prevalence, 5 The “model-view-controller” pattern is an analogy for distributed systems that was very loosely borrowed from Smalltalk, which was originally used to describe the design structure of graphical user interfaces [Fow08]. 6 Wikipedia: Model-view-controller, Chapter 26. Data Integrity: What You Read Is What You Wrote Written by Raymond Blum and Rhandeev Singh Edited by Betsy Beyer What is “data integrity”? When users come first, data integrity is whatever users think it is.

decision-making skills, Structured and Rational Decision Making defense in depth, for data integrity, The 24 Combinations of Data Integrity Failure Modes, Sunday, February 27, 2011, late in the evening, Defense in Depth demand forecasting, Demand Forecasting and Capacity Planning dependency hierarchies, Setting Reasonable Expectations for Monitoring, Dependencies among resources deployment, Deployment(see also continuous build and deployment) development environment, Our Development Environment development/ops split, The Sysadmin Approach to Service Management DevOps, Google’s Approach to Service Management: Site Reliability Engineering Direct Server Response (DSR), Load Balancing at the Virtual IP Address disaster recovery tools, Testing Disaster disaster role playing, Disaster Role Playing disaster testing, Preparedness and Disaster Testing-Defense in Depth and BreadthDisaster and Recovery Testing (DiRT), Preparedness and Disaster Testing disk access, Disk Access Diskerase process, Recommendations distractibility, Distractibility distributed consensus systemsbenefits of, Managing Critical State: Distributed Consensus for Reliability coordination, use in, Distributed Coordination and Locking Services deploying, Deploying Distributed Consensus-Based Systems-Quorum composition locking, use in, Managing Critical State: Distributed Consensus for Reliability monitoring, Monitoring Distributed Consensus Systems need for, Managing Critical State: Distributed Consensus for Reliability overview of, Conclusion patterns for, System Architecture Patterns for Distributed Consensus-Reliable Distributed Queuing and Messaging performance of, Distributed Consensus Performance-Disk Access principles, How Distributed Consensus Works quorum composition, Quorum composition quorum leasing technique, Quorum Leases(see also consensus algorithms) distributed periodic scheduling (see cron) DNS (Domain Name System)EDNS0 extension, Load Balancing Using DNS load balancing using, Load Balancing Using DNS-Load Balancing Using DNS DoubleClick for Publishers (DFP), Case Study: Migrating DFP to F1-Case Study: Migrating DFP to F1 drains, Planned Changes, Drains, or Turndowns DTSS communication files, Origin of the Pipeline Design Pattern dueling proposers situation, Multi-Paxos: Detailed Message Flow durability, Indicators E early detection for data integrity, Third Layer: Early Detection(see also data integrity) Early Engagement Model, Evolving the Simple PRR Model: Early Engagement-Disengaging from a service “embarrassingly parallel” algorithms, Trouble Caused By Uneven Work Distribution embedded engineers, Embedding an SRE to Recover from Operational Overload-Conclusion emergency preparedness, Sunday, February 27, 2011, late in the eveningcross-industry lessons, Preparedness and Disaster Testing emergency responsechange-induced emergencies, Change-Induced Emergency-What we learned essential elements of, Emergency Response Five Whys, Ask “what,” “where,” and “why”, Example Postmortem guidelines for, Emergency Response initial response, What to Do When Systems Break lessons learned, Keep a History of Outages overview of, Conclusion process-induced emergencies, Process-Induced Emergency solution availability, All Problems Have Solutions test-induced emergencies, Test-Induced Emergency encapsulation, Load Balancing at the Virtual IP Address endpoints, in debugging, Examine engagements (see SRE engagement model) error budgetsbenefits of, Benefits best practices for, Error Budgets forming, Forming Your Error Budget guidelines for, Pursuing Maximum Change Velocity Without Violating a Service’s SLO motivation for, Motivation for Error Budgets error rates, Indicators, The Four Golden Signals Escalator, Escalator ETL pipelines, Origin of the Pipeline Design Pattern eventual consistency, Managing Critical State: Distributed Consensus for Reliability executor load average, Utilization Signals F failures, best practices for, Fail Sanely(see also cascading failures) fake backends, Production Probes false-positive alerts, Tagging feature flag frameworks, Feature Flag Frameworks file descriptors, File descriptors Five Whys, Ask “what,” “where,” and “why”, Example Postmortem flow control, A Simple Approach to Unhealthy Tasks: Flow Control FLP impossibility result, How Distributed Consensus Works Flume, Challenges with the Periodic Pipeline Pattern fragmentation, Load Balancing at the Virtual IP Address G gated operations, Enforcement of Policies and Procedures Generic Routing Encapsulation (GRE), Load Balancing at the Virtual IP Address GFE (Google Frontend), Life of a Request, Load Balancing in the Datacenter GFS (Google File System), Detecting Inconsistencies with Prodtest, Highly Available Processing Using Leader Election, Extended Infrastructure-Tracking the State of Cron Jobs, Overarching Layer: Replication global overload, Per-Customer Limits Global Software Load Balancer (GSLB), Networking Gmail, Gmail: Predictable, Scriptable Responses from Humans, Gmail—February, 2011: Restore from GTape Google Apps for Work, Target level of availability Google Compute Engine, Indicators Google production environmentbest practices for, Fail Sanely-SRE Teams complexity of, Software Engineering in SRE datacenter topology, Hardware development environment, Our Development Environment hardware, Hardware Shakespeare search service, Shakespeare: A Sample Service-Job and Data Organization software infrastructure, Our Software Infrastructure system software, System Software That “Organizes” the Hardware-Monitoring and Alerting Google Workflow systemas model-view-controller pattern, Workflow as Model-View-Controller Pattern business continuity and, Ensuring Business Continuity correctness guarantees, Workflow Correctness Guarantees development of, Introduction to Google Workflow stages of execution in, Stages of Execution in Workflow graceful degradation, Load Shedding and Graceful Degradation GTape, Gmail—February, 2011: Restore from GTape H Hadoop Distributed File System (HDFS), Storage handoffs, Clear, Live Handoff “hanging chunk” problem, Trouble Caused By Uneven Work Distribution hardwaremanaging failures, System Software That “Organizes” the Hardware software that “organizes”, System Software That “Organizes” the Hardware-Monitoring and Alerting terminology used for, Hardware health checks, Stop Health Check Failures/Deaths, Practices hermetic builds, Hermetic Builds hierarchical quorums, Quorum composition high-velocity approach, Principles, High Velocity hotspotting, Picking the Right Subset I idempotent operations, Resolving Inconsistencies Idempotently, Cron Jobs and Idempotency incident managementbest practices for, In Summary effective, Managing Incidents formal protocols for, Feeling Safe incident management process, What we learned, Elements of Incident Management Process incident response, Practices managed incident example, A Managed Incident roles, Recursive Separation of Responsibilities template for, Example Incident State Document unmanaged incident example, Unmanaged Incidents when to declare an incident, When to Declare an Incident infrastructure servicesidentifying risk tolerance of, Identifying the Risk Tolerance of Infrastructure Services improved SRE through automation, Faster Action integration proposals, Enforcement of Policies and Procedures integration tests, Integration tests, Integration intent-based capacity planningAuxon implementation, Introduction to Auxon-Introduction to Auxon basic premise of, Our Solution: Intent-Based Capacity Planning benefits of, Our Solution: Intent-Based Capacity Planning defined, Intent-Based Capacity Planning deploying approximation, Approximation driving adoption of, Raising Awareness and Driving Adoption-Designing at the right level precursors to intent, Precursors to Intent requirements and implementation, Requirements and Implementation: Successes and Lessons Learned selecting intent level, Intent-Based Capacity Planning team dynamics, Team Dynamics interruptscognitive flow state and, Cognitive Flow State dealing with, Dealing with Interrupts dealing with high volumes, General suggestions determining approach to handling, Factors in Determining How Interrupts Are Handled distractibility and, Distractibility managing operational load, Managing Operational Load on-call engineers and, On-call ongoing responsibilities, Ongoing responsibilities polarizing time, Polarizing time reducing, Reducing Interrupts ticket assignments, Tickets IRC (Internet Relay Chat), A Recognized Command Post J jobs, Managing Machines Jupiter network fabric, Hardware L labelsets, Labels and Vectors lame duck state, A Robust Approach to Unhealthy Tasks: Lame Duck State latencydefined, Choosing a Strategy for Superior Data Integrity measuring, Indicators monitoring for, The Four Golden Signals launch coordinationchecklist, The Launch Checklist-Example action items, Launch Coordination Checklist engineering (LCE), Launch Coordination Engineering, Development of LCE-Infrastructure churn(see also product launches) lazy deletion, The 24 Combinations of Data Integrity Failure Modes leader election, Managing Critical State: Distributed Consensus for Reliability, Highly Available Processing Using Leader Election lease systems, Reliable Distributed Queuing and Messaging Least-Loaded Round Robin policy, Least-Loaded Round Robin level of service, Service Level Objectives(see also service level objectives (SLOs)) living incident documents, Live Incident State Document load balancingdatacenterdatacenter services and tasks, Load Balancing in the Datacenter flow control, A Simple Approach to Unhealthy Tasks: Flow Control Google's application of, Load Balancing in the Datacenter handling overload, Handling Overload ideal CPU usage, The Ideal Case, The Pitfalls of “Queries per Second” lame duck state, A Robust Approach to Unhealthy Tasks: Lame Duck State limiting connections pools, Limiting the Connections Pool with Subsetting-A Subset Selection Algorithm: Deterministic Subsetting packet encapsulation, Load Balancing at the Virtual IP Address policies for, Load Balancing Policies-Weighted Round Robin SRE software engineering dynamics, Team Dynamics distributed consensus systems and, Capacity and Load Balancing frontendoptimal solutions for, Power Isn’t the Answer using DNS, Load Balancing Using DNS-Load Balancing Using DNS virtual IP addresses (VIPs), Load Balancing at the Virtual IP Address policyLeast-Loaded Round Robin, Least-Loaded Round Robin Round Robin, Simple Round Robin Weighted Round Robin, Weighted Round Robin load shedding, Load Shedding and Graceful Degradation load tests, Overload Behavior and Load Tests lock services, Lock Service, Distributed Coordination and Locking Services logging, Examine Lustre, Storage M machinesdefined, Hardware, Definitions managing with software, Managing Machines majority quorums, Number of Replicas MapReduce, Challenges with the Periodic Pipeline Pattern mean timebetween failures (MTBF), Testing for Reliability, Expect Testing Fail to failure (MTTF), Emergency Response to repair (MTTR), Emergency Response, Faster Repairs, Testing for Reliability memory exhaustion, Memory Mencius algorithm, Stable Leaders meta-software, The Use Cases for Automation Midas Package Manager (MPM), Packaging model-view-controller pattern, Workflow as Model-View-Controller Pattern modularity, Modularity Moiré load pattern in pipelines, Moiré Load Pattern monitoring distributed systemsavoiding complexity in, As Simple as Possible, No Simpler benefits of monitoring, Why Monitor?

pages: 203 words: 14,242

Ship It!: A Practical Guide to Successful Software Projects by Jared R. Richardson, William A. Gwaltney


continuous integration, David Heinemeier Hansson, Donald Knuth, index card, MVC pattern, place-making, Ruby on Rails, web application

Software Development Times, March 2001. 185 Index A C Accidental choices, 3 Agile development, 175 Agility, 11, 64, 106, 160 Ambient orb, 33 Analysis paralysis, 107 Ant, 166 AntHill, 169 Approving code, 97 Architecture and collaboration, 111 Aristotle, 1 Automake, 165 Automated testing maintenance of, 153 Automatic build systems, 98, 99, 9 Canned data, 107 see also Mock objects Capability maturity model, 175 Carmack, John, 12 Circular dependency, 138 Clover, 179 Clumping, bugs, 37 CMM, see Capability maturity model Cobertura, 179 Cockburn, Alistair, 98 Code change notifications, 6, 94, 143 Code freeze, 66 Code libraries, 20 Code reviews, 6, 88, 143 and team cohesion, 146 virtual, 95 Code, legacy, 129 Cognitive overload, 74 Collaboration, 55 Conflicts, 19 Continuous integration, 10, 30, 134, 137, 143, 169 Continuous testing, 133 Continuum, 169 Cooking ham, 8 Covey, Stephen, 60 Craftsmanship, 101 Critical path, 53 Cross-platform testing, 133 CruiseControl, 30, 169 CruiseControl.NET, 10, 169 Crystal, 176 CVS, 24, 162 B Backups, 23 Batch file, 26, 165 BitKeeper, 162 Blog, 85n Broken builds, 34 Broken windows, 119 Buddy builds, 10 Bugs distribution, 37 finding, 90 introducing, 13 regression, 31 reproducing, 135 Bugzilla, 172 Build machine, 17 Build times, 34 Builds, 25, 30 automating, 98, 129 Burn rate, 79 Bus number, 114 Buy-in, see Participation D Daily meetings, 6, 78 example, 83 D AMAGE C ONTROL rules for, 87 DamageControl, 169 Deadlines, 65, 69 Death March project, 156 Decoupling, 110 see also Circular dependancy Defect detection, 90 Defect-driven testing, 46, 154 Deliberate choices, 3 Deliverables, 9 Dependancy, circular, 138 Deprecated routines, 93 Dillard, Annie, 2n Disappearing products, 20 Documentation, 59 Done, determining when, 64, 159 E E-Tester, 179 EDIF, 51 Email notification, 99 Encapsulation, 109, 123 Estimation, 60, 63, 156 Excellence, 2 Expansion, 12 Expectations, 139 eXtreme Programming, 175 F Feature boxing, 65 Feature creep, 40, 158 Feature list, 72 Features, fluff, 63, 74 Features vs. issues, 39 Feedback, 64, 160, 161 Fit, 179 Fitnesse, 179 FogBugz, 172 Ford, Henry, 128 Foundation, 4 Functional tests, 44 Future expansion, 12 G Goals, 64 Grandma, 9 Groovy, 166 H Habits, 2, 155 187 M EETINGS Ham, 8 Heroism, 83 Hippocratic Oath, 93 HTMLUnit, 179 HTTPUnit, 179 I IDE, 16n IDE in batch mode, 27 Information radiators, 98 Infrastructure, 5 Infrastructure overload, 107 Integration tests, 44 Interfaces, 108, 109, 113 Interruptions, 74, 82 Introducing bugs, 13 Introducing practices, 150 Issue distribution, 37 Issues vs. features, 39 Iteration, 106 J Jelly, 51 JIRA, 172 JUnit, 178 JUnitPerf, 178 JWebUnit, 179 L Lava lamps, 33 Leaders, growing, 85 Legacy code, 129 Librarian, 16 Library code, 20 List, The, 57 Load tests, 44 LoadRunner, 179 Losing work, 13 M MAD reviews, 88 make, 165 Manager, nontechnical, 70 Manifesto, agile, 11 Maven, 51, 167 Maven 2, 167 MbUnit, 178 McCarthy, Justin, 9 Meeting alternatives, 82 Meetings daily, 6, 78 M ENTORING frequency, 78 Mentoring, 90, 155 MetaCheck, 42 Micromanagement, 145 Milestone, 116 Mock client tests, 44, 45, 129, 132 Mock Object, 108 Model-View-Controller , 123 Monitoring, 76 Morale, 124 MVC, see Model-View-Controller Myopia, 82 N NAnt, 10, 166 Notification, code change, 6 NUnit, 10, 178 O Open formats, 51 P Pair programming, 88 Parking lot therapy, 141 Participation, 147 Partitioning test data, 18 Patterns, 91 Peer pressure, 90 Performance tests, 44 Perl, 166 Perl mantra, 150n Plante, Dominique, 9 Plog, 85 Post-it Notes, failure of, 37 PR-Tracker, 172 Practice introduction, 150 Prioritization, 59, 61, 62, 64, 74 Problem solving, 96, 118 shared, 81 Process, 5 defined, 105 Production environment, 116 Products, disappearing, 20 Python, 166 Q Quarry worker’s creed, 4 R Rake, 166 188 T ESTING Rational unified process, 176 Raving fan, 151 Raymond, Eric S., 92 Refactoring, 90, 92 Regression, 31 Repository, 16 Requirements, 7, 64, 75, 124, 125, 160 Return on investment, see ROI Reviews, code, 6 Rogues, 141 ROI, 33, 90 RSS feed, 33, 62, 99 defined, 62 Rubber ducking, 89 Ruby, 166 RUP, see Rational unified process S SCM, 14, 19 Scrum, 176 Sharing code, 16 Shell scripts, 26, 165 Sign your work, 92, 101 Smoke tests, 44 Software practices, 1 Source code management system, 14, 19 Spolsky, Joel, 57 Spreadsheet, 57 Sprint, see Iteration Stakeholders, 60, 70, 73 defined, 71 Stealth practice, 152 Subversion, 10, 21, 24, 162 SUnit, 178 Supertools, 15 System object, 109 Systir, 179 T TDB, see Tracer bullet development Teams building, 146 communication, 81 and cooking, 110 trusting, 65 Tech lead, 6 defined, 69 Techniques, 5 Test Driven Refactoring, 131 Testing T ESTING HARNESS partitioning data, 18 Testing harness, 42 Testing, kinds of, 43 The List, 6, 57 example, 67 personal use, 60 rules for, 61 Third-party code, 20 Throwing code out, 120 Time boxing, 65 Toolkit, 3 Tracer bullet development, 6, 104, 175 benefits, 123 example, 120 Tracer bullets defined, 104 Truck number, see Bus number Tumbleweed developers, 79, 80 U Undo button, 19 Unit tests, 43 189 XP V VC, see Source code management system Version control, see Source code management system Visual SourceSafe, 162 W Watercooler, 146 Waterfall model, 119 Watir, 179 wiki, 58, 69 WinRunner, 179 Wizard code, 54 Work, losing, 13 X X10, 33 XML, 51 XP, see eXtreme programming Pragmatic Starter Kit Series Version Control.

You can’t do this type of refactoring and parallelization for every application, but this example illustrates the amazing flexibility and power you get when you clearly define interfaces between different layers of your application. We were able to do major work in one layer without changing the adjacent layers. Another important thing to note is that even though this example discusses using different servers, you don’t have to do that. We use different servers in our scenario to illustrate the demarcation. The same principle applies to an application. Take, for instance, the Model-ViewController (MVC)3 paradigm. When you clearly define the interfaces between the logic, the data, and the graphical user interface (GUI), you free up each group to work independently. In fact, the entire purpose of using MVC is to have this type of encapsulation. TIP 23 An encapsulated architecture is a scalable architecture Selling Tracer Bullets The benefits to the Tracer Bullet Development are enormous.

pages: 485 words: 74,211

Developing Web Applications with Haskell and Yesod by Michael Snoyman


create, read, update, delete, database schema, Debian, domain-specific language, don't repeat yourself, full text search, MVC pattern, web application

By using built-in Yesod constructs like defaultLayout and getMessage, you’ll get a consistent look-and-feel throughout your site, including pages automatically generated by Yesod such as error pages and authentication. We haven’t covered all the methods in the Yesod typeclass in this chapter. For a full listing of methods available, you should consult the Haddock documentation. Chapter 7. Routing and Handlers If we look at Yesod as a Model-View-Controller framework, routing and handlers make up the controller. For contrast, let’s describe two other routing approaches used in other web development environments: Dispatch based on file name. This is how PHP and ASP work, for example. Have a centralized routing function that parses routes based on regular expressions. Django and Rails follow this approach. Yesod is closer in principle to the latter technique.

|] handleDateR :: Integer -> Text -> Int -> Handler RepPlain -- text/plain handleDateR year month day = return $ RepPlain $ toContent $ T.concat [month, " ", T.pack $ show day, ", ", T.pack $ show year] getWikiR :: [Text] -> Handler RepPlain getWikiR = return . RepPlain . toContent . T.unwords The arguments have the types of the dynamic pieces for each route, in the order specified. Also, notice how we are able to use both RepHtml and RepPlain. The Handler Monad The vast majority of code you write in Yesod sits in the Handler monad. If you are approaching this from an MVC (Model-View-Controller) background, your Handler code is the Controller. Some important points to know about Handler: It is an instance of MonadIO, so you can run any IO action in your handlers with liftIO. By the way, liftIO is exported by the Yesod module for your convenience. Like Widget, Handler is a fake-monad-transformer. It wraps around a ResourceT IO monad. We discuss this type at length in the conduits appendix, but for now, we’ll just say it let’s you safely allocate resources.

Chapter 13. Yesod’s Monads As you’ve read through this book, there have been a number of monads that have appeared: Handler, Widget, and YesodDB (for Persistent). As with most monads, each one provides some specific functionality: Handler gives access to the request and allows you to send responses, a Widget contains HTML, CSS, and JavaScript, and YesodDB let’s you make database queries. In Model-View-Controller (MVC) terms, we could consider YesodDB to be the model, Widget to be the view, and Handler to be the controller. So far, we’ve presented some very straightforward ways to use these monads: your main handler will run in Handler, using runDB to execute a YesodDB query, and defaultLayout to return a Widget, which in turn was created by calls to toWidget. However, if we have a deeper understanding of these types, we can achieve some fancier results.

pages: 135 words: 31,098

ClojureScript: Up and Running by Stuart Sierra, Luke Vanderhart


domain-specific language, Firefox, MVC pattern, Paul Graham, web application

If you want more precise control over how your code is compiled, you can invoke the ClojureScript compiler directly from Clojure. Future versions of Clojure and ClojureScript will likely include some kind of conditional evaluation or “feature expressions,” making it possible to maintain a single source file that targets multiple host environments. In any case, the possibilities of having a unified language across servers and web browsers are exciting. Consider some examples: The classic Model-View-Controller pattern, in which the Model can be mirrored on both client and server Unit-testing client and server code in the same process Debugging client code before running it in a browser Summary Being able to work in the same language and data model in both web browsers and web servers is the most compelling feature of ClojureScript. With a little care, most algorithmic or data-centric code can be made to work identically in Clojure and ClojureScript.

Scala in Action by Nilanjan Raychaudhuri


continuous integration, create, read, update, delete, database schema, domain-specific language, don't repeat yourself,, failed state, fault tolerance, general-purpose programming language, index card, MVC pattern, type inference, web application

draggable method Driver class DRY (don’t-repeat-yourself) code DSL DTO (data transfer object) dynamic languages, transitioning from Dynamic type dynamic typing E e.hasMoreElements() method e.withFilter efficiency Elem type EmployeePayrollVisitor end-to-end test environment, for test-driven development equals method Erlang error detection errorLogger() method eta-expansion evenFilter event-based actors exception handling overview extensible components challenge of solving expression problem extensible languages, Scala as external load balancer ExternalPriceCalculator, 2nd, 3rd external-price-calculator-actor-dispatcher externalPriceSource externalPriceSourceCalculator, 2nd ExternalVendor, 2nd ExternalVendor.findAll ExternalVendorProxyActor, 2nd Extractor object, 2nd F F[_] type factory pattern fault tolerance File class file.getName() method FileToCount type, 2nd filter method, 2nd find method findAllByPhase method, 2nd findAllStoriesByPhase method findByDescription, 2nd findCalculator function finder method, 2nd findLowestPrice method findOne method, 2nd FindPrice message, 2nd, 3rd firstName parameter flatMap function, 2nd floating-point types foldLeft method, 2nd, 3rd foldRight method, 2nd forAll method for-comprehensions overview using with collections fork-join fullClasspath Function type Function1 trait functional languages, Scala as Functional Object pattern functional objects functional programming, 2nd ADTs advantages of, 2nd defined function composition function currying higher-order functions methods vs. functions monads managing state using methods used with moving from OOP to modeling purely functional programs object-oriented patterns pure vs. impure programming partial functions pure functional programs recursion in functional style, dependency injection Future divide and conquer mixing with actors vs using actors G Gen class, 2nd, 3rd GenTraversableOnce, 2nd GET method Get method getChronologyUsed() method getCount method getEntity() method getName() method getOrElse method getOrElseUpdate method getResource() method gets method getSender() method Global object greet method GreetingsActor H handle method head :: tail head recursion Hewitt, Carl hierarchy of classes of collections of parallel collections higher-kinded types, 2nd higher-order functions, 2nd Hindley-Milner type host parameter HTTP method, 2nd, 3rd http.proxy environment variable HttpClient library HttpGet method HttpServlet HttpServletRequest Hughes, John I I/O monad identifiers immutable collections immutable data, vs. mutable immutable objects implicit conversion implicit keyword implicit parameters dependency injection overview, 2nd implicits import statements importance, of testing impure programming, vs. pure programming InCompleteOrder Infix Operation pattern init() method, 2nd, 3rd, 4th input Int object Int type, 2nd, 3rd integer types Integer.parseInt integration test, 2nd, 3rd interactive mode internal load balancer InternalPriceCalculator, 2nd, 3rd InternalPriceCalculatorActor internal-price-calculator-actor-dispatcher interoperability with Java Java classes in Scala checked exceptions generics static members Scala classes in Java Scala web applications using Java frameworks model, view, controller using Spring configuration inTransaction method, 2nd invariant, 2nd io.monads package IOMonad type IOResource isDefinedAt method isEmpty method isLeft method isolation isRight method Iterable trait J JapanPayroll method JAR file Java byte code Java class Java Database Connectivity. See JDBC. Java driver, 2nd, 3rd, 4th Java interface, 2nd Java Virtual Machine. See JVM.

TestFindByQuery.scala testing asynchronous messaging systems behavior-driven development specifications for using Specs2 dependency injection cake pattern implicit parameters in functional style structural typing using Spring framework importance of test-driven development setting up environment using JUnit using ScalaCheck example of generators for testing string behavior TestPricingSystem testShouldReturnExternalPrice() this() method, 2nd, 3rd threads, concurrent programming using, challenges of throwableToLeft toString method total function toXml method Trait class traits, 2nd, 5th and class linearization stackable transaction parameter TransactionFailure Traversable parameter trait, 2nd try-finally block Tuple, overview tx method, 2nd type abstraction bounds inference parameterization parameters projection variance type classes, ad hoc polymorphism with modeling orthogonal concerns using solving expression problem using TypedActor types, 7th character floating-point higher-kinded types integer phantom types string structural types XML U unapply method, 2nd, 3rd unapplySeq method Unicode method Unit method universal traits Unix pipes SBT on UntypedActor up$extension method Updatable trait UpdatableCollection class, 2nd uppercase characters, finding url property UrlBasedViewResolver class USContractorPayrollSystem user story UseResource class USPayroll class USPayroll method util.Random class V validate method, 2nd ValidationException, 2nd value classes rules var prefixes variables, overview Vector collection Vector() method views views.index() method W WAR file weather function web applications connecting to databases saving to using Squeryl creating web pages for Kanban boards creating view for defined moving cards in setting up project with SBT SBT adding dependencies build file for for Mac for Unix for Windows project structure for Scalaz HTTP module configuring with SBT overview setting up servlet using Java frameworks model, view, controller using Spring configuration web.xml file weKanban application, 4th, 5th setting up project user stories WeKanbanApplication, 2nd, 3rd, 4th WeKanbanProjectDefinition.scala file, 2nd WeKanbanSchema object while loop Windows, SBT on with keyword withDispatcher method withFilter WordCount implementation using actors WordCount type WordCountMaster class WordCountWorker class, 2nd X XML types XmlConverter xs.clear() method, 2nd List of Figures Chapter 1.

pages: 643 words: 53,639

Rapid GUI Programming With Python and Qt by Mark Summerfield


Debian, Guido van Rossum, loose coupling, MVC pattern, software patent, sorting algorithm, web application

A solution is provided in chap13/pythoneditor_ans.pyw. 14 ● Using the Convenience Item Widgets ● Creating Custom Models ● Creating Custom Delegates Model/View Programming Model/view programming is a technique that involves separating data from its visual representation. It was first popularized as the MVC (model/view/ controller) paradigm used in the Smalltalk programming language. A model is a class that provides a uniform interface through which data items can be accessed. A view is a class that can present the data items from a model to the user on-screen. A controller is a class that mediates between the user interface (e.g., mouse events and key presses) to provide a means by which users can manipulate data items. View Controller or Delegate Model Dataset Figure 14.1 Model/view/controller and model/view/delegate The MVC approach offers several benefits. For example, huge datasets can be handled, because only the data that is actually displayed or edited is read or written from or to the data source.

pages: 554 words: 108,035

Scala in Depth by Tom Kleenex, Joshua Suereth


discrete time, domain-specific language, fault tolerance, MVC pattern, sorting algorithm, type inference

Asynchronous I/O and actors are a natural pairing, as the execution models for these are similar. Using an actor to perform blocking I/O is asking for trouble. That actor can starve other actors during this processing. This can be mitigated, as we’ll discuss in section 9.4. Although many problems can be successfully modeled in actors, some will benefit more. The architecture of a system designed to use actors will also change fundamentally. Rather than relying on classic Model-View-Controller and client-based parallelism, an actors system parallelizes pieces of the architecture and performs all communication asynchronously. Let’s look at a canonical example of a good system design using actors. This example uses several tools found in the old Message Passing Interface (MPI) specification used in supercomputing. MPI is worth a look, as it holds a lot of concepts that have naturally translated into actor-based systems. 9.1.1.

pages: 713 words: 93,944

Seven Databases in Seven Weeks: A Guide to Modern Databases and the NoSQL Movement by Eric Redmond, Jim Wilson, Jim R. Wilson


Amazon Web Services, create, read, update, delete, data is the new oil, database schema, Debian, domain-specific language,, fault tolerance, full text search, general-purpose programming language, linked data, MVC pattern, natural language processing, node package manager, random walk, recommendation engine, Ruby on Rails, Skype, social graph, web application

Because Mongo is focused on large datasets, it works best in large clusters, which can require some effort to design and manage. Unlike Riak, where adding new nodes is transparent and relatively painless for operations, setting up a Mongo cluster requires a little more forethought. Parting Thoughts Mongo is an excellent choice if you are currently using a relational database to store your data through an ORM out of habit. We often recommend it to Rails, Django, and Model-View-Controller (MVC) developers, since they can then perform validations and field management through the models at the application layer and because schema migrations become a thing of the past (for the most part). Adding new fields to a document is as easy as adding a new field to your data model, and Mongo will happily accept the new terms. We find Mongo to be a much more natural answer to many common problem scopes for application-driven datasets than relational databases.

pages: 603 words: 141,814

Python for Unix and Linux System Administration by Noah Gift, Jeremy M. Jones


Amazon Web Services, bash_history, Bram Moolenaar, cloud computing, create, read, update, delete, database schema, Debian, distributed revision control, Firefox, Guido van Rossum, industrial robot, inventory management, job automation, Mark Shuttleworth, MVC pattern, skunkworks, web application

Django Django is a full-stack web application framework. It contains a templating system, database connectivity by way of an object-relational mapper, and, of course, Python itself for writing the logic pieces of the application. Related to being a “full stack” framework, Django also follows a Model-View-Template (MVT) approach. This Model-View-Template approach is similar, if not identical, to a common approach called Model-View-Controller (MVC). Both are ways of developing applications so that the pieces of the application are not unnecessarily comingled. The database code is separated into an area referred to in both approaches as the “model.” The business logic is separated into an area referred to as the “view” in MVT and the “controller” in MVC. And the presentation is separated into an area referred to as the “template” in MVT and the “view” in MVC.

pages: 834 words: 180,700

The Architecture of Open Source Applications by Amy Brown, Greg Wilson


8-hour work day, anti-pattern, bioinformatics,, cloud computing, collaborative editing, combinatorial explosion, computer vision, continuous integration, create, read, update, delete, David Heinemeier Hansson, Debian, domain-specific language, Donald Knuth,, fault tolerance, finite state, Firefox, friendly fire, Guido van Rossum, linked data, load shedding, locality of reference, loose coupling, Mars Rover, MVC pattern, peer-to-peer, Perl 6, premature optimization, recommendation engine, revision control, Ruby on Rails, side project, Skype, slashdot, social web, speech recognition, the scientific method, The Wisdom of Crowds, web application, WebSocket

Compared to WikiCalc, the server's role has been greatly reduced. Its only responsibility is responding to HTTP GETs by serving entire spreadsheets serialized in the save format; once the browser receives the data, all calculations, change tracking and user interaction are now implemented in Javascript. Figure 19.6: SocialCalc Class Diagram The Javascript components were designed with a layered MVC (Model/View/Controller) style, with each class focusing on a single aspect: Sheet is the data model, representing an in-memory structure of a spreadsheet. It contains a dictionary from coordinates to Cell objects, each representing a single cell. Empty cells need no entries, and hence consume no memory at all. Cell represents a cell's content and formats. Some common properties are shown in Table 19.1. RenderContext implements the view; it is responsible for rendering a sheet into DOM objects.