Wednesday, March 8, 2017

Prototype - Overview

What is Prototype ?

Prototype is a JavaScript Framework that aims to ease the development of dynamic web applications. Prototype was developed by Sam Stephenson.
Prototype is a JavaScript library, which enables you to manipulate DOM in a very easy and fun way that is also safe (cross-browser).

Prototype - Useful Features

Let's now look at what Prototype can do specifically for us to develop a Dynamic Web Application.

Cross Browser Support

While doing JavaScript programming, it is required to handle different Web Browsers differently. Prototype Library has been written in such a way that it takes care of all the compatibility issues and you can do cross browser programming without any hassle.

Prototype - Utility Methods

The Prototype library comes with lot of predefined objects and utility functions. You can use those functions and objects directly in your JavaScript programming.
These methods are one of the cornerstones of efficient Prototype-based JavaScript coding. Spend some time to study them to become comfortable with the methods.

Prototype - Element Object

The Element object provides various utility functions for manipulating elements in the DOM.
Here is the list of all the utility functions with examples. All the methods defined here are automatically added to any element accessed using the $() function.
So, writing Element.show('firstDiv'); is the same as writing $('firstDiv').show();

Prototype - Number Processing

Prototype extends native JavaScript numbers in order to provide −
  • ObjectRange compatibility, through Number#succ.
  • Ruby-like numerical loops with Number#times.
  • Simple utility methods such as Number#toColorPart and Number#toPaddedString.

Prototype - String Processing

Prototype enhances the String object with a series of useful methods ranging from the trivial to the complex.
Here is the list of all the functions with examples dealing with String.

Prototype String Methods

NOTE − Make sure you have the prototype.js version of 1.6.

Prototype - Array Processing

Prototype extends all the native JavaScript arrays with quite a few powerful methods.
This is done in two ways −
  • It mixes in the Enumerable module, which brings a ton of methods in already.
  • It adds quite a few extra methods, which are documented in this section.

Prototype - Hash Processing

Hash can be thought of as an associative array binding unique keys to values. Only difference is that you can use any string as an index instead of just using a number as index.

Prototype - Basic Object

Object is used by Prototype as a namespace and to call related function using Object object. This is used in the following two ways −
  • If you are a simple developer, then you can use the existing functions like inspect or clone.
  • If you are one who wishes to create their own objects like Prototype does, or explore objects as if they were hashes, will turn to extend, keys and values.

Prototype - Templating

Templates are used for formatting group of similar objects and to produce formatted output for these objects.
Prototype provides a Template class, which has two methods −
  • Template() − This is a constructor method, which is used to create a template object and call evaluate() method to apply template.
  • evaluate() − This method is used to apply a template to format an object.

Prototype - Enumerating

Enumerable class provides a large set of useful methods for enumerations. Enumerations are objects that act as collection of values.
Enumeration methods are mostly used to enumerate arrays and hashes. There are other objects as well like ObjectRange and various DOM- or AJAX-related objects where you can use enumeration methods.

Prototype - Event Handling

Event management is one of the biggest challenges to achieve cross-browser scripting. Every browser has different approaches to handle key strokes.
Prototype Framework handles all cross browser compatibility issues and keeps you free from all trouble related to event management.

Prototype - Form Management

Prototype provides an easy way to manage HTML forms. Prototype's Form is a namespace and a module for all things form-related, packed with form manipulation and serialization goodness.
While it holds methods dealing with forms as a whole, its sub module Form.Element deals with specific form controls.

Prototype and JSON Tutorial

Introduction to JSON

JSON (JavaScript Object Notation) is a lightweight data-interchange format.
  • JSON is easy for humans to read and write.
  • JSON is easy for machines to parse and generate.
  • JSON is based on a subset of the JavaScript Programming Language.

Prototype and AJAX Tutorial

Introduction to AJAX

AJAX stands for Asynchronous JavaScript and XML. AJAX is a new technique for creating better, faster, and more interactive web applications with the help of XML, HTML, CSS and Java Script.
For a complete understanding on AJAX, please go through our simple AJAX Tutorial.

Prototype - Expressing Range

Prototype Ranges represent an interval of values. The preferred way to obtain a range is to use the $R utility function.
You can create a big range of values using a simple syntax as follows −
$R(1, 10).inspect();

$R('a', 'e').inspect();
This will produce the following result −

Prototype - Periodical Execution

Many times it is required to execute a function many times after a certain period of time. For example, you may want to refresh your screen after a given time. Prototype provides a simple mechanism to implement it using PeriodicalExecuter object.
The advantage provided by PeriodicalExecuter is that it shields you against multiple parallel executions of the callback function.

Prototype - Quick Guide

Prototype - Overview

What is Prototype ?

Prototype is a JavaScript Framework that aims to ease the development of dynamic web applications. Prototype was developed by Sam Stephenson.
Prototype is a JavaScript library, which enables you to manipulate DOM in a very easy and fun way that is also safe (cross-browser).

Prototype - Useful Resources

The following resources contain additional information on Prototype. Please use them to get more in-depth knowledge on this.

Discuss Prototype

This tutorial gives a complete understanding on Prototype. Prototype is distributed as a single file called prototype.js. Prototype is an object in javascript from which other objects inherit properties.

Phalcon - Overview

Phalcon is introduced as one of the recent frameworks of PHP, developed by a group of enthusiastic developers. Phalcon is a loosely coupled framework, which means it allows its objects to be treated like glue components, based on the needs of application.

Phalcon - Environmental Setup

Prerequisites − We need WAMP/LAMP/MAMP or XAMPP stack for this framework.
Following are the steps for the installation process of Phalcon framework in Windows.
Step 1 − Phalcon installation is completely dependent on dll file. DLL (Dynamic Link Library) creates the required package and plugins for Phalcon.

Phalcon - Application Structure

In this chapter, we will discuss the Application Structure of Phalcon. Following is the complete directory structure of a Phalcon project.

Phalcon - Functionality

Model View Controller (MVC) is a software design and structural pattern for developing webbased applications. This software architectural separates the representation of information from the user's interaction with it.

Phalcon - Configuration

The config folder of the web application includes the following files −
  • config.php
  • loader.php
  • services.php

Phalcon - Controllers

In MVC framework, “C” stands for the Controller which refers to the switchboards of the web application. The actions undertaken by the controller, helps to pass parameters to the view so that it can display and respond to the user input accordingly.

Phalcon - Models

Model in MVC architecture includes the logic of application. Model is the core interaction with the database. It should be able to manage updating, deleting, inserting, and fetching of records as per the user’s request.
For understanding the model interaction in Phalcon PHP framework, following steps should be followed.
Step 1 − Creation of database.

Phalcon - Views

Views are information being presented to the end user. A view can be considered as a web page with the appropriate response to be displayed. The response is received through the controller which interacts with the model.

Phalcon - Routing

The router component allows to define routes that are mapped to the controllers or handlers that should receive the request. A router parses a URI as per the information received.
Every router in the web application has two modes −

Phalcon - Database Connectivity

In this chapter, we will discuss the database connectivity related to Phalcon.

Creation of Database and Design

We will focus on creating a database for blogs which maintains posts along with the categories as per the entries of users.
Database Name: blog-tutorial
Query used for creating the database −

Phalcon - Switching Databases

We have used a MySQL database in our application. If we wanted to change the database software midstream, it would not be too hard, as long as we have the same data structure in our new database.

Phalcon - Scaffolding Application

Scaffolding usually refers to a type of code generation where we point it to a web application database, which results in creating a basic CRUD (Create, Read, Update, Delete) application.
Before designing a CRUD application, it is important to design database tables as per the need of the application.

Phalcon - Query Language

Phalcon Query Language (PHQL) also called as PhalconQL is a high-level SQL dialect which standardizes SQL queries for the database systems supported by Phalcon.
It includes a parser, written in C, which translates the syntax in target RDBMS.
Here is a list of some of the prominent features of Phalcon query language −

Phalcon - Database Migration

Database migration is important for the following reasons −
  • Database migration helps in transferring data between the specified storage types.
  • Database migration refers to the context of web-based applications migrating from one platform to another.
  • This process usually takes place to keep a track of data which is being outdated.

Phalcon - Cookie Management

Cookies also known as browser cookies are small text files stored in the browser. It saves all the information related to user identity. This information is used to validate the users once they browse through different pages.
There are two different types of Cookies −

Phalcon - Session Management

Sessions are server-side information storage which helps in user interaction with the website or web application. Each session is uniquely defined with a session ID, which is passed to the web server whenever the browser makes an HTTP request. The session ID is paired every time with the internal database such that all stored variables are retrieved.

Phalcon - Multi-Lingual Support

Phalcon includes a component Phalcon\Translate which provides multi-lingual support and it is very helpful to create web pages, which gets translated in multiple languages.
It includes an adapter which helps in binding arrays and assists in reading translation messages.

Phalcon - Asset Management

Assets are all about the additional components apart from the existing framework in Phalcon. Phalcon has an asset manager which helps to manage all the asset components like CSS or JS files.
The common methods used are −

Phalcon - Working with Forms

Forms are used in all web applications to accept inputs from the user as request. The data is accepted as an input, then manipulated and saved in the database or any other operation is being performed.
Phalcon includes a component named Phalcon\Forms which helps in the creation and maintenance of forms.
Consider the example of Blog-tutorial, which we created in the previous chapters. It includes a form which is used to create a new category.

Phalcon - Object Document Mapper

Before starting with the concepts of Object Relational Mapper (ORM) and Object Document Mapper (ODM), it is important to understand the difference between SQL and NoSQL databases.
The following table highlights the differences between SQL and NoSQL −

Phalcon - Security Features

Phalcon provides security features with the help of Security component, which helps in performing certain tasks like password hashing and Cross-Site Request Forgery (CSRF).

Hashing Password

Hashing can be defined as the process of converting a fixed length bit string into a specified length in such a way that it cannot be reversed. Any change in the input string will change the value of hashed data.

Phalcon - Quick Guide

Phalcon - Overview

Phalcon is introduced as one of the recent frameworks of PHP, developed by a group of enthusiastic developers. Phalcon is a loosely coupled framework, which means it allows its objects to be treated like glue components, based on the needs of application.

Phalcon - Useful Resources

The following resources contain additional information on Phalcon. Please use them to get more in-depth knowledge on this.

Discuss Phalcon

Phalcon is an open source framework quite popular among developers. It is a combination of PHP and C language. Phalcon is developed by Andres Gutierrez and his group of collaborators. This tutorial provides an overall idea on Phalcon PHP framework and how you can use it.

MVC Framework - Introduction

What is MVC?

The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components are built to handle specific development aspects of an application. MVC is one of the most frequently used industry-standard web development framework to create scalable and extensible projects.

MVC Framework - Architecture

In the last chapter, we studied the high-level architecture flow of MVC Framework. Now let us have a look at how the execution of an MVC application takes place when certain request comes from the client. The diagram below shows the flow:

MVC Framework - ASP.NET Forms

MVC and ASP.NET Web Forms are inter-related but different models of development depending on the requirement of the application and other factors. At a high level, you can consider that MVC is a more advanced and sophisticated web application framework designed with separation of concerns and testability in mind.

MVC Framework - First Application

Let us jump in and create our first MVC application using Views and Controllers. Once we have a small hands-on experience on how a basic MVC application works, we will learn all the individual components and concepts in coming chapters.

MVC Framework - Folders

Now that we have already created a sample MVC application, let us understand the folder structure of an MVC project. We will create new MVC project to learn this.
In your visual studio, open File->New->Project and select ASP.NET MVC Application. Name it as MVCFolderDemo.

MVC Framework - Models

The model is responsible for managing the data of the application. It responds to the request from the view and it also responds to instructions from the controller to update itself.
Model classes can either be created manually or generated from database entities. We are going to see a lot of examples for manually creating Models in coming chapters.

MVC Framework - Controllers

Asp.net MVC Controllers are responsible for controlling the flow of the application execution. When you make a request (means request a page) to MVC applications, a controller is responsible for returning the response to that request. A controller can have one or more actions. A controller action can return different types of action results to a particular request.

MVC Framework - Views

As seen in the initial introductory chapters, Views are the components involved with application's User Interface. These Views are generally bind from the model data and have extensions like html, aspx, cshtml, vbhtml, etc. In our First MVC Application, we had used Views with Controller to display data to the final user. For rendering these static and dynamic content to the browser, MVC Framework utilizes View Engines. View Engines are basically markup syntax implementation which are responsible for rendering the final HTML to the browser.

MVC Framework - Layouts

Steps to create MVC Layouts

Layouts are used in MVC to provide consistent look and feel on all the pages of our application. It is same as defining the Master Pages but MVC gives some more functionalities
Step 1: Create a sample MVC application with Internet application as Template and create a Content folder in the root directory of the web application.

MVC Framework - Routing Engine

Introduction to Routing

ASP.NET MVC Routing enables use of URLs that are descriptive of the user actions and are more easily understood by the users. At the same time, Routing can be used to hide data which is not intended to be shown to the final user. For example, in an application that does not uses routing, user would be shown the URL as http://myapplication/Users.aspx?id=1 which would correspond to the file Users.aspx inside

MVC Framework - Action Filters

In ASP.NET MVC, controllers define action methods and these action methods generally have a one-to-one relationship with UI controls such as clicking a button or a link, etc. For example in one of our previous examples, the UserController class contained methods UserAdd, UserDelete, etc.

MVC Framework - Advanced Example

In the First MVC Tutorialchapter, we learnt how Controllers and Views interact in MVC. In this tutorial, we are going to take a step forward and learn how to use Models and create an advanced application to create, edit, delete and view list of users in our application.

MVC Framework - Ajax Support

Introduction

As you might be knowing, Ajax is a shorthand for Asynchronous JavaScript and XML. The MVC Framework contains built-in support for unobtrusive Ajax by which you can use the helper methods to define your Ajax features without adding code throughout all the views. This feature in MVC is based on the jQuery features.

MVC Framework - Bundling

Bundling and Minification are two performance improvement techniques that improves the request load time of the application. Most of the current major browsers limit the number of simultaneous connections per hostname to six. It means that at a time, all the additional requests will be queued by the browser.

MVC Framework - Exception Handling

In ASP.NET, error handling is done using the standard try catch approach or using application events. ASP.NET MVC comes with built-in support for exception handling using a feature known as exception filters. We are going to learn two approaches here: one with overriding the onException method and another by defining the HandleError filters.

MVC Framework Questions and Answers

MVC Framework Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Certification Exams and Job Interviews. This section provides a useful collection of sample Interview Questions and Multiple Choice Questions (MCQs) and their answers with appropriate explanations.

MVC Framework - Resources

The following resources contain additional information on MVC Framework. Please use them to get more in-depth knowledge on this.

Discuss MVC Framework

As per the official definition, Model-view-controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user.