Skip to Content
Learning Functional Programming in Go
book

Learning Functional Programming in Go

by Lex Sheehan
November 2017
Intermediate to advanced
670 pages
17h 35m
English
Packt Publishing
Content preview from Learning Functional Programming in Go

Use a parameter object when we have unrelated data elements to pass

A parameter object contains only fields and crude methods for accessing them (getters and setters). It is a dead data structure used only to transfer data.

If we are passing a lot of unrelated data items into a function, then what are the odds that our function would fail the Single Responsibility Principle?

What if we wanted to add logic that could modify a data value based on our runtime context?

However, if we have a set of parameters that describe a new customer, we could consider grouping them into a data objects. Something like the following could be considered a reasonable thing to do:

We grouped the FullName attributes (salutation, firstName, middleName, lastName ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Functional Programming

Learning Functional Programming

Jack Widman

Publisher Resources

ISBN: 9781787281394Supplemental Content