Book Image

Hands-On Design Patterns and Best Practices with Julia

By : Tom Kwong
Book Image

Hands-On Design Patterns and Best Practices with Julia

By: Tom Kwong

Overview of this book

Design patterns are fundamental techniques for developing reusable and maintainable code. They provide a set of proven solutions that allow developers to solve problems in software development quickly. This book will demonstrate how to leverage design patterns with real-world applications. Starting with an overview of design patterns and best practices in application design, you'll learn about some of the most fundamental Julia features such as modules, data types, functions/interfaces, and metaprogramming. You'll then get to grips with the modern Julia design patterns for building large-scale applications with a focus on performance, reusability, robustness, and maintainability. The book also covers anti-patterns and how to avoid common mistakes and pitfalls in development. You'll see how traditional object-oriented patterns can be implemented differently and more effectively in Julia. Finally, you'll explore various use cases and examples, such as how expert Julia developers use design patterns in their open source packages. By the end of this Julia programming book, you'll have learned methods to improve software design, extensibility, and reusability, and be able to use design patterns efficiently to overcome common challenges in software development.
Table of Contents (19 chapters)
1
Section 1: Getting Started with Design Patterns
3
Section 2: Julia Fundamentals
7
Section 3: Implementing Design Patterns
15
Section 4: Advanced Topics

To get the most out of this book

You should download the latest version of Julia from the Julia Language website (https://julialang.org/).

The code samples are available on GitHub, as described in the Technical requirements section of each chapter. At the time of writing, the code has been tested with Julia version 1.3.0. To download the code samples, clone the project from GitHub as follows:

You are encouraged to run and experiment with the code samples accompanying this book. The code samples are typically stored in one of the following formats:

  • Code snippets in a Julia source file. These snippets can be copied and pasted into the REPL.
  • Code residing in a package directory. The package can be instantiated as follows:

For example, in Chapter 5Reusability Patterns, the content is listed as follows:

To use the code for DelegationPattern, just start a Julia REPL in that folder with the --project=. command-line argument:

Then, go to the package mode and instantiate the package by entering the ] instantiate command:

After that, you can use the package as usual:

If there is a test directory, then you can read and run the test scripts provided.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the Support tab.
  3. Click on Code Downloads.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-on-Design-Patterns-and-Best-Practices-with-JuliaIn case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Code in Action

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text such as variable names, function names, data types, etc. For example, "The format function takes a formatter and a numeric value, x, and returns a formatted string."

A block of code is set as follows:

abstract type Formatter end
struct IntegerFormatter <: Formatter end
struct FloatFormatter <: Formatter end

Any experiment or output from the REPL is presented as screenshots:

Bold: Indicates an important word or concept. For example, "The Bridge pattern is used to decouple an abstraction from its implementation so that it can evolve independently."

Italics: Emphasizes a new concept that will be explained later in the text. For example, "The cases presented in previous chapters include various situations that we can solve by writing idiomatic Julia code."

Important notes appear like this.
Tips and tricks appear like this.