Reader small image

You're reading from  Hands-On Design Patterns and Best Practices with Julia

Product typeBook
Published inJan 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838648817
Edition1st Edition
Languages
Right arrow
Author (1)
Tom Kwong
Tom Kwong
author image
Tom Kwong

Tom Kwong, CFA, is an experienced software engineer with over 25 years of industry programming experience. He has spent the majority of his career in the financial services industry. His expertise includes software architecture, design, and the development of trading/risk systems. Since 2017, he has uncovered the Julia language and has worked on several open source packages, including SASLib.jl. He currently works at Western Asset Management Company, a prestige asset management company that specializes in fixed income investment services. He holds an MS degree in computer science from the University of California, Santa Barbara (from 1993), and he holds the Chartered Financial Analyst designation since 2009.
Read more about Tom Kwong

Right arrow

The history of design patterns

Design patterns is not a new concept to computer programmers. Since personal computers became more affordable and popular in the 1980s, the programming profession flourished and a lot of code was written for a variety of applications.

I remember that, when I was 14 years old, learning the GOTO statement for a BASIC program was one of the coolest things. It literally allowed me to take a control flow to a different part of the code at any time. Perhaps not too surprisingly, when I learned about structured programming and the Pascal language in college, I started to realize how GOTO statements produce messy spaghetti code. Using GOTO for branching purposes is a pattern. It's just a bad one because it makes code difficult to understand, follow, and debug. In today's lingua franca, we call them anti-patterns. When it comes to...

Software design principles

While this book does not cover object-oriented programming, some object-oriented design principles are universal and could be applied to any programming language and paradigm. Here, we will take a look at some of the most well-known design principles. In particular, we will cover the following:

  • SOLID: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
  • DRY: Don't Repeat Yourself
  • KISS: Keep It Simple, Stupid!
  • POLA: Principle of Least Astonishment
  • YAGNI: You Aren't Gonna Need It
  • POLP: Principle of Least Privilege

Let's start with SOLID.

SOLID

The SOLID principle consists of the following:

  • S: Single Responsibility Principle
  • O: Open...

Software quality objectives

Everyone likes beautiful design. I do, too. But, the use of design patterns is not just to make something look good. Everything we do should have a purpose.

The GoF classified object-oriented design patterns as creational, structural, and behavioral. For Julia, let's take a different perspective and classify our patterns by their respective software quality objectives as follows:

  • Reusability
  • Performance
  • Maintenance
  • Safety

Let's understand each of these in the following sections.

Reusability

People often talk about top-down and bottom-up approaches when designing software.

The top-down approach starts with a large problem and breaks it down into a set of smaller problems. Then, if the...

Summary

In this chapter, we started by going back in time and reviewing the history of design patterns. We discussed why design patterns can be useful for software professionals and how we would like to organize design patterns in this book given what we have learned in the past. 

We went over several key software design principles that can be applied universally in any programming language, as it is important that we keep them in mind when developing code and applying design patterns in Julia. We covered SOLID, DRY, KISS, POLA, YAGNI, and POLP. These design principles are well known and well received by the object-oriented programming community.

Finally, we discussed some software quality objectives that we want to achieve by using design patterns. In this book, we have decided to focus on reusability, maintainability, performance, and safety objectives. We also appreciated...

Questions

Review the following questions to reinforce your understanding of the subjects in this chapter. Answers are provided at the back of the book:

  1. What are the benefits of using design patterns?
  2. Name some key design principles.
  3. What problem does the Open/Closed Principle solve?
  4. Why is interface segregation important for software reusability?
  5. What are the simplest ways to keep an application maintainable?
  6. What is a good practice for avoiding over-engineered and bloated software?
  7. How does memory usage affect system performance?
You have been reading a chapter from
Hands-On Design Patterns and Best Practices with Julia
Published in: Jan 2020Publisher: PacktISBN-13: 9781838648817
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Tom Kwong

Tom Kwong, CFA, is an experienced software engineer with over 25 years of industry programming experience. He has spent the majority of his career in the financial services industry. His expertise includes software architecture, design, and the development of trading/risk systems. Since 2017, he has uncovered the Julia language and has worked on several open source packages, including SASLib.jl. He currently works at Western Asset Management Company, a prestige asset management company that specializes in fixed income investment services. He holds an MS degree in computer science from the University of California, Santa Barbara (from 1993), and he holds the Chartered Financial Analyst designation since 2009.
Read more about Tom Kwong