# Introduction

## Abstract

Nowadays, most web UI's depend on frontend frameworks/libraries (like Angular, Vue or React). These technologies are powerful, but they also lock programmers in by making it difficult to have a presentation layer independent of the rendering technology.

Each technology has their own *way of working* which doesn't integrate well with others. Therefore, learning a new framework/library could be a bad investment, as the technology might be outdated soon.

With this project, we want to research and evaluate different approaches to build modern frontend web applications as simple as possible. In order to not lose our train of thoughts, we limit this project's scope to frontend development using the technology standards HTML5, CSS3 and ES6.

To simulate real problems, the research process is built around a fictitious CRUD (Create, Read, Update, Delete) [application](https://github.com/robin-fhnw/IP5-Puerro/tree/f5db31e9448e145ecd9e10b8ac88d9824d368384/huerto/README.md).

It turned out, that there is not one single best way to handle every problem. Depending on the size and complexity of the application, different approaches should be considered.

If the goal is a dynamic informational website or a small web application, without a lot of internal state and little changing parts, the easiest solution is using plain and direct DOM manipulations with JavaScript.

As soon as there is a lot of changing content, direct DOM manipulations can get chunky and hard to maintain. Therefore, it is advisable to use a virtual DOM in order to change multiple elements regularly. A virtual DOM abstraction is useful for single view applications with huge and periodically changing DOM trees.

When developing frontend applications, handling and storing data on the client becomes quickly relevant. Normally, when state changes, the DOM needs to be updated accordingly. Doing this manually could lead to redundant code and doesn't comply with the separation of concerns pattern. Among other options, there is the possibility to combine state management with the virtual DOM and delegating the DOM access to a centralized location.

Another approach to separate the data, view and logic is with the well-known MVC pattern. Using its unidirectionally dataflow has the benefit of an improved understandability and maintainability especially for larger applications with a lot of logic. The only abstraction needed for this to work are observables.

For most applications, using a framework is not necessary. It comes with many dependencies, more features you will ever need, and it is hard to fully understand every peculiarity. Plus, it locks a developer in a predefined structure which makes it hard to switch the technology once started.

Therefore, it is often better to reach for simplicity instead of predetermined complexity.

## Table of Contents

* [Introduction](https://robin-christen.gitbook.io/puerro/01-introduction)
  * [About Web Development](https://robin-christen.gitbook.io/puerro/01-introduction#about-web-development)
  * [Purpose](https://robin-christen.gitbook.io/puerro/01-introduction#purpose)
  * [Methodology](https://robin-christen.gitbook.io/puerro/01-introduction#methodology)
  * [Scope](https://robin-christen.gitbook.io/puerro/01-introduction#scope)
  * [Coding Conventions](https://robin-christen.gitbook.io/puerro/01-introduction#coding-conventions)
* [DOM](https://robin-christen.gitbook.io/puerro/02-dom)
  * [Manipulating the DOM](https://robin-christen.gitbook.io/puerro/02-dom#manipulating-the-dom)
  * [Event-Driven Actions](https://robin-christen.gitbook.io/puerro/02-dom#event-driven-actions)
  * [Testability](https://robin-christen.gitbook.io/puerro/02-dom#testability)
  * [Use Cases](https://robin-christen.gitbook.io/puerro/02-dom#use-cases)
  * [Problems/Restrictions](https://robin-christen.gitbook.io/puerro/02-dom#problems--restrictions)
* [Virtual DOM](https://robin-christen.gitbook.io/puerro/03-virtual-dom)
  * [Creating a Virtual DOM](https://robin-christen.gitbook.io/puerro/03-virtual-dom#creating-a-virtual-dom)
  * [Rendering](https://robin-christen.gitbook.io/puerro/03-virtual-dom#rendering)
  * [Diffing](https://robin-christen.gitbook.io/puerro/03-virtual-dom#diffing)
  * [Testability](https://robin-christen.gitbook.io/puerro/03-virtual-dom#testability)
  * [Use Cases](https://robin-christen.gitbook.io/puerro/03-virtual-dom#use-cases)
  * [Problems/Restrictions](https://robin-christen.gitbook.io/puerro/03-virtual-dom#problems--restrictions)
* [State Management](https://robin-christen.gitbook.io/puerro/04-state-management)
  * [State Inside the View](https://robin-christen.gitbook.io/puerro/04-state-management#state-inside-the-view)
  * [Keep it Simple](https://robin-christen.gitbook.io/puerro/04-state-management#keep-it-simple)
  * [Components](https://robin-christen.gitbook.io/puerro/04-state-management#components)
  * [ID Management](https://robin-christen.gitbook.io/puerro/04-state-management#id-management)
  * [Testability](https://robin-christen.gitbook.io/puerro/04-state-management#testability)
  * [Use Cases](https://robin-christen.gitbook.io/puerro/04-state-management#use-cases)
  * [Problems/Restrictions](https://robin-christen.gitbook.io/puerro/04-state-management#problems--restrictions)
* [MVC](https://robin-christen.gitbook.io/puerro/05-mvc)
  * [The MVC Way](https://robin-christen.gitbook.io/puerro/05-mvc#the-mvc-way)
  * [Bidirectional Binding](https://robin-christen.gitbook.io/puerro/05-mvc#bidirectional-binding)
  * [Global State](https://robin-christen.gitbook.io/puerro/05-mvc#global-state)
  * [Testability](https://robin-christen.gitbook.io/puerro/05-mvc#testability)
  * [Use Cases](https://robin-christen.gitbook.io/puerro/05-mvc#use-cases)
  * [Problems/Restrictions](https://robin-christen.gitbook.io/puerro/05-mvc#problems--restrictions)
* [Conclusion](https://robin-christen.gitbook.io/puerro/06-conclusion)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://robin-christen.gitbook.io/puerro/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
