Dart and MongoDB Tutorial #3: Refactor our RESTful API into Controller classes

Dart and MongoDB Tutorial #3: Refactor our RESTful API into Controller classes

In the previous tutorial we wrote a RESTful api to interface with a MongoDB database. In this video we will learn how to refactor our solution into a PersonController class responsible to facilitating communication with our data resource.

Classes are usually the common way of encapsulating related logic in your software. They are useful for modularising the logic you write and Dart amkes this a breeze. I hope to demonstrate this a lot more in future articles.

At the end of this video you will be comfortable writing classes to handle HTTP requests and return the appropriate responses. This is a common pattern used by frameworks like Aqueduct and Angel.

Get the source code