Wednesday, June 12, 2019

Tutorial 10 – Client-side development 2 - RiWAs

PROGRAMMING APPLICATIONS AND FRAMEWORKS                                              
Tutorial 10


Distinguish the term “Rich Internet Applications” (RIAs) from “Rich Web-based Applications” (RiWAs)

•Rich Web-based applications
   •Use advanced GUIs
   •Use Delta-Communication
   •Provide rich user experience
 •Most of the web-based applications nowadays are RiWAs

 The key features of RiWAs, which make them more advanced than the standard web-based applications

•Rich GUIs in RiWAs use Delta-Communication to communicate with the server components
•DC happens behind the GUI
  •Eliminates page refreshes

•DC can process asynchronously
  •Eliminates page freezing

•DC works faster
  •Eliminates the work-wait pattern

 Different technologies and techniques used to develop the client-side components of the RiWAs, explaining their use in dedicated environments.

 Delta-Communication is, discussing the advantages of using it

Simple-Pull-Delta-Communication (SPDC) can be seen as the simplest form of DC
“Simple Pull Delta-Communication” (SPDC). Since the. SPCD concept is abstract, it is TTs independent and can be developed for both browser-based and non-browser-based clients. We defined the SPDC technique as follows

•Used in AJAX
 •Single XHR request to the server 
•Client-side: Native JS support 
•Server-side: special technology is not needed

 Synchronous and asynchronous communication in the context of DC

 Synchronous vs. asynchronous mode The distinct feature of the rich communication model of the RIAs is generally considered as the asynchronous mode of it, and this model is generally called asynchronous communication, because of this ability. However, the asynchronous mode is a controversial aspect In asynchronous mode, the GUI of the web page does not get blocked once the request is sent, till the response is arrived, processed, and the results are displayed [28]; instead, the user can continue using the application/GUI. In this asynchronous mode, once the response is received, it is processed in the background, by a dedicated application components in the client-side [28]. The asynchronous communication model facilitates the user to experience the results of the communication, even without knowing the execution or the processing of the request. Basically, there is nothing synchronous or asynchronous in this communication; it’s only the way the features, which utilize this communication is developed. Through the experiments we noted that the user experience of the rich features, which utilize the rich communication model, can be offered in either synchronous (blocking) or asynchronous (non-blocking) mode; and it is determined upon the requirements. For example, in the case of performing the transaction, the user has to wait until the transaction is completed, before continuing to use some other features of the application; therefore it should be implemented in synchronous mode. In the case of sending a mail, the user can click on the send mail button and continue reading other mails, while the mail is being processed and sent in background; thus it can be implemented in asynchronous mode.

Different types of technologies and techniques available for DC

Delta-Communication can be seen as the power of Rich Internet Applications, and there are different Techniques and Technologies available for the development of Delta-Communication, which should be selected carefully into the Rich Internet Application development. Enough discussions are not available, which compare and contrast these Delta-Communication development Techniques and Technologies towards supporting decision making of selecting them. This paper provides an overview of the contemporary Techniques and Technologies available for the Delta-Communication development, contextually compares them aligning to some selected criteria, and finally discusses some facts to be considered when selecting them for the Rich Internet Application development. A literature survey on the Delta-Communication development Technologies and Techniques was conducted, which was followed by a series of experiments towards getting the empirical evidence for the comparison. During the contextual comparison, the Simple Pull Delta-Communication was identified as the least complex technique and the WebSocket was noted as the highest complex technology.

The history and the evolution of the XHR and AJAX.

AJAX:
In the article that coined the term Ajax, Jesse James Garrett explained that the following technologies are incorporated: HTML (or XHTML) and CSS for presentation.
AJAX is a technique for creating fast and dynamic web pages. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page




XHR:
XMLHttpRequest (XHR) is an API in the form of an object whose methods transfer data between a web browser and a web server. The object is provided by the browser's JavaScript environment.
XMLHttpRequest (XHR) is a browser-level API that enables the client to script data transfers via JavaScript. ... However, the power of XHR is not only that it enabled asynchronous communication within the browser, but also that it made it simple.


The role of the DC-engine in RiWAs

TTs for the non-browser-based client-components of RiWAs The standard desktop application development TTs like JAVA or.Net and related libraries/frameworks can be utilized for non-browser-based client-components development. For DC development, these frameworks may contain their own tools or some third-party frameworks/libraries can be incorporated. The TTs discussed under the proprietary plugin based approach (in Section IV.1.a) also have the capability of developing non-browser-based client-components, which are executed on dedicated runtimes; for example, Flash/Flex [13] use the Flash player or Adobe AIR runtimes. They are usually augmented with rich tools for developing communication connectors to utilize the service of the Web. Nowadays, the mobile apps also communicate with server components thus, they can be seen as the client-components of RiWAs. Popular mobile development frameworks like Android and IOS encompass communication development tools into their packages. Additionally, even devices in IoT based systems can be exploited as client components of RiWAs. Therefore, related TTs like Arduino Programming Language [17] for Arduino devices, Python for Raspberry Pi devices [18], and related frameworks/libraries/protocols like MQTT [19] [20] can also, be listed under the non-browser-based client-component development TTs. B. TTs for the Server-Components of RiWAs The server-components of RiWAs are similar to Web-based applications [2]. Additionally, in server-side, they need a dedicated component(s) for handling DC. Fig. 2 illustrates the taxonomy for the server-component(s) development TTs of RiWAs. The “Web application” node, represents the standard server-side development TTs such as PHP, JAVA, ASP.Net, Python, etc. and related frameworks/Libraries like CodeIgniter for PHP [21], Struts for JAVA [22], etc. 

The Web services use dedicated TTs such as SOAP [23], REST [24], and frameworks/libraries like JAX-WS [25] and JAX-RS [26] for JAVA, Slim for PHP [27], etc. The behavior of the web services is different from the Web applications in the context of service exposure to other components via Application Program Interfaces (API). The Enterprise Service Bus (ESB) in Service Oriented Architecture (SOA) [28] or similar concepts can be used to extend the standalone RiWAs into multi-tire RiWAs using dedicated TTs. The concept of cloud computing [29] can also be related to these TTs, where the cloud-based systems provide a platform to deliver a service oriented functionalities. The concepts of Web services, SOA, and cloud computing incorporates wide and self-contained domains, which the deep discussions are intentionally avoided in this paper. In the given taxonomy for the server-component(s) of RiWAs, all the types of TTs are supposed to be contained with DC implementation tools. C. TTs for the Connector Elements of RiWAs Connector development TTs can be seen as the core of RiWAs development TTs. In addition to the connector of Web-based applications, the connectors in RiWAs incorporate DC, where both the client and server should contain components for handling DC. For the communication in RiWAs, a union of the communication development TTs of traditional Web-based systems and the DC development TTs is accepted.

 The role of the DC-Bus, indicating how a web-service can be effectively used to implement it


 Algorithms for the request and response processing of DC

The server is not required to transmit a delta-encoded response.  For
   example, the result might be larger than the current size of the
   resource.  The server might not be able to compute a delta for this
   type of resource (e.g., a compressed binary format); the server might
   not have sufficient CPU cycles for the delta computation; the server
   might not support any of the delta formats supported by the client;
   or, the network bandwidth might be high enough that the delay
   involved in computing the delta is not worth the delay avoided by
   sending a smaller response.

   However, if the server does want to compute a delta, and the set of
   encodings it supports has more than one encoding in common with the
   set offered by the client, which encoding should it use?  This is
   mostly at the option of the server, although the client can express
   preferences using "Quality Values" (or "qvalues") in the "A-IM"
   header.  The HTTP/1.1 specification [10] describes qvalues in more
   detail.  (Clients may prefer one delta encoding format over another
   that generates a smaller encoding, if the decoding costs for the
   first format are lower and the client is resource-constrained.)

   Server implementations have a number of possible approaches.  For
   example, if CPU cycles are plentiful and network bandwidth is scarce,
   the server might compute each of the possible encodings and then send
   the smallest result.  Or the server might use heuristics to choose an
   encoding format, based on things such as the content-type of the
   resource, the current size of the resource, and the expected amount
   of change between instances of the resource.

   Note that it might pay to cache the deltas internally to the server,
   if a resource is typically requested by several different delta-
   capable clients between modifications.  In this case, the cost of
   computing a delta may be amortized over many responses, and so the
   server might use a more expensive computation.

 variation of the jQuery ajax() function and related options 


Sometimes, we need more control over the Ajax calls we want to make. For example, we want to specify what should happen in case an Ajax call fails or we need to perform an Ajax request but its result is only needed if retrieved within a certain amount of time. In such situations, we can rely on another function provided by jQuery, called $.ajax(),

There are a lot of different options you can specify to bend $.ajax() to your need. In the list below you can find their names and their description sorted in alphabetic order:
  • accepts: The content type sent in the request header that tells the server what kind of response it will accept in return
  • async: Set these options to false to perform an asynchronous request
  • beforeSend: A pre-request callback function that can be used to modify the jqXHRthe object before it is sent
  • cache: Set these options to false to force requested pages not to be cached by the browser
  • complete: A function to be called when the request finishes (after success and error callbacks are executed)
  • contents: An object that determines how the library will parse the response
  • contentType: The content type of the data sent to the server
  • context: An object to use as the context (this) of all Ajax-related callbacks
  • converters: An object containing dataType-to-dataType converters
  • crossDomain: Set this property to true to force a cross-domain request (such as JSONP) on the same domain
  • data: The data to send to the server when performing the Ajax request
  • dataFilter: A function to be used to handle the raw response data of XMLHttpRequest
  • dataType: The type of data expected back from the server
  • error: A function to be called if the request fails
  • global: Whether to trigger global Ajax event handlers for this request
  • headers: An object of additional headers to send to the server
  • ifModified: Set this option to true if you want to force the request to be successful only if the response has changed since the last request
  • isLocal: Set this option to true if you want to force jQuery to recognize the current environment as “local”
  • jsonp: A string to override the callback function name in a JSONP request
  • jsonpCallback: Specifies the callback function name for a JSONP request
  • mimeType: A string that specifies the mime type to override the XHR mime type
  • password: A password to be used with XMLHttpRequest in response to an HTTP access authentication request
  • processData : Set this option to false if you don’t want that the data passed into the data option (if not a string already) will be processed and transformed into a query string
  • scriptCharset: Sets the charset attribute on the script tag used in the request but only applies when the “script” transport is used
  • statusCode: An object of numeric HTTP codes and functions to be called when the response has the corresponding code
  • success: A function to be called if the request succeeds
  • timeout: A number that specifies a timeout (in milliseconds) for the request
  • traditional: Set this to true if you wish to use the traditional style of param serialization
  • type: The type of request to make, which can be either “POST” or “GET”
  • url: A string containing the URL to which the request is sent
  • username: A username to be used with XMLHttpRequest in response to an HTTP access authentication request
  • xhr: A callback for creating the XMLHttpRequest object
  • xhrFields: An object to set on the native XHR object
That was pretty long, isn’t it? Well, as developers you probably have stopped reading this list at the fifth or sixth element I guess, but that’s fine. The next section will be more exciting because we’ll put them $.ajax() function and some of these options into action.

Tuesday, May 14, 2019

Tutorial 09 – Client-side development 1 - jQuery

PROGRAMMING APPLICATIONS AND FRAMEWORKS                                              
Tutorial 09


1. Is jQuery a framework or a library? 

A framework is something that usually forces a certain way of implementing a solution, whereas jQuery is just a tool to make implementing what you want to do easier. jQuery: The Write Less, Do More, JavaScript Library. For sure, it's a javascript library. ... And jQuery is just a single library 
Then jQuery is not a framework.


2. Explain the features provided by jQuery? 

•Reveal GUI elements
 •Change content (based on users’ actions) 
•Change CSS 
•Delta-Communication (Ajax)




jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is a JavaScript toolkit designed to simplify various tasks by writing less code. Here is the list of important core feature supported by jQuery 





3. Discuss the advantages and disadvantages of using jQuery in different project scales. 

The advantages of jQuery. The main advantage of jQuery is that it is much easier than its competitors. You can add plugins easily, translating this into a substantial saving of time and effort. ... Another advantage of jQuery over its competitors such as Flash and pure CSS is its excellent integration with AJAX

Advantages:
The main advantage of jQuery is that it is much easier than its competitors. You can add plugins easily, translating this into a substantial saving of time and effort. In fact, one of the main reasons why Resig and his team created jQuery was to buy time (in the web development world, time matters a lot).
The open source license of jQuery allows the library to always have constant and fast support, constantly publishing updates. The jQuery community is active and extremely hardworking.
Another advantage of jQuery over its competitors such as Flash and pure CSS is its excellent integration with AJAX
Disadvantages:

One of the main disadvantages of jQuery is a large number of published versions in a short time. It does not matter if you are running the latest version of jQuery, you will have to host the library yourself (and update it constantly), or download the library from Google (attractive, but can bring incompatibility problems with the code).
In addition to the problem of the versions, other disadvantages that we can mention:
  • jQuery is easy to install and learn, initially. But it’s not that easy if we compare it with CSS
  • If jQuery is improperly implemented as a Framework, the development environment can get out of control.

4. Explain how the jQuery handles the issues related to partial page loads to the browser. 

Through an extraordinary amount of hard work, jQuery effectively provides cross-browser compatibility for DOM traversal and manipulation, Event handling and delegation, XHR/Ajax logic, Element selection and document queries, Element attribute, and data management, as well as simple object management utilities. It does so without modifying the browser's native javascript implementation by providing a comprehensive abstraction layer.

5. Discuss the selectors and their use in jQuery. 

jQuery Selector is a function which makes use of expressions to find out matching elements from a DOM based on the given criteria. Simply you can say, selectors are used to selecting one or more HTML elements using jQuery

jQuery selectors enable you to find DOM elements on the web page. ... XQuery includes various selector patterns e.g element name, #id, attributes, descendant elements, CSS class, input types, etc.


jQuery can use CSS selectors
 Additionally, provides advanced selectors to access elements faster and efficiently



6. Compare and contrast the use of CSS advanced selectors in jQuery and jQuery’s DOM traversal API, indicating the pros and cons of them. 




jQuery provides API to traverse through the DOM 
These DOM navigating APIs are faster than advanced CSS like selectors

Can navigate through the DOM, element by element
Can use DOM element objects

7. Explain the importance of DOM objects and DOM processing in jQuery. 

Introduction. The Document Object Model (DOM) is a programming API for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated. ... Nevertheless, XML presents this data as documents, and the DOM may be used to manage this data

8. Discuss the benefits of using jQuery event handling over HTML event attributes, providing a list of events supported by jQuery. 



9. Explain how to declare jQuery event handlers outside the $(document).ready() function, indicating the need for that, and the related issues and solutions for them. 

Definition and Usage. The ready event occurs when the DOM (document object model) has been loaded. Because this event occurs after the document is ready, it is a good place to have all other jQuery events and functions. Like in the example above. The ready() method specifies what happens when a ready event occurs.

10. Identify a list of advanced features provided by jQuery and explain their use towards improving the user experience. 

•(this) object refers to the current object within the scope 
•Inside event handlers, (this) refers to the element, the event has triggered on

Data attributes


Refactoring with DOM objects

Target on specific elements with generic names


Filters

CSS manipulation

Animation


Tutorial 08 – Introduction to client-side development

PROGRAMMING APPLICATIONS AND FRAMEWORKS                                              
Tutorial 08


1. What are the main elements of client-side application components of distributed systems? 


•Distributed systems use client-side elements for users to interact with •These client-side elements include 
       •Views – what users see (mainly GUIs) 
       •Controllers – contain event handlers for the Views 
       •Client-model – Business logic and data

2. Discuss the Views development technologies for the browser-based client-components of web-based applications 
•Content – HTML
• Formatting – CSS

3. Discuss the Controller development technologies for the browser-based client-components of web-based applications 
HTMLCSSJavaScript and server-side technologies such as PHPASP,.Net, C#, Python, etc. 
as well as a database to store and retrieve information from 
(MySQLOracleSQL 



4. Discuss the client-Model development technologies for the browser-based clientcomponents of web-based applications 

5. Explain different categories of elements in HTML, proving examples for their use 

  • Block Elements. Block elements appear on the screen as if they have a linebreak before and after them. ...
  • Inline Elements. ...
  • Grouping HTML Elements. ...
  • The <div> tag. ...
  • The <span> tag
  • A text header, denoted using the <h1> , <h2> , <h3> , <h4> , <h5> , <h6> tags.
  • A paragraph, denoted using the <p> tag.
  • A horizontal ruler, denoted using the <hr> tag.
  • A link, denoted using the <a> (anchor) tag.
  • •Structural elements
  • • header, footer, nav, aside, article


Text elements
  •  Headings
  •  Paragraph –
  •  Line break -
  • Images
  • Hyperlinks

Data representational elements (these elements use
nested structures)
  • • Lists
  • • Tables
  • • Form elements
  • • Input
  • • Radio buttons, checkboxes
  • • Buttons

6. Discuss the importance of CSS, indicating new features of CSS3 

Cascading Style Sheets or CSS are an important way to control how your Web pages look. CSS can control the fonts, text, colors, backgrounds, margins, and layout. But it can be very difficult to learn CSS, and some people would rather not learn it.


Used to
• Decorate / Format content
•Advantages
• Reduce HTML formatting tags
• Easy modification
• Save a lot of work and time
• Faster loading

Some formatting categories
Positioning
Size
Alignment
Font / Text

Color / Background / Border


7. Compare and contrast the 3 main types of CSS selectors 
•Element selector
•ID selector
•Class selector


8. Discuss the advanced CSS selectors, explaining the specificity 

CSS is one of the most powerful tools that are available to web designers (if not the most powerful). With it, we can completely transform the look of a website in just a couple of minutes, and without even having to touch the markup. But despite the fact that we are all well aware of its usefulness, CSS selectors are still not used to their full potential and we sometimes have the tendency to litter our HTML with excessive and unnecessary classes and ids, divs and spans.

9. Explain the use for CSS media queries in responsive web development 
Media query is a CSS technique introduced in CSS3.
It uses the rule@media to include a block of CSS properties only if a certain condition is true.

example:

   @media only screen and (max-width: 600px) {
  body {
    background-color: lightblue;
  
}
}


10. Identify the pros and cons of 3 ways of using CSS (inline, internal, external) 

Internal CSS
 Advantages of Internal CSS:
  • Only one page is affected by stylesheet.
  • Classes and IDs can be used by internal stylesheet.
  • There is no need to upload multiple files. HTML and CSS can be in the same file.
Disadvantages of Internal CSS:
  • Increased page loading time.
  • It affects only one page – not useful if you want to use the same CSS on multiple documents
External CSS
 Advantages of External CSS:
  • The smaller size of HTML pages and cleaner structure.
  • Faster loading speed.
  • Same .css file can be used on multiple pages.
Disadvantages of External CSS:
  • Until external CSS is loaded, the page may not be rendered correctly.
Inline CSS
Advantages of Inline CSS:
  • Useful if you want to test and preview changes.
  • Useful for quick-fixes.
  • Lower HTTP requests.
Disadvantages of Inline CSS:
  • Inline CSS must be applied to every element

11. Identify frameworks/libraries/plugins/tools to develop the Views/web pages, and discuss their similarities and differences 

They dynamically generate HTML+CSS code
 •In server and/or client-side 
 •May have JS-based advanced interactive features
 • jQuery – A JS library, but can be seen a framework too. It
   wraps the complexity of pure JS. There are lots of JS
   frameworks, libraries, and plugins built using jQuery. Good for
  DOM processing.
• jQuery UI – Focus on GUI development
• Bootstrap – to rapidly design and develop responsive web
   pages and templates
• Angular – a JS framework/platform to build frontend
  applications
• React – a JavaScript library for building user interfaces (and
  the application, which uses that UI)

Pros:
  • small distribution size
  • the shallow learning curve, considerable online help
  • concise syntax
  • easy to extend
Cons:
  • adds a speed overhead to native APIs
  • less essential now that browser compatibility has improved
  • usage has flat-lined
  • some industry backlash against the unnecessary use
12. Discuss the client-side component development related aspects in browser-based web applications 

•Browser-based clients’ components comprise two main aspects
 •Controllers
 •Client-model

 •The components of browser-based clients are developed using JS/JS-based frameworks, libraries, and plugins.


Main features of the client-side component
development tools
•DOM processing (dynamic content generation, change, removal)
•Data processing
•Data persistence
•Session management (cookies)
•Communicating (with server components)


13. Discuss the new features in JS version 6 

  • JavaScript let
  • JavaScript const
  • Exponentiation (**) (EcmaScript 2016)
  • Default parameter values
  • Array.find()
  • Array.findIndex()

14. Identify frameworks/libraries/plugins/tools to develop the client-side components of browser-based applications, and discuss their similarities and differences 

Tutorial 10 – Client-side development 2 - RiWAs

PROGRAMMING APPLICATIONS AND FRAMEWORKS                                                  Tutorial 10 Distinguish the term “Rich Internet...