Book Image

JavaScript Domain-Driven Design

Book Image

JavaScript Domain-Driven Design

Overview of this book

Table of Contents (15 chapters)
JavaScript Domain-Driven Design
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Welcome to JavaScript Domain-Driven Design. For years, JavaScript has been stuck in the realm of making a website a little more interactive, but nobody would have thought about implementing whole applications in JavaScript. This has changed dramatically over the past few years, and JavaScript has evolved into this omnipresent powerhouse of a language that is present in almost every space of development.

This phenomenal growth has introduced many problems during development, which were previously unknown in the JavaScript world. Projects grow to very large codebases, many developers work simultaneously on these large codebases, and in the end, JavaScript is more often than not a vital part of the overall application. The good thing is that most of those problems have been solved before, and we, as JavaScript developers, can draw from the vast experiences gained over the years in other spaces and adapt them to work for us in JavaScript, leveraging JavaScript's unique flexibility along the way.

What this book covers

Chapter 1, A Typical JavaScript Project, introduces a typical business application and how it is developed. It shows how domain-driven design can help steer clear of common issues during the development to create a more problem-tailored application.

Chapter 2, Finding the Core Problem, shows how we can effectively explore an application's problem domain and identify the most important aspects to work on.

Chapter 3, Setting up a Project for Domain-driven Design, focuses on setting up a structure for the project that is ready to grow. It not only shows how we can lay out files and folders, but also creates the right testing and build environments.

Chapter 4, Modelling the Actors, shows how a project grows using object-oriented techniques together with domain-driven design to really isolate the domain. We also tackle one of the hardest problems of computer science, naming.

Chapter 5, Classification and Implementation, is all about the language we use in domain-driven design to make the project understandable and readable. We look at the relationship between domains and sub-domains, and then drill further down into the core of domain objects.

Chapter 6, Context Map – The Big Picture, is about not only growing the application from a technical perspective, but also from an organizational perspective. We talk about organizing the different parts that form the application as a whole, either as separate parts or as interlinked pieces.

Chapter 7, It's Not All Domain-driven Design, talks about fitting domain-driven design into the space of development techniques, talking about what problems fit where. We also talk about influences such as object-orientation, domain-specific languages, and more.

Chapter 8, Seeing It All Come Together, is about how our project fits into a space of projects in JavaScript, referring back to the beginning. We also look at alternative choices for frameworks and development styles.

What you need for this book

The book uses JavaScript as the language of choice throughout. In order to provide a consistent runtime environment, JavaScript Node.js is used throughout the book as the runtime. Other tools from the Node.js ecosystem are used as well, mainly npm as the package manager. To work with the code in the book, you need a version of Node.js, which is available for Windows, Macintosh OS, and Linux from the Node.js website http://nodejs.org/. It comes packaged with npm. For editing code, I recommend using your favorite text editor or IDE. If you don't have one, maybe give Sublime Text or Vim a try, these are also available for Windows, Macintosh OS, and Linux.

Who this book is for

This book assumes a certain familiarity with the JavaScript language. It is targeted at JavaScript developers, who are faced with the problems of growing applications, and the problems that arise from the growth. It provides a practical approach to domain-driven design and focuses on the parts that are the most useful in day-to-day development.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "At the time of the writing, the currently active version was node.js 0.10.33."

A block of code is set as follows:

var Dungeon = function(cells) {
  this.cells = cells
  this.bookedCells = 0
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

var dungeons = {}
Dungeon.find = function(id, callback) {
  if(!dungeons[id]) {
    dungeons[id] = new Dungeon(100)
  }

Any command-line input or output is written as follows:

$ npm install –g express

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking on the Next button moves you to the next screen."

Note

Important links or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.