-
Notifications
You must be signed in to change notification settings - Fork 0
On Middleware
Because I so highly recommend using Rack for web katas, the question of middleware is bound to come up. Of course I cannot stop you from using whatever middleware you choose. Nor would I if I could. You only hurt yourself by using too many abstractions in your implementation. This is my guidance on deciding when to use middleware:
Think of a kata like a unit test. In an isolated unit test you want to mock out external dependencies to isolate the subject under test. With every kata there is a "subject under test" and "external dependencies". For example, in the basic cookie web kata students are asked to implement "remember me" functionality in order to learn how cookies work under the hood. In this case the "subject under test" is the HTTP cookie headers; beyond that there are a few "external dependencies" including request parameter parsing. Since the point of the kata is to learn the Set-Cookie header, there is no need to do manual parameter parsing. Therefore, feel free to use middleware to handle the request parsing (like mocking out the external dependencies) but to get the most out of the exercise do not use any middleware or libraries to handle cookies for you.