At first glance, I don’t get react. Yet. The little bit we’ve done I’ve just followed along with a tutorial and enter in what I’m supposed to enter. But there is still a lot to understand about what I’m doing. The next section of class will shed more light. But for now, it’s like reading a foreign language book in the dark. Let’s lit a candle.
So far, one of the projects I’m most proud of is the Fetch IPA brewery finder that Lane and I worked on together. Through that project, we learned a lot about api’s and data handling. There were several times we were hung up on something and had to think outside the box to work our way through. But in the end, we made a good app and can still see where it can grow. There is still a lot of functionality that could be added and many ways to achieve it.
Much of my testing comes from logging functions and checking my results often. When something doesn’t work, I step backwards in the process until I find something that isn’t working correctly. Often it comes down to a small syntax error or typo. Sometimes it’s a bigger mix up in the process that requires more debugging. But I always try to start small and run one part of a function at a time to make sure I don’t write too much to debug easily. I’m still trying to get into the habit of writing modular code as well. Breaking it down into smaller parts makes it much easier to find where something doesn’t work. When it’s all one big block of code, any part of it can make the rest crash.
My best used tool is always console.log. It’s good to see what a function is outputting, or what the value or a variable is at that time, or even if the function is reaching that part of the code.
Resolving unhandled exceptions in Node are most commonly done using a Process. A process is a global object that provides information about the current Node.js process. It is a listener functional that listens for specified events. One of which is the ‘uncaughtException’. If this even happens while the program is running, it will run a function that will catch that error and handle it safely.
Node.js is a single-threaded platform but it is made to be scalable and take advantage of multi-processor platforms as well. It can accomplish this through clustering. Clustering spawns new processes on the operating system and each process can work independently. When done correctly, the main process and it’s child processes can all operate independently at the same time to resolve the program.
When writing callback function, typically the most common first argument will be the error object. If the callback throws an error, it is caught and passed through to the error handler of the function. If no error occurs, then it passes back null or undefined. Often, a simple ‘if’ statement can be used to check if the error object. If anything comes back other than null or undefined, then the error is true and the handler is used. Otherwise, it moves through the if statement with no action and carries on to the rest of the function.