What is HackerRank? Tips when joining HackerRank
What is HackerRank?
HackerRank is a platform for practicing code, according to its founders, where developers from all over the world gather to solve scientific problems. computers such as algorithms, machine learning, artificial intelligence as well as practice various programming models such as functional-oriented programming.
Not only that, HackerRank has gradually become a platform for companies and employers to test the candidate's coding skills. It's convenient to be able to learn to code and show results to employers in the same place at the same time.
Interested in visiting HackerRank.com website to participate and learn to try offline.
However, there are a few issues to keep in mind when practicing code on this platform, this is the advice of Devon Campbell, a web developer from Seattle, posted on the dev.to page that I have translated. again for you to read.
Note when learning code on HackerRank
function Rectangle(a, b) { }
This is the first line of a function that they ask you to write in 10 Days of Javascript. Write a rectangular object lying on the 4th day in 10 days. Most coders will use this first line and fill in the gaps between the marks {}. This is probably also what HackerRank expected.
By looking at this first line, you can understand that a is one side of the rectangle and b is the other side. If you read the article description, it is clear that a is the length of the rectangle and b is the width.
Why do you need a secret?
Batman needs to keep his identity a secret because he often spends the night doing illegal things, even though it's a good thing, he can still be arrested. In order to be free and bring justice to others, he cannot let others know that he is Bruce Wayne.
But, a
and b
here do not need to keep their true identities secret (the length and width of the rectangle). In fact, all they will do in this function is the length and width of the rectangle. That means they don't need to be a
and b
. So why can't length
be length
(width in English) and width is width
(width)?
What are the harmful effects of that naming?
In this HackerRank exercise, you will only write a few lines of code. Not to mention the only two logical parameters for creating a rectangle are its length and width. You probably won't forget what a and b are in the code. However, not only do you read your code, there are others, and many of them may not know what a and b are.
You can feel the code is very concise and smart, and it seems that HackerRank does that very well.
OK, but think a bit, in your work have you ever written an app, which program has so little code? If the application were 10,000 lines of code, each function had parameters with the letters a, b, c, d, e, the story would be very different. You can read and understand this code because you wrote it down, but if someone were to hand over this code from you they would probably have read it and cursed it inside.
You may think Devon is difficult or find the worst example on this platform to disparage. Of course, not every exercise on HackerRank uses obscure variable names, but there are many such exercises. Here is another example:
'use strict'; process.stdin.resume(); process.stdin.setEncoding('utf-8'); let inputString = ''; let currentLine = 0; process.stdin.on('data', inputStdin => { inputString += inputStdin; }); process.stdin.on('end', _ => { inputString = inputString.replace(/s*$/, '') .split('n') .map(str => str.replace(/s*$/, '')); main(); }); function readLine() { return inputString[currentLine++]; } // Complete the minimumBribes function below. function minimumBribes(q) { } function main() { const t = parseInt(readLine(), 10); for (let tItr = 0; tItr < t; tItr++) { const n = parseInt(readLine(), 10); const q = readLine().split(' ').map(qTemp => parseInt(qTemp, 10)); minimumBribes(q); } }
Many variables in the above code are not easy to understand, what is t
, what is q
, what is n
, what is tItr
. The main purpose that the author wants to say here is to just name the variable clearly, write. The code so that anyone who is new to reading it can imagine what this function does, what this variable is. Why do we need that?
Writing code is for humans
You might think that the code is for computers. No, it is not. Code for humans. If it's computer-specific, we don't need high-level languages like Javascript or Python.
Keep this in mind when you write code: Write how others read the code you write that they understand. Variable names, parameters, and functions should contain as many contexts as possible to help readers understand what they have read.a
is a very bad variable name. legnth
is a good variable name and lengthInInches
even better (if you expect the measurement is in inches). If the code changes, make sure you update the names given to reflect what they represent.
Because HackerRank is a big, reputable company, having a well-rated code on the platform also makes employers more interested.
It's just that, when you practice on HackerRank, train yourself the habit of restructuring terrible names of nonsense into a name that can convey the meaning and context necessary to read the code. When you work with projects off the ground, don't let obscure naming harm your code and earn you a reputation as an unreadable code developer.
By keeping in mind that writing code is something you can read later, you not only make it easier for other developers to work with you, but also make customers want to hire you and introduce you. with other companies that need your help.
There was a funny comment below that: When I got into the business I was told, "How to code the guy in the can read and understand" and "Imagine the person who inherits your code is a tall guy. Hot temper, knowing where you are "(If he doesn't understand, he will come to your house and give you a match - a translator).
You should read it
- 27 things I wish I knew before programming
- The wedding invitation card of the coder is completely different from what you think!
- 13 tips to help you learn code super fast without being too expensive
- 10 best programming games to test and develop your coding skills
- 12-year-old coder earns 350,000 USD selling NFT dolphin collection
- Female 10-year-old coder was invited by Google and Microsoft to work
- Set of multiple choice questions about programming with P7 prize
- AI makes coding skills no longer necessary: Here are 5 reasons that prove this statement is incorrect!
May be interested
- Your PC's processing power can help fight coronavirus through the Folding@home effortthe response to covid-19 has spurred 'enormously rapid growth' during the last three weeks, with more than 700,000 new volunteers joining the 30,000 who were already active
- Survival tips in horror game The Forestjoining the forest, players will play the role of the last surviving member of a plane crash, looking for ways to survive. such a confusing and dangerous situation can cause confusion and panic, especially for beginners.
- Vivo Y50: a smartphone that emphasizes speed, multitasking and durabilityas a new smartphone joining the 6 million segment, vivo y50 offers an attractive choice for young users thanks to its modern design and strong performance for every daily use task.
- DTCL season 8.5: Big changes to the shopping cycle, Ultimate Ezreal, Infinity Squaddtcl 8.5 will still be like the previous mid-season updates of truth arena. there will be 15 champions removed and new champions joining you in dtcl season 8.5.
- Facebook allows administrators to collect membership fees from the Group from 4.99 to 29.99 USD / monththe charging feature to join this group is being tested by facebook for prices from $ 4.99 to $ 29.99 per month and it is only enabled when the administrator requires it.
- How to Crimp a Wireelectrical connectors are necessary to join electric circuits together. but to use an electrical connector, you need to attach it to a wire via crimping. whether you're joining 2 pieces of wire or a wire directly to an electrical terminal,...
- Google is preparing to launch a game console, ready to 'battle' the game hardware marketgoogle is more serious than ever in joining the gaming industry, namely gaming hardware.
- Minecraft recipes to make basic items, food, tools, protective gear, wool, dyesjoining minecraft, you can freely create with your rich imagination, such as creating objects. we can create items, objects, materials, blocks and tools in minecraft pe in many different ways.
- The terms you need to know when playing Pokémon Gopokémon go is the most prominent name in recent days. this game of capturing and training virtual animals has created a relatively new way of playing, as players have to constantly move to catch pokémon. during the process of joining pokémon go, you will encounter and use a lot of important terms. so what do they mean?
- Instructions for entering the latest Immortal Legend codes and codesimmortal legend is a massively multiplayer online role-playing game with hands-free, oriental style. joining the game are thousands of gamers fighting in large-scale matches on the same screen to win glory and honor.