Creative Bracket

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

In the last video 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.

Further reading


Sharing is caring smile emoji

If you enjoyed reading this post, please share this through the various social buttons hovering on the left/top side of the screen ↖️arrow up emoji. Also, check out and subscribe to my YouTube channel (hit the bell icon too) for videos on Dart.

Subscribe to the newsletter for my free 35-page Get started with Dart eBook and to be notified when new content is released.

Like, share and follow me heart eyes emoji for more content on Dart.

Jermaine Oppong

Hello 👋, I show programmers how to build full-stack web applications with the Dart SDK. I am passionate about teaching others, having received tremendous support on sites like dev.to and medium.com for my articles covering various aspects of the Dart language and ecosystem.

Useful learning materials