Design Patterns – Top-Down vs Bottom-Up Approach in Class Library Design

designdesign-patternsmethodologyobject-oriented-design

I am designing a class library to represent western equal temperament music theory concepts for the purpose of composing notated music with code (I realize there are other libraries and programs for this but I want to design my own). The problem I am having is that when I start with the most fundamental concept (PitchClass) and start building upwards, I very quickly spiral out of control with too much complexity in the design. I end up scrapping it and starting over.

I am thinking about a new approach. Start by writing a program (which will not compile) that demonstrates how I want to use the library in the end. For example write the sample programs that might accompany a library first, as a part of the design process. I am hoping that doing so might help me with lower-level design decisions so that I do not lose myself in design complexity.

This approach is analogous to test driven design, but different in that the sample program is not isolated to a single class or function, but instead demonstrates the interface of many high-level classes.

Question
Is the top-down design methodology I am describing here a valid approach? Does it have a name? I am working alone, but do teams ever use an approach like this?

This does not answer the question because it is specifically about designing a web UI and dealing with browser differences.

This is not relevant because it is about back-end vs front-end specifications.

This is not a duplicate because it is specifically about approaching an MVC stack.

Best Answer

You're describing Acceptance Test-Driven Development.

The basic principle behind ATDD is that each software requirement is accompanied by an acceptance test that, when executed, provides proof that the requirement has been satisfied.

enter image description here

Acceptance tests are created when the requirements are analyzed and prior to coding. They can be developed collaboratively by requirement requester (product owner, business analyst, customer representative, etc.), developer, and tester. Developers implement the system using the acceptance tests. Failing tests provide quick feedback that the requirements are not being met.

The tests are specified in business domain terms. The terms then form a ubiquitous language that is shared between the customers, developers, and testers.

Tests and requirements are interrelated. A requirement that lacks a test may not be implemented properly. A test that does not refer to a requirement is an unneeded test. An acceptance test that is developed after implementation begins represents a new requirement.

I'm personally a big fan of ATDD. Requirements that are not accompanied by an acceptance test are not requirements at all; they're wishes.

Related Topic