Book description
Design and develop high-performance, reusable, and maintainable applications using traditional and modern Julia patterns with this comprehensive guide
Key Features
- Explore useful design patterns along with object-oriented programming in Julia 1.0
- Implement macros and metaprogramming techniques to make your code faster, concise, and efficient
- Develop the skills necessary to implement design patterns for creating robust and maintainable applications
Book Description
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.
What you will learn
- Master the Julia language features that are key to developing large-scale software applications
- Discover design patterns to improve overall application architecture and design
- Develop reusable programs that are modular, extendable, performant, and easy to maintain
- Weigh up the pros and cons of using different design patterns for use cases
- Explore methods for transitioning from object-oriented programming to using equivalent or more advanced Julia techniques
Who this book is for
This book is for beginner to intermediate-level Julia programmers who want to enhance their skills in designing and developing large-scale applications.
Table of contents
- Title Page
- Copyright and Credits
- Dedication
- About Packt
- Foreword
- Contributors
- Preface
- Section 1: Getting Started with Design Patterns
- Design Patterns and Related Principles
- Section 2: Julia Fundamentals
-
Modules, Packages, and Data Type Concepts
- Technical requirements
- The growing pains of developing applications
- Working with namespaces, modules, and packages
- Managing package dependencies
- Designing abstract and concrete types
- Working with parametric types
- Conversion between data types
- Summary
- Questions
-
Designing Functions and Interfaces
- Technical requirements
- Designing functions
- Understanding Multiple Dispatch
- Leveraging parametric methods
- Working with interfaces
- Summary
- Questions
-
Macros and Metaprogramming Techniques
- Technical requirements
- Understanding the need for metaprogramming
- Working with expressions
- Developing macros
- Using generated functions
- Summary
- Questions
- Section 3: Implementing Design Patterns
-
Reusability Patterns
- Technical requirements
- The delegation pattern
- The holy traits pattern
- The parametric type pattern
- Summary
- Questions
-
Performance Patterns
- Technical requirements
-
The global constant pattern
- Benchmarking performance with global variables
- Enjoying the speed of global constants
- Annotating variables with type information
- Understanding why constants help performance
- Passing global variables as function arguments
- Hiding a variable inside a global constant 
- Turning to some real-life examples
- Considerations
- The struct of arrays pattern
-
The shared array pattern
- Introducing a risk management use case
- Preparing data for the example
- Overview of a high-performance solution
- Populating data in the shared array
- Analyzing data directly on a shared array
- Understanding the overhead of parallel processing
- Configuring system settings for shared memory usage
- Ensuring worker processes have access to code and data 
- Avoiding race conditions among parallel processes
- Working with the constraints of shared arrays
-
The memoization pattern
- Introducing the Fibonacci function
- Improving the performance of the Fibonacci function
- Automating the construction of a memoization cache
- Understanding the constraint with generic functions
- Supporting functions that take multiple arguments
- Handling mutable data types in the arguments
- Memoizing generic functions with macros
- Turning to real-life examples
- Considerations
- Utilizing the Caching.jl package
- The barrier function pattern
- Summary
- Questions
-
Maintainability Patterns
- Technical requirements
-
Sub-module pattern
- Understanding when sub-module is needed
- Understanding afferent and efferent coupling
- Organizing sub-modules
- Referencing symbols and functions between modules and sub-modules
- Removing bidirectional coupling
- Considering splitting into top-level modules
- Understanding the counterarguments of using sub-modules
- Keyword definition pattern
- Code generation pattern
- Domain-specific language pattern
- Summary
- Questions
- Robustness Patterns
-
Miscellaneous Patterns
- Technical requirements
- Singleton type dispatch pattern
- Stubbing/Mocking pattern
- Functional pipes pattern
- Summary
- Questions
-
Anti-Patterns
- Technical requirements
- Piracy anti-pattern
-
Narrow argument types anti-pattern
-
Considering various options for argument types
- Option 1 – Vectors of Float64 values
- Option 2 – Vectors of instances of Number
- Option 3 – Vectors of type T where T is a subtype of Number
- Option 4 – Vectors of type S and T where S and T are subtypes of Number
- Option 5 – Arrays of type S and type T where S and T are subtypes of Number
- Option 6 – Abstract arrays
- Option 7 – Duck typing
- Summarizing all options
- Evaluating performance
-
Considering various options for argument types
- Nonconcrete field types anti-pattern
- Summary
- Questions
- Traditional Object-Oriented Patterns
- Section 4: Advanced Topics
- Inheritance and Variance
- Assessments
- Other Books You May Enjoy
Product information
- Title: Hands-On Design Patterns and Best Practices with Julia
- Author(s):
- Release date: January 2020
- Publisher(s): Packt Publishing
- ISBN: 9781838648817
You might also like
book
Kotlin Design Patterns and Best Practices - Second Edition
Future-proof your applications with best practices and design patterns in Kotlin Key Features Understand traditional and …
book
Practical Julia
The Julia programming language is acclaimed in scientific circles for its unparalleled ease, interactivity, and speed. …
book
Think Julia
If you’re just learning how to program, Julia is an excellent JIT-compiled, dynamically typed language with …
book
Julia Programming Projects
A step-by-step guide that demonstrates how to build simple-to-advanced applications through examples in Julia Lang 1.x …