User intent drives frontend design. Frontend design drives backend design. Backend design affects frontend design. Frontend design affects how the users think about the topic, and thus affects user intent.
It's all one large cycle, no matter where you start. I've always figured the goal was to start somewhere ("top" or "bottom" or wherever), make general design pass all the way around, bringing in external requirements as appropriate at each point (what the user wants, what the ui layer can do, what your database can do). Then keep going, until you reach a steady state where all parts generally fit together properly.
The debate isn't top down vs bottom up. If you develop code that you can test, it doesn't matter if you start at the bottom or top. In either case, you can mock the code out to make sure that each component works correctly. If you don't write testable code, you have to rely on setting up your environment before testing anything. This means the only way to test is by stepping through your code.
Writing code with tests gives you decoupled code and the ability to refactor the code later with confidence that it works correctly after the change. Writing the database layer first then building on top of that layer gives you coupled code. When a change is made, there could be a bunch of unintended side effects that can only be found by trial and error.
Look closer. It actually is. At least up to this point it was.
TDD, done according to the orthodoxy, as rabidferrit is describing, is necessarily top-down. You are meant to write a test which exercises a feature, alter the code in the most minimal way possible to pass that test, and then repeat.
That necessarily means you never build out underlying structure until a test requires it. And that necessarily means top-down development.
If you develop code that you can test, it doesn't matter if you start at the bottom or top.
Agreed! But to actually follow the teachings of TDD, you must start top-down, since that's the way the process is specified.
Writing the database layer first then building on top of that layer gives you coupled code.
But this is a filthy lie. :)
Assuming OO development. As a simplistic example, you could build a data access layer based on a set of abstract data models and a repository interface. You then build the database driver to adhere to that interface, and build code that depends on the interface only (where that dependency is injected in some way). When you need to test the consumers of the interface, you provide mocks/stubs for it. Voila, your intermediate layer is testable and decoupled from the actual database driver implementation.
So long as you build to formal interfaces (whatever that means in your language of choice), you can basically start anywhere in your software stack.
I think we're saying the same thing. You're basically writing decoupled code. You want to start at the bottom and write the code for the data access layer and then mock it out. You could do that, and that's fine. But you could also write the interface layer based on use cases described in the requirements, mock/stub out any underlying layer and work downward. I'm not advocating TDD at all. I'm saying writing decoupled code allows you to write testable code. And testable code is the key to happy code.
I mean we can argue semantics day and night, but TDD is typically considered a bottom up approach. There's no technical definition either way but Wikipedia hints at it being a bottom up approach and Googling "TDD bottom-up top-down" brings up discussions where the overwhelming results on the first and second page refer to TDD as being bottom up.
As an aside Richard Feynman, who wrote a report on the Challenger Disaster, discusses various approaches to testing and mentions a process very similar to TDD. However, he is very explicit in saying that testing of that sort is bottom up and advocates a bottom up approach to testing in general.
Once again, it's mostly semantics but when people think of bottom up they think of going from the small to the big.
Nope. Once you have the specifications, design the data structure first.
Designing optimized and extensible data models is a self contained task in itself, not even an easy one, that should not be affected by the UI in any way. Once you have a good data structure, you can build whatever UI you want, for whatever platform you want, for any target user group.
Writing UI around data structures is not always a good idea, because people often do not understand them. I.e. when you normalize well and make an 1:N connection in a new table, people often do not understand why it is needed, so you denormalize in the UI so that every record can look like having Contact Person 1, 2, 3 instead of a list which they don't understand.
169
u/chazmuzz Mar 11 '13
Coming to that realisation made it so much easier for me to work out how to code applications
Step 1) Plan your data structures
Step 2) Write UI around data structures