Coding Games: Tips and Tricks to Master the Key Concepts of Coding by Robert C. Matthews
Author:Robert C. Matthews [Matthews, Robert C.]
Language: eng
Format: azw3
Published: 2020-11-02T00:00:00+00:00
List
HashMap
And so on.
Weâve talked about the first two on the list, so letâs briefly touch on HashMaps.
What are Hash Maps? How best to highlight their functions than to, as I always love to do, first see how they are applied. Imagine you are an experienced full stack developer called in to troubleshoot a retail e-commerce website which has been having some problems with bugs and such. The first you do of course is to run the software on your IDE (more on that later). Upon running the code, you begin noticing some arrangements such as:
âShoesâ -> âOxfordsâ, âBroguesâ
âUtensilsâ -> âSpoonsâ, âForksâ, âKnivesâ
âKnivesâ -> âJapaneseâ, âWesternâ
âShirtsâ -> âformalâ, âcasualâ
If you see something like that, donât be afraid. And itâs not the problem (unless it is).
Letâs take a further look at this highlighted example.
One thing you notice here is that there are âgeneralâ names of items on the left, which point to more specific ones on the right. This pairing up of values is in the coding circle as a Key/Value pair.
The âkeyâ in these instances are the general items - shoes, shirts and such, and value here means the specific items from the general list.
This pairing arrangement is possible due to a HashMap data structure! This is a very useful concept that is applied to almost every retail website! For example, if you want to buy something on Amazon right now. Letâs say a phone. Where does the home page of the website first take you? To the electronics section! Next, you choose the phone maker, (also making use of a hash map), where you fill your specifications and such. This similar application of HashMap has tremendous potentials in our manipulation and application of data variables.
While the representation of HashMaps I gave up there looks rather fancy, the truth is, HashMaps are slightly more complex than that.
For example, hereâs how the HashMap of the program I showed you would look like, in Java code.
Map<String, List<String>> Shoes = new HashMap<String, List<String>>();
shoes.put("Oxfords", new ArrayList(Arrays.asList("Brogues", "Loafers", "Monkstraps")));
Whoa, right?
Thatâs a lot of brackets. Letâs break it down a bit.
As you know, the HashMap data structure is used to store key/value pairs. In this selected example, our key was shoes and the value pairs are the oxfords and such. Remember that the data type is a string. And because the collection of data is similar, they are defined by arrays. Now we get to an interesting part. Say a new type of shoes was just shipped in and we want to add this new option to our web app. What is to be done?
Traditionally, the âoldâ method would be to rewrite the code repeatedly, which is mindless drudgery and pretty much depressing. Instead what we do is create a new list of Arrayed data, insert it in our HashMap, and voila, done!
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7808)
Grails in Action by Glen Smith Peter Ledbrook(7719)
Azure Containers Explained by Wesley Haakman & Richard Hooper(6808)
Configuring Windows Server Hybrid Advanced Services Exam Ref AZ-801 by Chris Gill(6806)
Running Windows Containers on AWS by Marcio Morales(6326)
Kotlin in Action by Dmitry Jemerov(5089)
Microsoft 365 Identity and Services Exam Guide MS-100 by Aaron Guilmette(5053)
Combating Crime on the Dark Web by Nearchos Nearchou(4625)
Microsoft Cybersecurity Architect Exam Ref SC-100 by Dwayne Natwick(4576)
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4437)
The Ruby Workshop by Akshat Paul Peter Philips Dániel Szabó and Cheyne Wallace(4316)
The Age of Surveillance Capitalism by Shoshana Zuboff(3977)
Python for Security and Networking - Third Edition by José Manuel Ortega(3877)
The Ultimate Docker Container Book by Schenker Gabriel N.;(3535)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3528)
Learn Wireshark by Lisa Bock(3493)
Mastering Python for Networking and Security by José Manuel Ortega(3376)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3353)
Blockchain Basics by Daniel Drescher(3322)
