Skip to content
No description or website provided.
Find file
Pull request Compare This branch is 3 commits ahead of UWE-Ruby:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Stay Confident and DRY

Maintainable code requires that a developer to adhere to a number of principals that are often to difficult to employ at all times. Often times we are both learning a new domain, API, or language as well as trying to solve complex problems. The combination of the two often forces us to make to make poor design decisions.


The objective of the exercise is to make the sample code "better".

While you and your partner are the ultimate arbitrator of "better" there are some core tenets that are often supported by a large set of developers:

The Rules of Simplicity

  • Pass all tests
  • Clear, expressive, and consistent
  • Duplications no behavior or configuration
  • Minimal Methods, Classes, and Modules


Understand the code.

Define the criteria that would make this code "better".

Implement a solution that employs the criteria you defined. The idea here is to generate a solution that you think is "better".

Exercise Retrospective

  • What did you decided would make the sample code better?

  • What things were easier to implement?

  • What things were harder to implement?

  • What, if anything, surprised you today?

  • What, if anything, will you do differently in the future?


  • Ruby Metaprogramming

    Chapter 4 - Thursday: Class Definitions

  • Confident Code

    Suggestions and tips on how to write code that makes a statement, not asking a bunch of questions.

Further Exercise

This example provided with this exercise provides a simplistic solution.

  • Attempt a solution that employs a Domain Specific Language

    Define a language for setting up the board and making moves

  • Attempt a solution that limits the use of "Primitives"

    Primitives for the sake of this problem include: String; FixNum; Float; TrueClass; FalseClass; NilClass; and Symbols

  • Attempt a solution with Test Driven Development

    Remember the goal is to write a test that fails and then write the simplest code that passes the test.

  • Attempt a solution that limits the use of branching logic

    Removing as many if, elsif, unless, and case when from your implementation.

  • Attempt a solution that limits the use of "Primitives" and "Collections"

    Primitives were defined above. Collections are objects and derivatives like Array and Hash

Something went wrong with that request. Please try again.