As a product and scope grow there is always the trade-off between refactoring and implementing new features.
Increased complexity and requirements
Now most of todemy is written in typescript mainly due to the fact its easily deployed through aws lambda. The codebase has reached the point with the subtle states and interactions between users that some patterns have emerged which can easily simplify the logic.
When Todemy first started there was quite a simple model of a student being connected to an expert or not. As it grew this simple model would not cut it and a factor was required to ensure students in certain states were only allowed specific actions. In addition we wanted to be able to target and assist students in various stages from discovering Todemy for the first time to completing their first connection and beyond.
No code no bugs
As i’ve grown in experience as a developer i’m noticing more and more the most important skill is the ability to delete and refactor code whilst keeping pace with future requirements. Its a fine balance between hacking something together before the tech debt (which is almost always there) slows down progress or leads to more difficult bugs. Since i’m working on a start-up codebase there will always be refactoring opportunities.
The introduction of payments there have been various student and expert actions which have either been deprecated these have been left dangling in the code base. In addition an anti-pattern has been introduced which is duplicating student state checks across various actions.
Refactoring with types
The advantages of strongly typed languages is the ease of refactor. So to tackle the increased student state complexity we determined the various states and extracted all logic to determine which state a student is in into a common place. Now the code just has to handle all cases by switching across each state. This leads to a much easier code-base to reason with.
Hopefully we will be able to release payments soon as the branching differences has become a problem but it is great opportunity to refactor before the big merge and release.