What I Did
This week, I continued improving the Rank Emcee module based on Dr. Shawn’s review. I revised the implementation so that bulkStart() and bulkStop() always retrieve the latest data from CouchDB before performing updates, preventing stale revision conflicts. Both methods now update the event and its performances together instead of treating them as separate operations.
I also enhanced the application by introducing the JudgingMethod enum (standard and rank) into EventObj for backward compatibility. In addition, the MainDrawer was updated to display either the standard Emcee page or the Rank Emcee page dynamically based on the active event’s judging method.
Challenge This Week
The biggest challenge was understanding what a true bulk update means in CouchDB. Initially, I updated each performance individually, which worked functionally but required multiple HTTP requests and increased the risk of conflicts if another client modified the same documents simultaneously.
During the PR review, Dr. Shawn flagged that the implementation should use CouchDB’s _bulk_docs API instead of sending multiple sequential PUT requests. This required me to rethink my implementation and better understand how CouchDB handles bulk document updates.
To learn more about the issue, I read through cdb_client.dart and discovered that although the underlying wilt package already supports bulkSave() (which maps directly to CouchDB’s _bulk_docs endpoint), this functionality was not exposed through CdbClient.
Another point raised during the review was that some inline comments had been accidentally removed from the domain files during my refactoring. This reminded me that maintaining clear documentation is just as important as writing functional code, especially in a shared codebase used by multiple interns.
Solution
To resolve the issue, I implemented a new bulkPut() method in CdbClient that leverages CouchDB’s _bulk_docs API. Instead of sending multiple sequential requests, the method retrieves the latest versions of all required documents concurrently, merges the updates, and submits them in a single bulk request.
I also restored the missing inline comments to improve code readability and maintainability. These changes not only improved the efficiency of the implementation but also aligned the code with the project’s coding standards and long-term maintainability goals.
Reflection
This week taught me that writing working code is only part of software development. The efficiency and design of the implementation are equally important, especially in distributed systems where many users interact with the same data simultaneously.
I also realised how valuable code reviews are. Rather than simply correcting my mistakes, Dr. Shawn’s feedback helped me understand the reasoning behind better architectural decisions and encouraged me to write cleaner, more maintainable code.
Looking Ahead
Next week, I plan to continue refining the Rank Emcee module based on Dr. Shawn’s feedback. Once the implementation is approved, I will begin working on the Rank Judge module while continuing to improve the Rank-Based System.
0 Comments