background preloader

Construction

Facebook Twitter

Curly's Law: Do One Thing. In Outliving the Great Variable Shortage, Tim Ottinger invokes Curly's Law: A variable should mean one thing, and one thing only.

Curly's Law: Do One Thing

It should not mean one thing in one circumstance, and carry a different value from a different domain some other time. It should not mean two things at once. It must not be both a floor polish and a dessert topping. It should mean One Thing, and should mean it all of the time. The late, great Jack Palance played grizzled cowboy Curly Washburn in the 1991 comedy City Slickers. Curly: Do you know what the secret of life is? Curly's Law, Do One Thing, is reflected in several core principles of modern software development: Don't Repeat Yourself If you have more than one way to express the same thing, at some point the two or three different representations will most likely fall out of step with each other. The Single Responsibility Principle says that a class should have one, and only one, reason to change.

Code Kata. Start.sbastn.com/programmer-personality. Java - How does this code break the Law of Demeter. The Clean Code Talks - Don't Look For Things! Law of Demeter. The Law of Demeter (LoD) is a simple style rule for designing object-oriented systems.

Law of Demeter

"Only talk to your friends" is the motto. The style rule was first proposed at Northeastern University in the fall of 1987 by Ian Holland and popularized in books by Booch, Budd, Coleman, Larman, Page-Jones, Rumbaugh and others. A 2000 book that describes it well is The Pragmatic Programmer by Andrew Hunt and David Thomas. The name "Law of Demeter" was chosen because the style rule was discovered while working on the The Demeter Project which ever since was strongly influenced by the Law of Demeter. The Demeter Project develops tools that make it easier to follow the Law of Demeter. In 2003/2004 the Law of Demeter was revisited for Karl Lieberherr's ICSE 2004 keynote paper and presentation.

This paragraph is added in September 2011. This paragraph is added June 2013: The talk by Ben Orenstein at RailsConf 2013 provides a very good visualization of the Law of Demeter. S.O.L.I.D. Software Development, One Step at a Time. Most professional software developers understand the academic definitions of coupling, cohesion, and encapsulation.

S.O.L.I.D. Software Development, One Step at a Time

However, many developers do not understand how to achieve the benefits of low coupling, high cohesion and strong encapsulation, as outlined in this article. Fortunately, others have created stepping stones that lead to these goals, resulting in software that is easier to read, easier to understand and easier to change. In this article series, I will define three of the primary object-oriented principles and show how to reach them through the five S.O.L.I.D. design principles. Have you ever played Jenga? Have you ever thought you were playing a game of Jenga when you were writing or debugging software? Eliminate Most Mocks from Unit Tests « Arlo Being Bloody Stupid. Easily Eliminate Most Mocks July 15, 2012 by Arlo In previous discussions about mock-free unit testing, I’ve shown techniques that I use to eliminate the hard-to-eliminate test doubles.

Eliminate Most Mocks from Unit Tests « Arlo Being Bloody Stupid

I’ve skipped the simple techniques that I apply all the time. Time to fix that. Blog: Lets-Play TDD. Refactoring By Example. In-situ Coding: Programming in the Concrete Kent Beck, Three Rivers InstituteSeptember 2007 This paper describes in-situ coding, an extension of test-driven development, and it’s implementation in Eclipse.

Refactoring By Example

From a test Eclipse helps you create stub methods. Filling in the real code can sometimes best be done in the presence of real data. Changing two settings in Eclipse allows you to code with real data with a minimum of keystrokes. Change the method body template to throw an UnsupportedOperationException and set a breakpoint on all UnsupportedOperationExceptions. Test-driven development (TDD) reverses the traditional flow of programming work. One of the advantages of the TDD cycle is that filling in the implementation is easier once you have figured out the tests. Even with TDD, writing code requires considerable mental effort. Early dynamic programming environments like LISP and Smalltalk supported programming in the debugger.