By Joshua Backfield

When you have an valuable (and most likely object-oriented) programming historical past, this hands-on e-book will consultant you thru the alien international of useful programming. writer Joshua Backfield starts off slowly by means of displaying you the way to use the main invaluable implementation techniques sooner than taking you additional into functional-style thoughts and practices. In each one bankruptcy, you will research a practical idea after which use it to refactor the fictitious XXY company's imperative-style legacy code, writing and checking out the practical code your self. As you move during the booklet, you are going to migrate from Java 7 to Groovy and eventually to Scala because the desire for larger useful language help progressively raises.

Show description

Read or Download Becoming Functional: Steps for Transforming Into a Functional Programmer PDF

Best object-oriented software design books

Java & XML: Solutions to Real-World Problems

With the XML ''buzz'' nonetheless dominating speak between net builders, there is a genuine have to the way to lower throughout the hype and placed XML to paintings. Java & XML indicates the right way to use the APIs, instruments, and methods of XML to construct real-world purposes. the result's code and knowledge which are moveable. This moment variation provides chapters on complex SAX and complicated DOM, new chapters on cleaning soap and information binding, and new examples all through.

Data Structures for Computational Statistics

Because the starting of the seventies computing device is accessible to exploit programmable pcs for varied initiatives. throughout the nineties the has built from the large major frames to non-public workstations. these days it's not simply the that is even more robust, yet workstations can do even more paintings than a primary body, in comparison to the seventies.

Object-Oriented Analysis, Design and Implementation: An Integrated Approach

The second one version of this textbook contains revisions according to the suggestions at the first variation. In a brand new bankruptcy the authors supply a concise creation to the rest of UML diagrams, adopting an analogous holistic technique because the first version. utilizing a case-study-based method for offering a complete creation to the foundations of object-oriented layout, it includes:A sound footing on object-oriented innovations comparable to periods, items, interfaces, inheritance, polymorphism, dynamic linking, and so on.

Extra info for Becoming Functional: Steps for Transforming Into a Functional Programmer

Example text

Example 3-14. enabled field. We’ll address how we might fix this when we start looking at immutable variables. info | 31 Returning an Empty List Rather Than Null In Example 3-14, notice that we’re able to pass the list that was re‐ turned by getCustomerById directly to foreach. This has the nice side effect that we don’t need to do null checking. ” Groovy Version of setContractEnabledForCustomer The following code shows a simple way to accomplish the same functionality we’ve just implemented, but in Groovy.

Info Whereas we’re trying to ensure that there are no functions that have side effects, we should no longer be using our foreach function. Instead, we’ll be using a map or collect function. Let’s write that really quickly so that we have it ready. Our map function will take a list of anything and another function that will be used to transform each individual item it is passed. The code in Example 3-19 shows the new map function, which will exist inside our Customer class. Example 3-19. call(obj)); } return outList; } Let’s remember our setContractForCustomer function; we can refactor it to return the list of Contracts that were updated, as shown in Example 3-20.

Example 2-11. ” We can create a new class that takes a customer and returns a customer, as shown in Example 2-12. Example 2-12. getEnabledCustomerField(new CustomerAsCusto mer()), which gives us a list of all our enabled cutomers. But what if we didn’t want to have to create all of these named classes? What if we didn’t actually need to define full classes? Well, that leads right into the next section on anonymous functions. info | 15 Anonymous Functions Anonymous functions are split into two types: lambda functions and closures.

Download PDF sample

Rated 4.42 of 5 – based on 28 votes