Mind maps can be powerful tools to visualize a problem and attempt a solution. They are usually multi layered diagrams that spread out from a central idea and branch out into different possible scenarios/hooks. In my Computer Science classes, however, I have tried different ways to implement the idea of a mind map. Given the timelines we worked with, it wasn’t always feasible to let kids spend time creating a graphic representation of the solution since the challenge was often not that complex. Hence, I have used the IDE (the code editor where the program is written) and comments as a good way for kids to organize themselves before attempting a solution. This post is about how that worked and some pointers on best practices.
Java is the official programming of the IB Computer Science program so I will document this using it’s syntax. Recently I learnt of dailycodingproblem.com which is a service one can sign up for free. Every day, a coding challenge is sent via email. These challenges are usually interview questions asked by major companies including Google, Microsoft, Uber etc. So I will use one of those challenges to present a IDE based mind map and the solution.
To simulate my solution I will use JDoodle’s online Java compiler. The solution produced here is one of many but I am taking the longer route since this post is aimed at students still learning programming.
The first thing I will do is clarify the challenge for myself via comments.
You will notice this first step has the bare bones of the solution. Mostly comments, this step can be considered the “root” of the solution. Doing this helps students combine elements of psuedocode and visual structure so that they know, to start with, what goes where.
The next step is to chart out the function which will accept the array, process it and return it back to main () for printing.
The color coding of IDEs is something I have appreciated because it helps kids focus on what is a keyword, which one is a comment, where are the brackets etc. This focus on the grammar often helps them in structuring the solution into mini units of action.
Now we translate each of the commented lines in the main () function to actual code. We make a few syntax changes (such as returning an array back to main () ) to ensure the additional function works.
With this, the only thing remaining to be done is adding the logic for the processArray() function to work. Mapping out the solution by first splitting it into a main( ) and a method ( ) ensures students dont spend too much time on variables and needless if conditions in the main ( ). This way they can get to the primary solution quickly.
Let us now repeat this approach for the method.
Returning of the array back is already in place. So we need to focus on the remaining lines. We translate these one by one into code.
We declare a new array of the exact same size as our initial array. Then, for each of the element in that new array, we send both the position of the current array’s elements (since it needs to be excluded from the product calculation) and the contents of the original array. This break up is another aspect of mapping the solution since this layer was not part of our original approach. This sort of split helps students understand the solution step by step and not be overwhelmed by it as a whole.
We then code our final method – product( )
As before, we repeat the pattern of translating this function’s statements into code.
We execute this program now and see the results:
- Chalking out the entire solution as comments first, and then filling them up with code as you go along maps out the solution better.
- Students who jump to the IDE to start coding the moment they are given a challenge will feel they are closer to the solution since they are narrowing down the critical pieces of the solution by wrapping up the other parts fairly quickly.
- New innovative solutions often can emerge when splitting up the solution this way since at any given moment, you are focused only on one part of it.
- Mapping out the approach by using methods ensures that they understand functions, parameters, return values more clearly.
- As they develop more skills with the basics of programming, then short cuts, recursive methods, dynamic structures etc can be used to further cut down both planning and execution time.