Jonathan Boccara's blog

A new post every Tuesday and Friday morning

How to Flatten Out A Nested Switch Statement

Published June 27, 2017 - 1 Comment
Flatten switch case nested collapse expressive C++

With my team we’ve recently come across an annoying switch nested in another switch statement, and I want to show a solution for flattening out this sort of structure. Motivation Let’s consider two enums representing the size and color of a shirt. While I don’t work in the clothing industry, using a simple example by stripping […]

7 Ways to Get Better at C++ During this Summer

Published June 23, 2017 - 13 Comments
Summer C++

Summer Is Coming. With it comes the sea, the sun, the beach, or the mountain or perhaps your family house. But there is also a great thing that comes with summer: more time. Maybe you’re taking some time off, or maybe this is just because work is less intensive during this period. In all cases, summer is […]

The Interface Principle in C++

Published June 20, 2017 - 10 Comments

The Interface Principle in C++ encompasses a specific combination of features and ways of considering what an interface is, that allows to write expressive C++ code that preserves encapsulation. It has been around for a while, is still currently used, and may be enriched in the future versions of the language. So it’s worth being aware of. Note that […]

The Right Attitude to Deal with Legacy Code

Published June 16, 2017 - 1 Comment

If you’re like the majority of software developers working for a company, you probably have to deal with legacy code, at least sometimes. Well maybe you don’t because you’re working on a brand new project with few people. But chances are you do. I for sure have faced legacy code. Many times, and coming in […]

The real difference between struct and class

Published June 13, 2017 - 4 Comments

“Should I use a struct or a class?” Such is the question many C++ programmers ask themselves, or ask around to more experienced co-workers, when designing their code. There is sometimes a cloud of misconception about what the difference between struct and class technically is, particularly amongst the youngest developers. And once we get to understand the technical difference, […]

Using toString on Custom Types in C++

Published June 6, 2017 - 10 Comments

“Give me a string representation of this object.” This is a fairly ubiquitous sentence in programming, that many languages express in one brief statement: Java has .toString(), Python has str and Haskell has show, to cite just a few. My goal here is to propose a concise way to also express this in C++. Note: after I wrote […]

Expressive C++ Template Metaprogramming

Published June 2, 2017 - 3 Comments
Expressive template metaprogramming tmp

There is a part of C++ developers that appreciate template metaprogramming. And there are all the other C++ developers. While I consider myself falling rather in the camp of the aficionados, I’ve met a lot more people that don’t have a strong interest for it, or that even find it downright disgusting, than TMP enthusiasts. Which camp do you […]

Making Strong Types Hashable

Published May 30, 2017 - 5 Comments

Strong types are types that are built over primitive types, and add meaning to them. My purpose today is two-fold: showing you how to write an STL-compliant hash function for custom types so that they can be used in unordered containers such as std::unordered_map, making a hash function available for strong types. For more about the motivation […]

Strong Types Conversions

Published May 26, 2017 - 0 Comments

Strong types are a way to add a meaning to objects by giving them a meaningful name, by using types. This lets the compiler, human beings, and developers understand better the intent of a piece of code. We’ve been exploring strong types on Fluent C++. I focus here on how to define strong types conversions. If you want to catch […]

1 2 3 7