MarkiyanMatsekh / iAmOpen

web application for convenient search of institutions
markiyan.dyndns.biz
1 stars 0 forks source link

Implement the institution query #10

Open MarkiyanMatsekh opened 12 years ago

MarkiyanMatsekh commented 12 years ago

Make the basic implementation of our main business operation - querying institutions. Of course, implementation will change several times, so develop it in a flexible way, without spikes=)

It should be implemented as an action of controller, which reacts only to GET requests.

  1. The method should accept only 1 parameter - a class with all needed information tied together - this is what we call "Posted Data Object Model" (dont misconcept with view model and domain model)
  2. This parameter should be safe, i.e validated at the input(proper types, propert range etc) and if failed - the request should be safely rejected(i think the best way would be to use MVC's model binding)
  3. The logic should be
    • clear
    • extendable
    • independent from other variables except input param of method
    • stable(i.e. no possible crashes or exceptions allowed - all dangerous operations should be wrapped by try catch block)
    • informative - if something went wrong - we should give response with friendly information about the error. But also, this information should be limited to avoid informing malicious users about vulnerabilities of our application. So, the crash information should be friendly, but secure.
    • The method should deliver processed data to the view in form of a single class, which is called "View Model", and which will be specific to almost every single View.

At this moment, let this action method process such information

that's it - after passing the data to the view - responsibilities of the controlelr are over. you can create some basic view only for developing/debugging purposes, dont waste time for design.

About model - create subfolders in Models fodler, with View Model and Post Data Model examples, and there create a folder with a name of the controller, and a file with a name of an action, to which the model refers. These conventions will help us orientate in the future Also, if possible - try to provide some basic unit tests for querying functionality(follow the example in iAmOpen.Tests)

MarkiyanMatsekh commented 12 years ago

I recommend using test-driven development, i.e. - after declaring post data model, view model and action method in controller - don't start implementing the logic. First write few tests, as you expect your controller to work, and then write the functionality until all tests are passed. nonetheless, this approach is hardly applicable for model binding and validating funcitonality, even tough, you can try to.