GSoC Journey: Week 02 of Coding Period

Senthilathiban
3 min readJun 7, 2024

--

Hello folks,

Myself Senthil Athiban, a final year undergraduate student at Madras Institute of Technology. This blog represents a continuous series documenting my journey through GSoC. If you haven’t already read my community bonding blogs, I encourage you to check out my previous blogs here. I have been selected as a GSoC student at OpenMRS for the Validation Rule Builder for the Form Builder project. My primary mentor is Dennis Kigen, and my backup mentor is Hadijah Kyampeire.

Week 2: June 03 — June 08

This week, my focus was on two main tasks:

  1. Integrating the rules into the schema.
  2. Writing unit test cases for the rule builder.

Reviews from Mentor:

On the first day of the week, I had a call with my primary mentor to discuss my progress. I demonstrated how easy it is to build multiple logics for the same field, and he was impressed with my work and provided positive feedback. He advised me to start writing documentation in parallel, so users can clearly understand the features and how to build conditional logic for complex forms easily

Tasks Completed

  • Schema Integration: I worked on changing the schema based on user input from the rule builder. Utilizing React Context, I stored the rules for easy retrieval. When users start building rules, these are stored in global state variables and used to create the schema.
  • Unit Testing: Developing a feature isn’t enough; ensuring its stability is crucial. Writing unit test cases helps find potential bugs before production. I used the Jest framework for this task.
  • Documentation: Based on my mentor’s feedback, I started writing user-friendly documentation to guide users in building conditional logic for forms.

Challenges Faced

  • Optimization: Preventing unnecessary re-renders in React was a challenge. The global state variable changes frequently when users build rules, as I used the useEffect hook to listen for changes. Utilizing hooks like useMemo() and useCallback() helps memoize callback functions and variables.
  • Testing: Writing comprehensive test cases to cover all edge cases and ensure the feature works as expected was challenging.

Lessons Learned

Optimization Techniques:

  • Using useMemo() and useCallback(): These hooks are crucial for memoizing expensive calculations and callback functions. By doing so, I was able to ensure that functions and variables are only recalculated when their dependencies change, reducing the number of re-renders and improving performance.
  • Efficient State Management: I refined how I handle global state changes. By carefully managing when and how state updates occur, I minimized the frequency of updates, which in turn reduced the number of re-renders. This involved optimizing the logic within the useEffect hook to only update the state when necessary.

React-Testing:

  • Importance of Test Cases: “ Writing bad test cases is better than having none”. The purpose of test cases is to test the behavior of the feature, not the implementation. Before writing test cases, it’s crucial to understand the feature’s behavior, inputs, and expected outputs. I practiced writing unit test cases extensively before writing unit test cases for my GSoC project.

Plans for Next Week

  • Implement Changes Based on Mentor Reviews: Carefully review and incorporate the feedback provided by my mentor on my recent pull request.
  • Enhance the Conditions Block of the Rule-Builder: I plan to improve the functionality of the conditions block within the rule-builder. This will include integrating new features that allow users to create more complex and dynamic conditions for their forms. The goal is to make the rule-builder more robust and user-friendly, enabling users to define intricate logic with greater ease and flexibility.

About Me

I’m Senthil Athiban, a final-year undergrad from India. Days are for VS Code, nights for GitHub — a constant journey of coding and exploration, fueled by passion and curiosity.

GitHub: https://github.com/senthil-k8s

LinkedIn: https://www.linkedin.com/in/senthil-athiban-m/

Twitter: https://twitter.com/senthil_k8s

--

--