Here you can find my private notes about programming that I wanted to share with you. Feel free to filter based on the topic you want or search for something specific.
Hints and tips about Load and Web Tests with Microsoft Visual Studio
When dealing with large web applications you will definitely have to apply some load to the infrastructure before going or even during being online. A Load test is a predefined set of URL requests that are submitted to your application from multiple virtual users. The number of the users or the amount of time a Load tests runs, can be defined from you.
By testing your application with Load tests you can be sure about the maximum workload or number of requests that your infrastructure can support and handle simultaneously. Having this information you can decide if you have to buy (on premise case) or rent (cloud case) new hardware.
With this article I would like to give some tips and tricks for features of the Load tests in Microsoft Visual Studio.
Define the width of every column in a HTML-table and show only one line of text per table-row by using the ellipsis character
A very old HTML best practice suggests that we should not use tables to structure the HTML elements inside a webpage. This solution was used extensively a decade ago, and for this reason tables got a very bad reputation in the web community. However, using tables in your HTML code for structuring and presenting a set of data is still a valid option.
When you use a table with multiple columns, you often want to define the width for each of the columns of the table.
One reason for that could be that you want to show more context of an “important” column than the others.
Another reason could be the fact that if you do not define the column widths, the longest value in a column will also define the width of the column. As a result the other columns are getting shrank.
How to test the HTML elements and their DOM properties with the Jasmine framework
When you test your JavaScript code you often want to test the user interactions with the UI of your web application and not just its logic. Testing the UI makes even more sense if you use a JS-framework which offers a list of UI controls.
Consider the following use-cases that could be unit tested:
The user loads a new webpage and the cursor has to be placed automatically inside the search input field.
The search input, together with other input elements, is placed inside a div with a red background.
The this keyword in JavaScript - Must Know JavaScript features every programmer should learn to master the language
The previous days I had a great conversation about the fundamentals of JavaScript, scope, closure, etc.. The this keyword was also a discussion point. I wasn’t 100% sure of the rules that apply to this and I wanted to refresh my memory about the possible ways to use the keyword and for each case identify the owner of this when a function is invoked.
The four, and only four rules about this
Using the new keyword for creating new objects. In that case the this will be bound to the new created object.
As you can see in the following example, this binds to the object that created a new Car instance. For that reason we can have multiple objects from the same “class” (there are no classes in JavaScript) and each of these objects can have different values on their properties. An important thing to take away from this example is that we create a new property each time we use the this keyword inside the “constructor” function, and the value of this property is different for every instance the “class”.