Swift-like Swift code

A brief introduction to Swift optionals.


Swift is becoming the language of choice for more and more developers on iOS and OS X. It’s fast, simple, clean, and has a number of features that simply aren’t available to Objective-C programmers.

While it isn’t a hard requirement to do so, several projects are being ported from Objective-C to Swift — especially those in their early stages — in order to take advantage of the speed, power, and safety of Swift. One of those projects isn’t actually a software project — it’s the upcoming Swift edition of iOS Games Programming Cookbook. When we began updating the book for Swift, the first thing that we had to do was to rewrite all of the book’s code in the new language. However, a straight re-write from one language into another isn’t enough. Swift behaves differently than Objective-C in very important ways, and that means that your ported Swift code needs to be aware of how Swift does things.

Read more…

Comment: 1

Variations in event-driven architecture

Find out if mediator or broker topology is right for you.

Editor’s note: this is an advance excerpt from Chapter 2 of the forthcoming Software Architecture Patterns by Mark Richards. This report looks at the patterns that define the basic characteristics and behavior of highly scalable and highly agile applications, and will be made available to download in advance of our Software Architecture Conference happening March 16-19 in Boston.

Coming soon.

Available now!

The event-driven architecture pattern is a popular distributed asynchronous architecture pattern used to produce highly scalable applications. It is also highly adaptable and can be used for both small and large, complex applications. The pattern is made up of highly decoupled, single-purpose event processing components that asynchronously receive and process events. 

The event-driven architecture pattern consists of two main topologies, the mediator and the broker. The mediator topology is commonly used when you need to orchestrate multiple steps within an event through a central mediator, whereas the broker topology is used when you want to chain events together without the use of a central mediator. Because the architecture characteristics and implementation strategies differ between these two topologies, it is important to understand each one to know which is best suited for your particular situation.

Read more…

Comment: 1

Software engineers must continuously learn and integrate

Four ways programmers can thrive in their careers.

Software engineers: themes to watch in software architecture, open source culture and code, data, mobile and the Internet of Things

As O’Reilly continues to build and assess our programming content ecosystem — now more than 30 years in the making — we have gone from covering a few key languages, operating systems, and concepts to a diversification of topics that would have made an editor’s head spin in the 1980s. Our goal, however, remains the same: to continue to provide practical content from experts who help you do your job. An important piece of that goal is to keep you informed as we interpret the trends on the horizon. What follows are a few of the core themes we are focusing on at the moment. Expect these to evolve and change with the speed of innovation.

You can also stay in the loop on the latest analysis and developments through our weekly Programming newsletter.

Actually be a software engineer

The term “full-stack” first emerged in a 2008 blog post (the original post is no longer available, but an archive is published here). The term perhaps reached its canonical definition in a post by Facebook engineer Carlos Bueno. He wrote:

“A ‘full-stack programmer’ is a generalist, someone who can create a non-trivial application by themselves. People who develop broad skills also tend to develop a good mental model of how different layers of a system behave.“

Whether you are striving to be a full-stack programmer, a T-shaped engineer, or you choose to rebuff those terms entirely as mere marketing, what now floats around as a “full-stack developer” definition is incomplete. Read more…

Comment: 1

Elvis has left the ivory tower

Pragmatism now rules in team structure, technology, engineering practices, and operational innovation.


Ancient history in computer science (2004) provides a gem about the personas that Microsoft envisioned as users of the development environment Visual Studio. They developed three:

  • Mort, the opportunistic developer, likes to create quick-working solutions for immediate problems. He focuses on productivity and learns as needed.
  • Elvis, the pragmatic programmer, likes to create long-lasting solutions addressing the problem domain, and learning while working on the solution.
  • Einstein, the paranoid programmer, likes to create the most efficient solution to a given problem and typically learns in advance before working on the solution.

These designations received a lot of negative press, particularly around the Mort persona, but I want to focus on Einstein and Elvis.

Formerly, software architects exemplified the Einstein persona: isolated from day-to-day development details, focused on building abstractions and frameworks. The isolation is so common that it spawned its own “Ivory Tower Architect” derogatory phrase. But the realities of building systems that scale as fast as the business does invalidates that approach. Now, Elvis, the pragmatic developer, has ascended to architect while simultaneously descending from the Ivory Tower. Modern architects don’t have the luxury of isolation from the gritty realities of software development today. Pragmatism now rules in team structure, technology, engineering practices, and operational innovation because:

Read more…

Comment: 1

Java 8 streams API and parallelism

Leveraging intermediate and terminal operators to process large collections.

In the last post in this series, we learned about functional interfaces and lambdas. In particular, we looked at the ITrade functional interface, and filtered a collection of trades to generate a specific value. Prior to the feature updates made available in Java 8, running bulky operations on collections at the same time was ineffective and often cumbersome. They were restricted from performing efficient parallel processing due to the inherent explicit iteration that was being used. There was no easy way of splitting a collection to apply a piece of functionality on individual elements that then ran on multi-core machine architectures — that is, until the addition of Java 8’s Streams API.

Read more…

Comment: 1

Using the command pattern with lambda expressions

Reduce boilerplate and make the intent of your code more obvious.

As Java developers we’re all familiar with the concept of Design Patterns. These are codified template solutions to problems that we may encounter when developing. We’re probably also familiar with being told by our functional programming brethren that design patterns are just “missing” language features. So the question now arises, with the introduction of lambda expressions in Java 8 and a more functional style of programming, how do design patterns change? In this article we’ll be looking at the command pattern.

A command object is an object that encapsulates all the information required to call another method later. The command pattern is a way of using this object in order to write generic code that sequences and executes methods based on runtime decisions.

There are four classes that take part in the command pattern:

  • Receiver – Performs the actual work
  • Command – Encapsulates all the information required to call the receiver
  • Invoker – Controls the sequencing and execution of one or more commands
  • Client – Creates concrete command instances


Let’s look at a concrete example of the command pattern and see how it improves with lambda expressions. Read more…

Comment: 1