While Java 8 is coming, are you sure you know well the enums that were introduced in Java 5? Java enums are still underestimated, and it’s a pity since they are more useful than you might think, they’re not just for your usual enumerated constants! Java enum is polymorphic Java enums are real classes that [...]
Continue Reading »
Tags: clean, dsl, enum, hack, immutable, interface, java, object, optimization, polymorphism, Programming, singleton, state, strategy, syntax, valueobject
Posted in Programming • 3 Comments »
The Composite pattern is a very powerful design pattern that you use regularly to manipulate a group of things through the very same interface than a single thing. By doing so you don’t have to discriminate between the singular and plural cases, which often simplifies your design. Yet there are cases where you are tempted [...]
Continue Reading »
Tags: closureofoperation, composite, design, fold, functional, intentionrevealing, interface, java, language, oo, pattern, Programming, trick
Posted in Functional style, Programming • Comments Off
In functional programming, Map and Fold are two extremely useful operators, and they belong to every functional language. If the Map and Fold operators are so powerful and essential, how do you explain that we can do our job using Java even though the Java programming language is lacking these two operators? The truth is [...]
Continue Reading »
Tags: closure, commonscollections, eclipse, fold, foreach, fp, functional, guava, idiom, java, loop, map, mapreduce, pattern, poorman, Programming, reduce, syntax
Posted in Functional style, Programming • 6 Comments »
In the first part of this article we introduced predicates, which bring some of the benefits of functional programming to object-oriented languages such as Java, through a simple interface with one single method that returns true or false. In this second and last part, we’ll cover some more advanced notions to get the best out [...]
Continue Reading »
Tags: ddd, design, functional, interface, java, language, logic, optimization, predicate, Programming, specification, subsumption, testing, trick
Posted in Patterns, Programming, ddd • 2 Comments »
You keep hearing about functional programming that is going to take over the world, and you are still stuck to plain Java? Fear not, since you can already add a touch of functional style into your daily Java. In addition, it’s fun, saves you many lines of code and leads to fewer bugs. What is [...]
Continue Reading »
Tags: ddd, design, functional, interface, java, language, predicate, Programming, specification, trick
Posted in Programming • 6 Comments »
Now that enterprises have chosen stable platforms (JVM and .Net), on top of which we can choose a syntax out of many available, which language will you pick up as your next favourite? New languages to have a look at (my own selection) Based on what I read everyday in various blogs, I arbitrarily reduced [...]
Continue Reading »
Tags: .net, clojure, F#, functional, groovy, java, language, oo, platform, Programming, scala, syntax, trend
Posted in Programming • 4 Comments »
This anti-pattern is about Using String instances all the time instead of more powerful objects. This is a special case of primitive obsession. Examples Here are some flavours of this anti-pattern: String as keys in a Map: I have seen calls to toString() on objects just to use their String representation as a key in [...]
Continue Reading »
Tags: antipattern, java, oo, Programming, valueobject
Posted in Programming • Comments Off
Deciding where and how to place the annotations is not innocent. The last thing we want is to create extra maintenance effort because of the annotations. In other words, we want annotations that are stable, or that change for the same reasons and at the same time than the elements they annotate. This article suggests [...]
Continue Reading »
Tags: annotation, aop, architecture, c#, classdiagram, crosscuttingconcern, dependencies, design, domain, intent, intrinsic, java, location, pattern, Programming, stereotype, uml, use case
Posted in Programming • 1 Comment »
Many concepts look obvious because they are used often, not because they are really simple. Small quantities that we encounter all the time in most projects, such as date, time, price, quantity of items, a min and a max… hardly are a subject of interest from developers « as it is obvious that we can represent [...]
Continue Reading »
Tags: ddd, design, domain, experience, immutable, intent, java, methodology, oo, pattern, valueobject
Posted in Programming • 2 Comments »
Patterns represent a couple (intent, solution), where the intent matters most. Based on that intents, that can be generic or specialized, I propose to consider patterns like types in languages with strong typing, for the compiler to enforce their constraints. Declaring patterns: what for? Consider the very simple Quantity pattern from Analysis Patterns (Fowler): Represent [...]
Continue Reading »
Tags: analysis, ddd, design, intent, java, methodology, pattern, Programming, tdd, typing
Posted in Patternity, Patterns, Programming • 1 Comment »