Foreword

This two-volume book shows how to design and implement web applications with a model-based engineering approach, using the two most relevant technology platforms for web development: JavaScript and Java. Web apps are designed with the help of information models in the form of UML class diagrams and implemented as:

1.JavaScript front-end apps, using one of the two local storage technologies offered by web browsers;

2.Java back-end apps, using Java Server Faces (JSF) as the user interface technology, the Java Persistence API (JPA) for object-to-storage mapping, and a MySQL/ MariaDB database management system;

3.distributed JavaScript apps with

a.a front-end component for managing the user interface and taking care of certain parts of the application logic (including constraint-based data validation), and

b.a NodeJS-based back-end component for managing persistent storage and taking care of certain parts of the application logic (including constraint-based data validation).

The focus of the book are general concepts and techniques concerning the fundamental information management issues of

  1. integrity constraints and data validation,
  2. enumerations and enumeration attributes
  3. unidirectional and bidirectional associations between object types,
  4. subtyping and inheritance in class hierarchies.

The first two issues of this list are discussed in Volume 1 of the book, while the last two issues are discussed in Volume 2.

We assume that the reader is already familiar with HTML and with object-oriented programming, preferably with Java (or, otherwise, with C++, PHP, Python or C#). In addition, we assume that the reader has some familiarity with CSS and JavaScript, and is willing to learn more about programming with modern JavaScript.

The book can be used

1)in web development courses for students of Computer Science and related disciplines;

2)by JavaScript developers for learning Java;

3)by Java developers for learning JavaScript;

4)by JavaScript and Java (and PHP/Python/C# etc.) developers for learning

object-oriented (OO) programming with JavaScript and Java EE,

how to implement basic information management concepts and build complete web apps with plain JavaScript and Java EE.

The book comes with the complete source code of six example apps that you can run, or download, from the book’s website http://web-engineering.info/WebAppBook. Readers can ask questions about any chapter or topic of the book in one of the discussion forums provided at the web-engineering.info website.

1Mastering App Development Requires More than Coding Skills

For mastering app development, it’s not sufficient that you master coding in your favorite programming language. It’s essential that you understand all basic concepts and techniques, not just in programming, but also in information management.

A programming (or software development) technology typically combines a programming language, such as JavaScript, Java or C#, with a framework or a number of libraries, such as JavaScript with BackboneJS, Java with JPA and JSF, or C# with ASP.NET MVC, for programming user interfaces and data storage management.

Many developers seem to believe that all they need to learn and master for their professional career are the right programming technologies. However, they fail to master app development, if they don’t manage to learn the general concepts and techniques needed for being able to apply programming technologies in the right way.

Understanding general concepts and techniques, in programming and information management, helps you to

better understand the elements of a language or framework by recognizing them as specific incarnations of general concepts,

compare different technologies and assess their strengths and weaknesses,

make an informed choice of a new promising language/technology suitable for your purposes.

While technology-specific knowledge is important (in fact, it is the basis) for mastering programming and app development, it is also true that its half-time value is pretty short. In this book, we do not only explain programming and information management concepts and techniques in a technology-independent way, we also explain in which way these concepts and techniques are supported in the two most relevant technologies: JavaScript and Java.

2Why is JavaScript a Good Choice for Building Web Apps?

Today, JavaScript is not just a programming language, but rather a platform, which offers many advantages over other platforms:

1.It’s the only language that enjoys native support in web browsers.

2.It’s the only (“universal”) language that allows

a.building web apps with just one programming language; all other languages (like Java and C#) can only be used on the back-end and need to be combined with front-end JavaScript, so developers need to master at least two programming languages.

b.executing the same code (e. g., for constraint validation) on the back-end and the front-end.

3.It’s the only language that allows dynamic distribution, that is, executing the same code (e. g., for business computations) either in the back-end or the front-end, depending on run-time conditions such as the available front-end resources.

4.It combines object-oriented with functional programming.

5.Its dynamism allows various forms of meta-programming, which means it enables developers to program their own programming concepts, like classes and enumerations.

3Why is Java a Good Choice for Building Web Apps?

In 2017, and for many years to come, the enterprise software platform Java Enterprise Edition (Java EE), which bundles the Java language together with a number of libraries for enterprise software systems, is the most important programming platform for enterprise information technologies, including all kinds of business software applications. Its strong points mainly result from the fact that it is very mature:

  1. it has a rich ecosystem, including a large number of libraries, frameworks and tools;
  2. Java code executes faster than scripting languages, like Python, PHP, NodeJS or Ruby;
  3. Java web applications can be scaled, e. g., by using distributed database transactions and cluster technologies;
  4. it provides a lot of advanced security technologies.

4Comparing Java with JavaScript

As opposed to Java, JavaScript is relatively easy to learn. One reason for this is the need of explicit type definitions for variables, parameters and return values in Java, which are not needed in JavaScript.

Both Java and JavaScript are “object-oriented” programming languages, but JavaScript is even more “object-oriented” than Java, which is rather “class-oriented”. There is no explicit class concept in JavaScript. Classes have to be defined in the form of special objects. However, objects can also be created without instantiating a class, and properties as well as methods can be defined for specific objects independently of any class definition.

At run time, properties and methods can be added to, or removed from, any object and class. While JavaScript classes can be redefined at runtime, immediately affecting all objects that instantiate the class, Java classes cannot be redefined in such a way.

JavaScript allows defining methods that are specific for an object, independently of its class. The methods of a Java object are defined for its class, it is not possible to define object-specific methods.

JavaScript has better support for functional programming. For instance, it supports “closures”, which are function execution contexts. Java only supports a limited version of closures for anonymous classes and “lambdas”.

5Good Programs Are: Effective, Robust, Efficient and Maintainable

… as observed by Nick Gonzalez1. A good program is effective: it solves the problem it is supposed to solve. A good program must not crash when it receives bad inputs from users: it is robust. Good programs are efficient: it does the job it is supposed to do quickly. Since the requirements for a program may change over time, a good program should be maintainable, so it can be modified easily when requirements do change. A program can only be maintainable, if its code is written in a clear manner.

Any damn fool can write code that a computer can understand, the trick is to write code that humans can understand. (Martin Fowler in After the Program Runs2)

Code is often “unnecessarily complicated, convoluted, disorganized, and stitched together with disdain”, as observed in a post by Santiago L. Valdarrama3 who recommends using comments when necessary, only to explain things that can’t be made clear enough, but rather make your code reveal its intention through the use of better names, proper structure, and correct spacing and indentation.

6Run the Apps and Get Their Code

For running any of the example apps from our web server, and for downloading their code, please visit http://web-engineering.info/WebAppBook-CodeLinks.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset