Loading...

Follow A Java geek on Feedspot

Continue with Google
Continue with Facebook
or

Valid

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 intere
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

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
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

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.
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

This is the 7th post in the Exercises in Programming Style focus series. The post of this week is special, as it's about Object-Oriented Programming. It's quite popular nowadays to dismiss OOP. There's a lot of confusion around it. Some people conflate OOP with accessors (i.e. getters and setters), or shared mutable state (or even both). This is not true, as we will see in this post.
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

This is the 6th post in the Exercises in Programming Style focus series. Last week saw us using higher-order functions by passing them as the parameter to another function, and dynamically calling them. The parameter passing is quite nice, but it's not easy to follow the flow of the program. This week we are going to keep those functions, but make use of them in a different way, with function composition.
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

This post is the 5th in the Exercises in Programming Style series. Previous posts include: An introductionManaging the stackAs concise as possibleRecursion This week, the chapter is named 'Kick forward'. The style’s constraint is not to call a function directly, but to pass it to the next function as a parameter, to be called later. Higher-order functions I’m not sure whether the concept of higher-order functions has its roots in Functional Programming. However, the concept itse
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

This is the 4th post in the Exercises in Programming Style series. Previous posts include: An introductionManaging the stackAs concise as possible This week’s post will be back to fundamentals, as the constraint is to use recursion: Recursion in computer science is a method of solving a problem where the solution depends on solutions to smaller instances of the same problem (as opposed to iteration). The approach can be applied to many types of problems, and recursion is one of the ce
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

In previous posts, we had a simple problem to handle - find and sort the 25 most frequent words from a file. Then, we had to comply with different sets of constraints regarding the code: first, no variable but a single untyped array; then, only a stack and a heap. This week, the constraint is to achieve the goal with the shortest code possible. For that, the usage of Kotlin's stdlib is more than welcome.
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Last week, we had our first taste of Exercises in Programming Style. Remember, the goal is to write a simple program, but to comply with some constraints. The previous constraint was that there was only a single variable available, an array. With a statically-typed language such as Kotlin, it required a lot of casting variables to their correct types before using them. This week, the constraint is as radical, but different. Instead of a single array, we have two data structures available: a hash
Read Full Article
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Recently, my colleague Bertrand lent me a copy of the book Exercises in Programming Style by Cristina Videira Lopes. Among all the books that sit on my reading pile, I decided to put it on top, and started reading right away. Currently reading Exercises in Programming Style by @cristalopes - and doing the exercices in #Kotlin. IMHO, it's one of the best (if not the best) book on programming I've read so far! I'll probably blog about it.Thanks @bertrand_cachet for the pointer—
Read Full Article

Read for later

Articles marked as Favorite are saved for later viewing.
close
  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview