Using Composer from Java Developer’s Perspective

Background Composer is a dependency manager for PHP. It makes your life easy. If you are a Java developer and have used Apache Maven, you’ll find Composer a familiar tool. Unlike Maven, dependencies are declared in a file called composer.json

How to create classes in JavaScript

Background [wp_ad_camp_1] I must admit I used to dislike JavaScript and UI development. First, I related JavaScript to Web UI design at which I am very not good at. I do not have an artistic side when it comes to

How to adjust table headers in Angular-Datatables

This highlights how to programmatically adjust table headers after rendering angular-datatables. Note that sometimes before adjusting the headers so that they will aligned with the table body (

), a delay (via setTimeout()) is needed as the adjustment may be interrupted or prevented by any of the tables’ parent elements.

Working with Reference Types in JavaScript

JavaScript has both primitive and reference types. It has three primitive types: string, numeric, and boolean. Internally, these are small and fixed-sized collection of bytes that are easily and predictably manipulated at the low (primitive) levels of the JavaScript interpreter. Example of strings are ‘This is a string’ and “This is another string”. Numeric values – 1, and 3.1416. Boolean values – true or false. On the other hand, reference types are different. They include objects (including JS built-in objects), Arrays, and functions. Essentially, they can have any number of properties or elements with various types (both primitives and references), so they cannot be manipulated as easily as fixed-size primitive v

JavaScript Arrays with Elements of Different Data Types

Array with different types of data? Weird stuff! Generally, an array is collection of similar items. In Computer Science 101, this means the items are of the same data type. We have an array of integers, boolean values or strings. But in JavaScript, arrays can have elements of different types.

Type Checking in JavaScript

Okay, JavaScript is a loosely-typed language, which means you do not declare the data type of a variable explicitly. In a basic variable assignment expression, e.g., var i = 4;, the value that assigns to the variable determines the data type of the variable. As you assign different types of data to the same variable, its data type changes as well. Given the nature of JavaScript, finding out what data type a variable represents before using it is very important.

JavaScript Static Properties and Methods

In JavaScript Object Creation and Object Methods and Properties, we talked about methods and properties that are tied to an object. Without an object, these properties are unusable and inaccessible to other codes. There is another type of members – static methods and properties. These are only accessible via the class itself. These are even inaccessible if referenced via objects.

Three ways to mock an object using Mockito

If you’re new to Mockito and have only seen a sample or two on the Internet, you might find other examples create mock objects in different ways using the same framework. As a matter of fact, there are three (3) ways to create mock objects in Mockito.

Void methods and Mockito in Java

When we talk about unit tests, we think about input values and return values to/from methods. Returned values are checked against expected values as a way to verify behavior of codes. But how would you test codes that do not return any values? Essentially, we resort to stubbing out void methods. That is easy in Mockito!

Inheritance in Object-oriented JavaScript

Inheritance in JavaScript is called prototypal inheritance. Objects inherit from objects. When we create an object from a class, [wp_ad_camp_5]

it always inherits from

In Java speak, this is like saying  “any class inherits from Object class”.