exercise programming style

Exercises in Programming Style: sharing data among threads

This is the 17th post in the Exercises in Programming Style focus series. Last week, we solved the word count problem using the Actor model: objects running on different threads and communicating through messages. This week, we will drop objects, and use data structures that are shared among the threads: such a shared structure is called data space in the book. The original Python code uses two dedicated data spaces.

exercise programming style

Exercises in Concurrent Programming Style

This is the 16th post in the Exercises in Programming Style focus series. In the book, this chapter is called Actors. In software, the actor model is a very specific way to design code: The actor model in computer science is a mathematical model of concurrent computation that treats 'actors' as the universal primitives of concurrent computation. In response to a message that it receives, an actor can: make local decisions, create more actors, send more messages, and determine how to respond to th

exercise programming style

Exercises in Programming Style: spreadsheets

This is the 15th post in the Exercises in Programming Style focus series. Last week, we solved the top 25 word frequencies problem with the help of the database. This week, we will get back to solve it with code alone. The design is to model the problem as a spreadsheet. The spreadsheet holds a number of cells, each cell having a value and a formula. Just like in regular spreadsheet, the formula is a function that might reference another cell’s value, and computes the current cell’s v

exercise programming style RDBMS

Exercises in Relational Database Style

This is the 14th post in the Exercises in Programming Style focus series. So far, we solved the word frequencies problem with code alone. This week, we will solve it with the help of infrastructure. And with this specific problem at hand, what better fit than the database? We can approach the problem by loading the data read from the files in the database, and retrieving the top 25 words with the relevant query.

exercise programming style aop

Exercises in Aspect-Oriented Programming Style

This is the 12th post in the Exercises in Programming Style focus series. This week, we will focus on Aspect-Oriented Programming, a powerful programming technique: In computing, Aspect-Oriented Programming is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns. It does so by adding additional behavior to existing code without modifying the code itself, instead separately specifying which code is modified via a 'pointcut' specification, suc

exercise programming style

Exercises in Programming Style and the Event Bus

This is the 10th post in the Exercises in Programming Style focus series. In last week’s post, we solved the now familiar top-25-word-frequencies-in-a-text-file problem by using Event-Driven Programming. When the number of observer-subject pairs grows, an alternative is to migrate to the Event Bus. The Observer pattern is a messaging pattern: an Observer subscribes to a Subject. When the later emits an event, the former is notified. This is End-to-Point messaging: if multiple observers are

exercise programming style

Exercises in Programming Style: Event-Driven Programming

This is the 9th post in the Exercises in Programming Style focus series. In the post from two weeks ago, we solved the problem using Object-Oriented Programming: we modeled the problem space using objects. For an object to communicate with another one, a dispatch() method was made available. Remember before the web was ubiquitous? Graphical user interfaces were already a thing. One great and widespread way to handle user interactions is Event-Driven Programming: this has been popularized as the

exercise programming style

Exercises in Programming Style: maps are objects too

This is the 8th post in the Exercises in Programming Style focus series. Last week’s post was dedicated to OOP. Despite popular belief, the exercise was solved using neither accessors i.e. getters and setters, nor shared mutable state. The solution’s implementation was based on traditional OOP constructs offered by the Kotlin language: classes, inheritance and overriding. Other languages may offer different ways to do OOP.