An intro to try...catch, Comments, Web Catching and Cross Browser Testing

Abu Siddique
3 min readMay 6, 2021

--

As a programmer, we all love or hate error. It is a part of our coding life. We all heard that; errors are good. At first sight, we fear Errors, but by making Errors, we actually learn how not to do something and how to do it better next time. Normally, a script “dies” (immediately stops) in case of an error, printing it to console but doing some error handing we can do something more reasonable. Here I'm gonna discuss the try…catch method.

try…catch syntax

Let’s see the syntax for the try and catch with optional finally block:

In the above code, the first two blocks try and catch. Where the try block contains the main code that can generate errors. If an error occurs then try block throws the exception that is caught by the catch block, in which we can handle it as we want. We can either show a user-readable message or we can show the error message nu alert.

The optional finally block executes unconditionally after try/catch.

Comments

Comments are specially marked lines of text in the program that are not evaluated. We normally use them to describe how and why the code works, just to support the code. But some of us do in such a way that it becomes frustrating for readers which are Bad comments. Inaccurate comments mislead the people who read the code. Try to avoid “explanatory” comments in code. It's better to let the Code Explain Itself. Some comments that are necessary or beneficial are Good comments. For example, sometimes we need a legal statement in the comments of our code. More situations that justify commenting in codes are explaining intent/architecture, clarification, warning of consequences, JSDoc comments, function usage, emphasis, etc.

Web Catching

Caching is a way of temporarily storing the contents of a webpage in locations near the user, similar to the way our memory works. It is used to improve the performance of any website and application by storing commonly accessed data in several places, and then serving that data to requesters from that store. One of the factors to the popularity of catching is Data cost which is simply cost to generation, transfer, and storage. There are various types of caching including client-side, server-side, and hybrid.

Client Caching helps limit the data cost incurred by the user by storing commonly useful data locally that the client often requests. The benefit of it, clients can get common data rapidly and also reduce the network traffic from the internet servers.

With Server Caching, data is cached on the server. Data can be cached at any point or time on the server when it makes sense. Clients can then access the information more quickly, again improving the user experience.

Hybrid Caching allows the client or user-specific content that may not be applicable to other users to be stored on the local client cache while the server cache stores universally required data. That means faster data delivery and greater redundancy, as well as a freeing of core resources for the actual main systems servers.

Cross Browsing testing is a method of quality assurance for web applications across multiple browsers and different devices. As a developer, our job is to make our website accessible and appealing to the broadest range of users. Cross browser testing users can easily view content and experience optimized functionality no matter what device, operating system, or browser they access it from.

The most common workflow for cross browsing testing is

Initial planning > Development > Testing/discovery > Fixes/iteration.

--

--