Book Image

Building Your Own JavaScript Framework

By : Vlad Filippov
Book Image

Building Your Own JavaScript Framework

By: Vlad Filippov

Overview of this book

JavaScript frameworks play an essential role in web application development; however, no single framework works perfectly for all projects. This book will help you understand existing projects, design new software architecture, and maintain projects as they grow. You’ll go through software architecture principles with JavaScript, along with a guided example of structuring your project and maintenance guidance. This book covers framework planning aspects, enabling you to identify key stakeholders, understand JavaScript API design, and leverage complex abstraction. The second part of the book takes a practical programming approach to building your own framework by showing you how to structure modules and interfaces. As you advance, you’ll discover how to develop data-binding components, work with JavaScript APIs, and much more. While writing a framework is half the job, continuing to develop it requires effort from everyone involved. The concluding chapters help to achieve this by teaching you the crucial aspects of software maintenance and highlighting the constants of framework development. By the end of this book, you’ll have gained a clear understanding of the JavaScript framework landscape, along with the ability to build frameworks for your use cases.
Table of Contents (16 chapters)
1
Part 1: The Landscape of JavaScript Frameworks
6
Part 2: Framework Development
11
Part 3: Maintaining Your Project

Architecting the new framework

Now, we’ll get to the architectural part of our practical approach. So far, we know what we are building and who we are building it for. It is now time to determine the shape of our feature set and see how we can enable those features for our users. The most basic use case that we would like to cover is generating assertions for JavaScript code, as presented here:

// basic.js
export function helloReader() {
  return "Hello reader!";
}
// tests/basic.js
import ct, { assert } from "componium-test";
import { helloReader } from "../basic.js";
ct({
  basic: function () {
    assert.strictEqual(helloReader(), "Hello reader!",
      "output is correct");
  },
});

The preceding code example tests the helloReader() function and verifies that the correct string is returned. Starting from these basics, to take things further...