Hashmap status: done

CodeCaraCodeCara
3 min read

This week’s post is mainly based on the Hashmap project and is just a brief summary of the project as I did not keep very detailed records, due to many setbacks I had for numerous reasons.

THINGS I’VE WORKED ON/COMPLETED…

I completed the Hashmap project

ISSUES I HAD…

I realised that I hadn’t used node.js to do the Linked List project (and I should have), so for this project, I did not use an index.html and ran my file using node.js from within Visual Studio Code. In order to do this, I had to use VSC debugger and I had to admit that I found it tricky at first. Sometimes nothing happened when I stepped through the code, sometimes nothing got displayed to the console, but I persisted with it and managed to figure out enough to be able to debug and create a working program.

I had a lot of problems using the ‘this’ keyword, which introduced a lot of bugs in certain pieces of code - namely, when the same ‘this reference’ was being called by several different methods and it was hard to keep track of what was going on. I fixed this by assigning a local variable to the ‘this reference’ .

While debugging, I discovered that unless the strict equality operator is used, the number ‘0’ can equate to false!

When trying to increase my buckets size, I effectively needed needed to change the properties of my ‘this’ object, in order for the rest of my code to work. I found out that you can’t just ‘replace’ the ‘this’ object, but what I could do, was change its properties and that did the trick.

So I thought i had finished this project about three times before I actually finished it, but further problems I had after ‘finishing’ it included:

  • For some reason, I had understood that max. capacity was based on occupied buckets instead of the number of entries so I had to go back and fix this

  • My logic to reassign entries to the enlarged hashmap (wrongly) assumed that I could just rehash the key for the first entry in a list in a bucket and the reason I did not see this immediately was because the hash values for most of the entries were the same for capacities of 16 and 32. However, this caused an issue for one entry and so I became aware of the error and fixed it

THINGS THAT WENT WELL…

Once i got past my major debugger problems and the ‘this’ problem, things went a lot more smoothly

THINGS I’VE LEARNT/NEED TO IMPROVE ON…

I took some time off in the middle of this project and I was struggling to use the debugger intially, which demotivated me a little bit and I lost some of my momentum. Hopefully, I will be better-prepared to debug with node.js going forward.

Also, I don’t think that taking too many days off is good for me personally, as I find losing too much time demotivating. The next time I come across something tricky, I am going to limit any time off that I take and just push through the difficulties, taking only short breaks when deemed necessary.

OTHER…

n/a

PLAN FOR THE UPCOMING WEEK…

The Binary Search Tree project - looking forward to starting something new.

0
Subscribe to my newsletter

Read articles from CodeCara directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

CodeCara
CodeCara