Unleash Web Views with Higher-Order Templates

Total Page:16

File Type:pdf, Size:1020Kb

Unleash Web Views with Higher-Order Templates HoT: Unleash Web Views with Higher-order Templates Fernando Miguel Carvalho a and Luis Duarte ADEETC, ISEL, Polytechnic Institute of Lisbon, Portugal Keywords: Template View, Big Data, Front-end, Web Application, HTML. Abstract: Over the past decades, templates views have been the most used approach to build dynamic HTML pages. Simply put, a template engine (such as JSP, Handlebars, Thymleaf, and others) generates HTML by merging templates with given data models. Yet, this process may turn impractical for large data sets that postpone the HTML resolution until all data become available to the engine. This behavior results in poor user experience preventing the browser to render the end user-interface. In this paper we introduced the concept of higher- order templates (HoT) provided in Java implementation of HtmlFlow, which allows HTML to be resolved on demand as data becomes available. This lets the user-interface to be rendered incrementally by the browser in line with the availability of the data. Finally we also show some advantages of HtmlFlow over state of the art front-end frameworks such as ReactJS. 1 INTRODUCTION and producing HTML is blocking and it only finishes when all template markers have been replaced with Contrary to static HTML pages, which do not change data from the context object. In the case of an itera- from request to request, dynamic Web pages may take tion tag (i.e. #each of Listing 1) it must traverse the results from a data source, like database or web ser- entire list (i.e. tracks) to complete the template reso- vice, and embed them into the HTML. Dynamic Web lution. The larger the data (i.e. tracks.size()), the pages share a similar structure to static HTML but longer the engine takes to finish the resolution. While they also include markers that can be resolved into the engine is resolving the view, the browser is pre- calls to gather dynamic information. Since the static senting a blank page to the end user giving him an part of the page acts as a template, this pattern is unresponsive behavior. known as template view (Fowler, 2002) or template- Listing 1: Handlebars template view for a dynamic un- based view strategy (Alur et al., 2001). When the tem- ordered list. plate view is used to service a request, the markers <ul> are replaced by the results of corresponding computa- {{#each tracks}} tions. The parsing and replacement process (i.e. res- <li>{{name}}</li> olution) is the main role of the template engine (Parr, {{# each }} 2004). </ul> Template engines distinguish themselves by the idiom and subset of available markers to control the Visualization is one of the major concerns in big dynamic content. Generally, all engines provide a data (Agrawal et al., 2015; Storey and Song, 2017). specialized tag for iteration, which can be used for Also, people tend to prefer web based applications example to generate a dynamic list such that one pre- as their favorite visualization support for data anal- sented in Listing 1 expressed in the Handlebars id- ysis (Yaqoob et al., 2016). Yet, even using data re- iom (an extension to the Mustache templating lan- duction strategies (Liu et al., 2013; ur Rehman et al., guage (Lerner, 2011)). 2016) the resulting data sets are large enough to make In this example, the template receives a context unfeasible the use of template views. This problem object with a tracks property and generates a li arises in both, server-side or client-side (i.e. front- element with the track’s name for each item in the end) web application development. In the former tracks list. The process of resolving the template case, the view resolution process prevents the server to send the response and in the latter, the number of a https://orcid.org/0000-0002-4281-3195 DOM nodes (Hors et al., 2004) increases with the size 118 Carvalho, F. and Duarte, L. HoT: Unleash Web Views with Higher-order Templates. DOI: 10.5220/0008167701180129 In Proceedings of the 15th International Conference on Web Information Systems and Technologies (WEBIST 2019), pages 118-129 ISBN: 978-989-758-386-5 Copyright c 2019 by SCITEPRESS – Science and Technology Publications, Lda. All rights reserved HoT: Unleash Web Views with Higher-order Templates of dynamic data, incurring in additional performance 2 STATE OF THE ART overhead for the browser. For these reasons tradi- tional ways of presenting data in web applications is Dealing with large data sets on web applications usu- inadequate to handle big data (Agrawal et al., 2015). ally leads the browser to present an unresponsive be- In this work, we propose a new approach based on havior due to the template view resolution process. higher-order templates (HoT), which aims to achieve One way of dealing with this problem is to reduce big a similar methodology to the server side template data into manageable size (Feldman et al., 2013). Yet, view pattern, but useful even on the presence of big even using reduction techniques the resulting subset data. Briefly, our goal is to establish data-centric may still be large enough to turn impractical the use push-style approach (Jin et al., 2015) and push the of a template engine. resulting HTML to the response stream as its content Web applications usually mitigate this problem is being resolved. Rather than pulling data from a with two possible solutions (but not limited to): 1) source and fully complete markers of a template view, numbered pagination, 2) infinite scrolling. Numbered we propose to react to data and push the resulting pagination was one of the first solutions adopted to HTML as it is being resolved. This follows the idea deal with the web presentation of big data, such as of (Meijer, 2012) that states that the Velocity axis of the results retrieved by web search engines. Later the big data ranges from pulling data from the source to MSN search’s image search was the first one to in- pushing data to the clients. troduce the infinite scrolling technique with a single This solution is implemented in HtmlFlow Java page of results, which you can scroll to automatically library, which implements a domain specific lan- load more images (Farago et al., 2007). Both options guage (DSL (Mernik et al., 2005)) for HTML. Briefly, reduce latency and turn the browser responsive, but HtmlFlow implementation is based on the following both also have some drawbacks. key ideas: Numbered pagination forbids, for example, the 1. do not block the template resolution until its com- end user to use the browser to find something among pletion (Meijer, 2012); all resulting pages. On the other hand, infinite scrolling uses AJAX to fetch data (Kesteren et al., 2. discard textual template files; 2006) and DOM (Hors et al., 2004) to update the 3. use HTTP chunked transfer encoding (Fielding user-interface as data results become available. This and Reschke, 2014); approach is usually known as front-end web develop- 4. define views as first-class functions. ment (Smith, 2012). But, manipulating large collec- tions of DOM nodes is slow and increases browser For the remainder of this paper we present in the processing overhead. Moreover we lose the overall next section state of the art solutions that deal with structure of the template view that now is mixed in web presentation of large data sets. Then in Sec- with DOM manipulation logic. tion 3 we present our proposal of higher-order tem- Regarding the example of Listing 1 and its use plates. After that in Section 4, we present the Java with a front-end technology, then the template would library HtmlFlow, which provides a domain-specific be only the ul element with a unique identifier (e.g. language for HTML. In Section 5, we discuss re- listOfTracks) such as: lated work in the HtmlFlow field. In Section 6, we present an experimental evaluation of developing a web application–topgenius.eu1–that presents the top <ul id="listOfTracks"></ul> tracks ranking for a given country. This application uses data from Last.fm RESTful API and dynamically In turn, the li elements would be manipulated builds a list with hundreds of thousands of records. programmatically through DOM. Here we compare three different technological ap- Keeping a view definition with whole HTML proaches: 1) server-side template view, 2) ReactJS structure similar to a template was one of the moti- and 3) HtmlFlow. Finally, in Section 7 we conclude vations for the appearance of front-end frameworks, and discuss some future work. such as Angular or ReactJs. This kind of frameworks allow the definition of a view based on a context ob- ject that is latter bound to the view by the framework through DOM. Yet, these frameworks do not solve the perfor- mance issues and do not let end users to get page source code in an infinite scroll scenario. For example 1Source code is available at github.com/xmlet/topgenius in ReactJs, the page source of resulting HTML will 119 WEBIST 2019 - 15th International Conference on Web Information Systems and Technologies only display <div id="root"></div> correspond- The tracksTpl function receives two parameters: ing to the div element where the framework places an HtmlFlow view and a context object (e.g. tracks). HTML elements from DOM manipulation. The view parameter provides the HTML fluent in- Briefly, web front-end development approaches terface (Fowler, 2010) with methods corresponding circumscribe the server-side templates problems by to the name of HTML elements and an additional moving the HTML resolution from the server to web () method to close an HTML element tag.
Recommended publications
  • Building Great Interfaces with OOABL
    Building great Interfaces with OOABL Mike Fechner Director Übersicht © 2018 Consultingwerk Ltd. All rights reserved. 2 Übersicht © 2018 Consultingwerk Ltd. All rights reserved. 3 Übersicht Consultingwerk Software Services Ltd. ▪ Independent IT consulting organization ▪ Focusing on OpenEdge and related technology ▪ Located in Cologne, Germany, subsidiaries in UK and Romania ▪ Customers in Europe, North America, Australia and South Africa ▪ Vendor of developer tools and consulting services ▪ Specialized in GUI for .NET, Angular, OO, Software Architecture, Application Integration ▪ Experts in OpenEdge Application Modernization © 2018 Consultingwerk Ltd. All rights reserved. 4 Übersicht Mike Fechner ▪ Director, Lead Modernization Architect and Product Manager of the SmartComponent Library and WinKit ▪ Specialized on object oriented design, software architecture, desktop user interfaces and web technologies ▪ 28 years of Progress experience (V5 … OE11) ▪ Active member of the OpenEdge community ▪ Frequent speaker at OpenEdge related conferences around the world © 2018 Consultingwerk Ltd. All rights reserved. 5 Übersicht Agenda ▪ Introduction ▪ Interface vs. Implementation ▪ Enums ▪ Value or Parameter Objects ▪ Fluent Interfaces ▪ Builders ▪ Strong Typed Dynamic Query Interfaces ▪ Factories ▪ Facades and Decorators © 2018 Consultingwerk Ltd. All rights reserved. 6 Übersicht Introduction ▪ Object oriented (ABL) programming is more than just a bunch of new syntax elements ▪ It’s easy to continue producing procedural spaghetti code in classes ▪
    [Show full text]
  • Functional Javascript
    www.it-ebooks.info www.it-ebooks.info Functional JavaScript Michael Fogus www.it-ebooks.info Functional JavaScript by Michael Fogus Copyright © 2013 Michael Fogus. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or [email protected]. Editor: Mary Treseler Indexer: Judith McConville Production Editor: Melanie Yarbrough Cover Designer: Karen Montgomery Copyeditor: Jasmine Kwityn Interior Designer: David Futato Proofreader: Jilly Gagnon Illustrator: Robert Romano May 2013: First Edition Revision History for the First Edition: 2013-05-24: First release See http://oreilly.com/catalog/errata.csp?isbn=9781449360726 for release details. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Functional JavaScript, the image of an eider duck, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐ mark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
    [Show full text]
  • What Is ASP.NET?
    Welcome to the ASP.NET QuickStart Tutorial Getting Started Introduction The ASP.NET QuickStart is a series of ASP.NET samples and What is ASP.NET? supporting commentary designed to quickly acquaint Language Support developers with the syntax, architecture, and power of the ASP.NET Web programming framework. The QuickStart ASP.NET Web Forms samples are designed to be short, easy-to-understand Introducing Web Forms illustrations of ASP.NET features. By the time you have Working with Server Controls completed the QuickStart tutorial, you will be familiar with: Applying Styles to Controls Server Control Form Validation ● ASP.NET Syntax. While some of the ASP.NET Web Forms User Controls syntax elements will be familiar to veteran ASP developers, several are unique to the new Data Binding Server Controls framework. The QuickStart samples cover each Server-Side Data Access element in detail. Data Access and Customization ● ASP.NET Architecture and Features. The Working with Business Objects QuickStart introduces the features of ASP.NET that Authoring Custom Controls enable developers to build interactive, world-class Web Forms Controls Reference applications with much less time and effort than ever before. Web Forms Syntax Reference ● Best Practices. The QuickStart samples demonstrate the best ways to exercise the power of ASP.NET Web Services ASP.NET while avoiding potential pitfalls along the Introducing Web Services way. Writing a Simple Web Service Web Service Type Marshalling What Level of Expertise Is Assumed in the Using Data in Web Services QuickStart? Using Objects and Intrinsics If you have never developed Web pages before, the The WebService Behavior QuickStart is not for you.
    [Show full text]
  • Exam Ref 70-482: Advanced Windows Store App Development Using HTML5 and Javascript
    Exam Ref 70-482: Advanced Windows Store App Development Using HTML5 and JavaScript Roberto Brunetti Vanni Boncinelli Copyright © 2013 by Roberto Brunetti and Vanni Boncinelli All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. ISBN: 978-0-7356-7680-0 1 2 3 4 5 6 7 8 9 QG 8 7 6 5 4 3 Printed and bound in the United States of America. Microsoft Press books are available through booksellers and distributors worldwide. If you need support related to this book, email Microsoft Press Book Support at [email protected]. Please tell us what you think of this book at http://www.microsoft.com/learning/booksurvey. Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/ en/us/IntellectualProperty/Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of their respec- tive owners. The example companies, organizations, products, domain names, email ad- dresses, logos, people, places, and events depicted herein are fictitious. No association with any real company, organization, product, domain name, email address, logo, person, place, or event is intended or should be inferred. This book expresses the author’s views and opinions. The information con- tained in this book is provided without any express, statutory, or implied warranties. Neither the authors, Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book.
    [Show full text]
  • Automating Testing with Autofixture, Xunit.Net & Specflow
    Design Patterns Michael Heitland Oct 2015 Creational Patterns • Abstract Factory • Builder • Factory Method • Object Pool* • Prototype • Simple Factory* • Singleton (* this pattern got added later by others) Structural Patterns ● Adapter ● Bridge ● Composite ● Decorator ● Facade ● Flyweight ● Proxy Behavioural Patterns 1 ● Chain of Responsibility ● Command ● Interpreter ● Iterator ● Mediator ● Memento Behavioural Patterns 2 ● Null Object * ● Observer ● State ● Strategy ● Template Method ● Visitor Initial Acronym Concept Single responsibility principle: A class should have only a single responsibility (i.e. only one potential change in the S SRP software's specification should be able to affect the specification of the class) Open/closed principle: “Software entities … should be open O OCP for extension, but closed for modification.” Liskov substitution principle: “Objects in a program should be L LSP replaceable with instances of their subtypes without altering the correctness of that program.” See also design by contract. Interface segregation principle: “Many client-specific I ISP interfaces are better than one general-purpose interface.”[8] Dependency inversion principle: One should “Depend upon D DIP Abstractions. Do not depend upon concretions.”[8] Creational Patterns Simple Factory* Encapsulating object creation. Clients will use object interfaces. Abstract Factory Provide an interface for creating families of related or dependent objects without specifying their concrete classes. Inject the factory into the object. Dependency Inversion Principle Depend upon abstractions. Do not depend upon concrete classes. Our high-level components should not depend on our low-level components; rather, they should both depend on abstractions. Builder Separate the construction of a complex object from its implementation so that the two can vary independently. The same construction process can create different representations.
    [Show full text]
  • ASP.NET 4 and Visual Studio 2010 Web Development Overview
    ASP.NET 4 and Visual Studio 2010 Web Development Overview This document provides an overview of many of the new features for ASP.NET that are included in the.NET Framework 4 and in Visual Studio 2010. Contents Core Services .....................................................................................................................................3 Web.config File Refactoring ...................................................................................................................... 3 Extensible Output Caching ........................................................................................................................ 3 Auto-Start Web Applications .................................................................................................................... 5 Permanently Redirecting a Page ............................................................................................................... 7 Shrinking Session State ............................................................................................................................. 7 Expanding the Range of Allowable URLs ................................................................................................... 8 Extensible Request Validation .................................................................................................................. 8 Object Caching and Object Caching Extensibility ...................................................................................... 9 Extensible HTML, URL, and HTTP Header
    [Show full text]
  • Designpatternsphp Documentation Release 1.0
    DesignPatternsPHP Documentation Release 1.0 Dominik Liebler and contributors Jul 18, 2021 Contents 1 Patterns 3 1.1 Creational................................................3 1.1.1 Abstract Factory........................................3 1.1.2 Builder.............................................8 1.1.3 Factory Method......................................... 13 1.1.4 Pool............................................... 18 1.1.5 Prototype............................................ 21 1.1.6 Simple Factory......................................... 24 1.1.7 Singleton............................................ 26 1.1.8 Static Factory.......................................... 28 1.2 Structural................................................. 30 1.2.1 Adapter / Wrapper....................................... 31 1.2.2 Bridge.............................................. 35 1.2.3 Composite............................................ 39 1.2.4 Data Mapper.......................................... 42 1.2.5 Decorator............................................ 46 1.2.6 Dependency Injection...................................... 50 1.2.7 Facade.............................................. 53 1.2.8 Fluent Interface......................................... 56 1.2.9 Flyweight............................................ 59 1.2.10 Proxy.............................................. 62 1.2.11 Registry............................................. 66 1.3 Behavioral................................................ 69 1.3.1 Chain Of Responsibilities...................................
    [Show full text]
  • Contents Contents
    Contents Contents ........................................................................................................................................................ 1 1 Introduction ............................................................................................................................................... 4 Samples and Examples .............................................................................................................................. 4 2 Prerequisites .............................................................................................................................................. 4 3 Architecture ............................................................................................................................................... 4 Direct to On-Prem ..................................................................................................................................... 4 Azure Cloud ............................................................................................................................................... 5 Service On-Prem ....................................................................................................................................... 6 4 Why Choose the Microsoft Technology Stack? ......................................................................................... 7 Rapid Application Development ............................................................................................................... 7 C# .........................................................................................................................................................
    [Show full text]
  • Microsoft CRM – Typical Customizations
    Microsoft CRM – Typical Customizations by Andrew Karasev Microsoft CRM was designed to be easily customizable. Microsoft CRM Software Development Kit (MS CRM SDK) which you can download from Microsoft website contains descriptions of the objects or classes, exposed for customization. It has sample code in C# and partially in VB.Net. In Visual Studio.Net you can analyze all the classes, used by Microsoft developers to create MS CRM - you will discover that most of them are not documented in MS CRM SDK. Microsoft will not support your customization if you use undocumented class or do direct SQL access to CRM database. Let us describe you - programmer, software developer typical cases of MS CRM Customizations. 1. Integration with SQL Server application. If you have legacy system on MS SQL Server - let's say you are transportation company and have in-house developed cargo tracking database. Now in MS CRM you want lookup the shipments for the customer (or account in CRM). This is SDK programming and calling SQL stored proc to retrieve cargo info. Instead of SQL Server you can have other database (ORACLE, MS Access, PervasiveSQL to name a few) - you can access multiple Database platforms via ADO.Net connection from your .Net application, which is easily integrated into MS CRM Account screen. 2. Email capturing in MS CRM. You have customer with email [email protected]. Now you want all the emails that you receive from customer.com domain to be attached to Bill who is account in CRM. This is more difficult customization - you have to create MS CRM SDK web service, that one will be creating email activity and call it from COM+ application - Microsoft Exchange event handler (ONSYNCSAVE database event sink).
    [Show full text]
  • Moving Applications to the Cloud, 2Nd Edition Patterns & Practices
    Moving Applications to the Cloud, nd 2 Edition patterns & practices Summary: This book demonstrates how you can adapt an existing, on-premises ASP.NET application to one that operates in the cloud. The book is intended for any architect, developer, or information technology (IT) professional who designs, builds, or operates applications and services that are appropriate for the cloud. Although applications do not need to be based on the Microsoft Windows operating system to work in Windows Azure, this book is written for people who work with Windows-based systems. You should be familiar with the Microsoft .NET Framework, Microsoft Visual Studio, ASP.NET, and Microsoft Visual C#. Category: Guide Applies to: Windows Azure SDK for .NET (includes the Visual Studio Tools for Windows Azure), Windows Azure SQL Database, Microsoft SQL Server or SQL Server Express 2008, Windows Identity Foundation, Enterprise Library 5, WatiN 2.0, Microsoft Anti-Cross Site Scripting Library V4, Microsoft .NET Framework version 4.0, Microsoft Visual Studio 2010 Source: MSDN Library(patterns & practices) (link to source content) E-book publication date:June 2012 Copyright © 2012 by Microsoft Corporation All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty/Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of their respective owners. The example companies, organizations, products, domain names, email addresses, logos, people, places, and events depicted herein are fictitious.
    [Show full text]
  • Design Patterns for QA Automation Anton Semenchenko
    Design Patterns for QA Automation Anton Semenchenko CONFIDENTIAL 1 Agenda, part 1 (general) 1. Main challenges 2. Solution 3. Design Patterns – the simplest definition 4. Design Patterns language – the simplest definition 5. Encapsulation – the most important OOP principle CONFIDENTIAL 2 Agenda, part 2 (main patterns) 1. Page Element 2. Page Object 3. Action CONFIDENTIAL 3 Agenda, part 3 (less popular patterns) 1. Flow (Fluent Interface) – Ubiquitous language – Key word driven – Behavior Driven Development (BDD) 2. Domain Specific Language (DSL) – Flow 3. Navigator (for Web) CONFIDENTIAL 4 Agenda, part 4 (take away points) 1. “Rules” and principles 2. A huge set of useful links 3. A huge set of examples CONFIDENTIAL 5 2 main challenges in our every day work (interview experience) 1. Pure design 2. Over design CONFIDENTIAL 6 Solution 1. Find a balance CONFIDENTIAL 7 Design Patterns – the simplest definition 1. Elements (blocks) of reusable object-oriented software; 2. The re-usable form of a solution to a design problem; CONFIDENTIAL 8 Design Patterns – as a language 1. Design patterns that relate to a particular field (for example QA Automation) is called a pattern language 2. Design Patterns language gives a common terminology for discussing the situations specialists are faced with: – “The elements of this language are entities called patterns”; – “Each pattern describes a problem that occurs over and over again in our (QA Automation) environment”; – “Each pattern describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice!” CONFIDENTIAL 9 Design Patterns for QA Automation 1.
    [Show full text]
  • Drools Expert User Guide
    Drools Expert User Guide Version 6.0.0.CR2 by The JBoss Drools team [http://www.jboss.org/drools/team.html] ....................................................................................................................................... vii 1. Introduction ................................................................................................................. 1 1.1. Artificial Intelligence ............................................................................................ 1 1.1.1. A Little History ......................................................................................... 1 1.1.2. Knowledge Representation and Reasoning ................................................ 2 1.1.3. Rule Engines and Production Rule Systems (PRS) .................................... 3 1.1.4. Hybrid Reasoning Systems (HRS) ............................................................ 5 1.1.5. Expert Systems ........................................................................................ 8 1.1.6. Recommended Reading ........................................................................... 9 1.2. Why use a Rule Engine? .................................................................................. 12 1.2.1. Advantages of a Rule Engine ................................................................. 13 1.2.2. When should you use a Rule Engine? ..................................................... 14 1.2.3. When not to use a Rule Engine .............................................................. 15 1.2.4. Scripting
    [Show full text]