Saturday, 7 May 2016

Migrating Volunteer Management System to Class based views- [GSoC-16 Project]

Volunteer Management System
Systers has many volunteers that offer their skills, time and commitment to accomplish their vision- Women in Computing. The community has implemented a Volunteer Management System to manage their volunteer contact information, track hours and events they worked, and provide reporting functionality at the least.
Django 1.3 introduced class-based views and also added a range of generic class-based views. From then, function-based views have been marked as deprecated. Most of the function-based views in the Systers VMS portal violates DRY.  Class-based generic views helps to streamline common use cases, saving development time and effort.

Migrating FBV to CBV
A view is a callable which takes a request and returns a response. This can be more than just a function in Django. Class-based views allows to structure our views and reuse code by harnessing inheritance and mixins.
One of the advantages of CBV is Inheritance. For instance, large projects like VMS has a lot of redundant code due the repetition of similar views. By migrating to CBV, views could be inherited and thus avoid code redundancy.

Few advantages, which VMS can achieve by migrating to Django’s class based views are :
  1. Django offers various generic views like CreateView, UpdateView, FormView, ListView and DetailView to handle views easily. For eg: Allow users to Create, Update and Delete events and shifts of volunteers with or without authorization, without violating DRY.
  1. Better code readability, reducing the number of lines of code, easing the code review process.
  2. Replacing the decorators by mixins instead, makes them more flexible, extensible and DRYer, just like the move from FBVs to CBVs.  
  3. Better handling of form data, which is handled in a traditional way in FBVs.
  4. Better support from the Django development community as the recent developments are CBV based.

No comments:

Post a Comment