When creating any software, it is almost inevitable to spend a big part of your development time researching, and many times this involves looking for syntax you don't remember, or for finding out how other people have approached the same problem you are trying to solve.
There are other times when even though you find answers, you still don't understand what's going on, there is some unknown syntax or even terms you've never heard of. If you feel identified here, read on.
This is how I approach it.
How can recursion help me understand something?
Well, it isn't recursion on its own, it is the use of it as a method for getting to the root of the concept you are trying to understand.
There are several ways you may try to overcome situations when despite finding the answers you still don't understand.
The first and most simple way to get out of this situation is trial and error, and if it works, it stays. But this is not the best you can do, since you will not be able to optimize, or easily refactor your code because you still don't understand what's making your code work.
The next way is to ask someone who probably knows this, they give you an answer you can be happy with, and you know who to come back to if something similar comes up again in the future.
Another alternative would be to do your research recursively. Here is the pseudocode:
research(problem) if I understand return answer/solution else research(subproblem)
When I find the answer to the main problem I'm trying to solve, I always make sure I understand the underlying mechanics of the solution. This empowers me to adapt this solution to the current problem I'm trying to solve, to refactor and optimize my code.
If, on the other hand, I know that "Users.all.filter(user => user.group == smart)" gives me the users that are in the smart group, but I don't know how it is working, I will not understand why it takes ages to do this with thousands of users,
By extending my research into why, how, and the alternatives for using "filter" (in this example), I will learn that I'm doing an extra query for each user, and the database is receiving as many queries as users it contains. This is the recursive part, I've done research again with the part I didn't quite understand, now that I understand it I can go back to my previous problem and see if it is really a good solution or not.
Now not only do I know how to solve the current problem, but I'll also know the very basics of the solution and I will be able to easily use those basics for other problems.
Do your research as many times and with as many recursive calls as needed, you will learn so much, and you will learn while applying it, which will make it much easier to remember.
CAUTION: Don't fill up your recursive call stack. If the research didn't give you the answer early on, and you find yourself going several recursive calls deep, it is best to check with your teammates to see if either they can help you redirect your research or give you a hand with the problem you currently have, and then go on with finishing your research, it is still important to learn from it.
I hope you have learned something from this article, and if you have another method you would like to share, please leave a comment. I'd love to also learn from you.