Posts

Showing posts with the label test harness

Legacy code concepts II: the Seam Model

Hi audience, According to my last post, there are some important concepts related to legacy code that it is worth writing down and, therefore, have a clearer picture. Sensing and separation were two of them, both concepts tightly related to breaking dependencies. Moving forward, in line with those, I’m going to write about the Seam Model, introduced by Michael C. Feathers in his book Working Effectively with Legacy Code . The Seam Model The Seam Model is a convenient name to represent the ways by which we can perform tests without producing code changes in order to get a class into a test harness. A Seam Quoting the author, “A seam is a place where you can alter behaviour in your program without editing that place” Important to highlight: alter behaviour without editing . So how can we change behaviour without changing the code? We can actually do it in different ways or manners so far: Seam types Preprocessing seam : used in languages that allow preprocessing, such as C+...

Legacy code concepts I: Sensing and Separation

Hi again, I’ve been lately reading my last technical book acquisition: Working effectively with legacy code (Michael C. Feathers) and, after several chapters, I’ve decided to write down some key concepts in order to make them clearer on my mind. Context The book is mainly focused on how to get a class into a “ test harness ”, or, in other words, how to  successfully create unit tests for legacy code so the risk of side effect changes is minimized. Usually, in order to get a test harness, dependencies between classes must be broken, hence, some code refactors are put in place, this situation leads to a potential vicious circle scenario: A change -> test harness -> break dependencies (refactoring) -> A change Breaking dependencies is the cornerstone of the whole strategy for getting a class into a test harness. However, the solution is, as we already know, quite difficult to implement sometimes, so, in order to tackle such challenge, the author proposes a v...