Software

Once upon a time TDD... and me

Once upon a time TDD... and me

Once upon a time, a young woman had plenty of projects and passions and was a bit hyperactive. She didn’t enjoy talking about her life and wondered how she would write this post.

Among her early dreams were learning many things about science and software engineering. She started with biosciences (which, by the way, are fascinating — nothing is more complex and well-crafted than the human body) and then decided to continue with software engineering. However, the software engineering program she completed only lasted one year (6 months of classes and 6 months of internship). Of course, this was simply a doorway to the world she was eager to discover.

Continue reading
Refactoring Is Like Sleeping

Refactoring Is Like Sleeping

Bob is a developer. He has been asked to add a brand new feature to the application. He’d like to take this opportunity to refactor the code a little bit, since it doesn’t respect the good practices he learned from the last Software Craftsmanship meetup. However, Bob was told he couldn’t do it because there was not enough time to do anything other than produce features. So, Bob thought, “there is never enough time anyway”…

Sounds familiar? Indeed, refactoring is often seen as an activity without any value. Other things in life can also seem pointless. There is one that takes almost a third of our lives during which we literally do nothing: sleeping!

Continue reading
Que faire lorsqu'une méthode privée veut être testée ?

Que faire lorsqu'une méthode privée veut être testée ?

Les tests automatisés servent à vérifier le bon comportement d’un objet (ou d’un ensemble d’objets), indépendamment de la manière dont ce comportement est implémenté. Le comportement d’un objet est décrit par son API publique (constructeurs, constantes et méthodes publiques). Les tests ne devraient donc utiliser que cette API.

Les méthodes privées (et protected) ne faisant pas partie de l’API publique d’un objet, elles ne devraient pas être appelées directement par le code de test.

Cet article a pour objectif de montrer comment réagir lorsqu’il paraît nécessaire de tester une méthode privée.

Continue reading
Pourquoi ne pas utiliser l'héritage pour éviter la duplication de code ?

Pourquoi ne pas utiliser l'héritage pour éviter la duplication de code ?

L’héritage est une composante très importante des langages orientés objet tels que Java. Cependant, il doit être utilisé à bon escient afin de respecter les bonnes pratiques de programmation.

Il m’est arrivé de rencontrer des cas où l’héritage était utilisé afin de ne pas dupliquer du code. Le but de cet article est d’illustrer une telle utilisation, d’analyser ses inconvénients et de montrer une manière possible de la corriger.

Continue reading