I’ve Cracked the Code, Please Call Tech Support- Episode 19, Main and Aside

This has felt like a sprint week, for me at least. OCD is still a thing, and the problem is that I don’t get to choose what it hyper focuses on, sometimes. Medication being switched up makes it even weirder for a while, but hopefully we are working towards a more permanent solution.

  1. What is “callback hell” and how can it be avoided?

You know, it’s always intimidating when you research a term and find out that it is also referred to as the “Pyramid of Doom”.

If you have a large amount of callback functions, you can lose track of what does what. When that happens, your code can get a bit…wacky.

If you have callbacks in your code that rely on callbacks from previous parts of your function, and that in turn has a callback that requires that callback….and on and on and on. This is callback hell. And it is very bad.

You can see that this would become very, very difficult to maintain after a short while. If you have an error in any part of this along the line, everything, well, goes to callback hell.

As with any code, the best way to avoid future problems is to plan it out before you get too deep in the weeds. Declare your functions beforehand, give them clearly defined and understood names. If a problem occurs after this, you will have a much better grasp of what it is, where it is, and how to fix it.

2. What are “stubs” in Node.js?

A “stub” is a smaller program that is substituted for a larger one. This means that it can be loaded later, and you can store it remotely.

3. What are “streams” in Node.js?

Given that streams are feared across the industry (no, seriously, even the creator of Redux fears these things), I took some time to research this one.

Broadly, streams are an efficient way to deal with end-to-end information exchanges. Instead of having to load the entire file into system memory, streams allow us to read the data in chunks, pieces at a time. With file sizes getting bigger and bigger, this starts becoming an incredibly helpful thing.

4. What does “chaining” mean in Node.js?

This one was a little unclear, to be honest. According to GeeksforGeeks.com, chaining requires the use of an npm module called async, which you can install to your project like so:

npm init
npm i async

This allows you to chain functions in two ways, parallel or in a series. Parallel chains functions together asynchronously, while series chains them together one after the other. So, when one task is completed, the other begins automatically.

5. Explain “console” in Node js.

The console is a global object, so is accessible to every part of the document. Similarly to JavaScript, the console helps us to debug our programs by providing feedback such as error messages when our programs run.

6. Explain exit codes in Node JS. List out some exit codes.

Exit codes are codes that are provided to basically tell us if our code was successful or not.

A code of 0 means our code was successful. Hooray! But every other code means something else has happened, such as 5, which is known as a Fatal Error, which is unrecoverable.

7. What is the difference between cluster and non-cluster index?

Both of these indexes are used when storing data. A cluster index sorts these data rows in the table on their key values whereas the non-cluster index stores it at one location, while indexing it at another location.

8. What are user defined functions? What are all types of user defined functions?

As per Microsoft, user defined functions in SQL are routines that accept parameters, perform an action (such as complex calculations), and return the result as a value.

Different types of these functions include scalar functions (returns a single data value), table-valued functions (return a table of data), and system functions, which cannot be modified, but are provided by SQL to perform a variety of functions.