The Programmer Blog RSS

The Programmer Blog is here to help you, the programmer. We do our best to provide useful resources that offer explanations to popular programming problems, across a variety of programming languages. If you would like to suggest a blog topic or have a question, please leave us a message.

Java, java.lang.OutOfMemoryError, systemoutofmemory

Learn how memory leaks manifest themselves in Java and how to avoid a System Out of Memory Exception. Contrary to what many people think, an application written in Java may rather present memory leak problems, resulting in exceptions of type System Out of Memory (java.lang.OutOfMemoryError). Unfortunately, a large number of Java programmers think that Memory leak is a C /...

Read more

Javascript, JSON, KnockoutJS

When using KnockoutJS and the Knockout Mapping Plugin, you may notice extra properties are being serialized with your viewmodels, ex. "__ko_mapping__" or "copiedProperties" objects. JSON Example: { "MyObject": { "Id": "00000000-0000-0000-0000-000000000000", "Type": 1, "Name": "Default MyObject" }, "__ko_mapping__": { "ignore": [], "include": ["_destroy"], "copy": [], "observe": [], "mappedProperties": { "MyObject.Id": true, "MyObject.Type": true, "MyObject.Name": true }, "copiedProperties": {}, "": {}...

Read more

API, Javascript

One of the key ingredients to an AJAX driven website is the ability to reliably get query string parameters. We will run through an example using the new URLSearchParams API and also a Javascript only implementation for legacy browsers. Using the URLSearchParams Web API Consider the url http://www.systemoutofmemory.com?id=1&firstName=Bob&hobby=Baseball&hobby=Basketball Get the query string params var queryParams = new URLSearchParams(window.location.search); Iterate &...

Read more

c#, list, random

Randomizing a list<T> can be done using the Random and a simple LINQ query. Check out our card shuffling example below: Randomizing a list of objects Given a Card class public class Card { public string Name { get; set; } public int Value { get; set; } } Initialize a new list of cards var cards = new List<Card>()...

Read more

c#, cast, enum, int, string

Casting enums can get tricky in C# so we wanted to provide a few examples to help clarify the situation. Below we are using a simple enum to demonstrate how to cast an int to a enum, enum to an int. We will also go over how to check if an enum exists given an integer or string and how to...

Read more