Skip to main content

Posts

Avoiding Memory Leaks:
A peek in Browsers' Closure's Optimization

In this post, I want to cover a Closure optimization meant to help us preventing memory leaks. This optimization is implemented by the three major browsers: Chrome, Firefox and IE. Closure is a popular subject and you can find very good articles out there. Although the post won't cover Closures internals, I will briefly cover the basics in order to keep the reading fluent. Basics To put it shortly; any time we access a method in JS, a special context object is created. This object contains the variables to be searched in the scope chain search process. var x = 10; (function parentFunc () { console.log(x); }()); //* Result: 10 The code above will print 10 because when the parentFunc method is executed, a special context object containing its parent's variables is created and is pointed by parentFunc method scope. When the interpreter starts searching for 'x' value it searches inside the parentFunc scope. If it can not find it, its parent scope gets evaluated. …
Recent posts

How Security may Impact a Web App Performance: A trek into HTTP Caching

In this post I will go over some interesting HTTP topics: HTTP Caching Headers, SSL, Fiddler, and how each of them can have impact over your web application performance (yes, just running Fiddler on your machine can effect your application's caching behavior!).  The main purposes of this post are both, helping out other developers who encountered issues covered in the post, and to stimulate awareness about security and HTTP caching relationship. For .NET Stack developers, don't be disappointed when I will mention Spring MVC, it is just my current REST provider (long live IIS!), the essence of the post should be interesting regardless. NOTE: When mentioning 'browser' I am referring by default to Chrome version 51.0.2704.84. Basic HTTP Caching Headers Rules I won't fully cover basic HTTP Caching protocol subjects like Etag/Last-Modified, no-store, no-cache etc. But before staring let's have a very quick reminder about basics HTTP Caching concepts: no-cache - must revali…

Design API for Multiple Different Clients

Today I want to talk about common design challenges related to architecture of robust APIs, designed to be consumed by multiple clients with different needs.

Our use case is the following: We need to build a N-Tier Web REST/SOAP API that is supposed to read/write data from a DB, perform some processing on that data and expose those methods to our API consumers.

In addition we have multiple different API clients each with different needs, meaning we can't just expose a rigid set of functions with a defined group of DTOs (Data Transfer Objects).
DTO vs POCO Before start diving I want to explain shortly the difference between these two controversial concepts.
DTO Objects that are designed to transfer data between edges (i.e. between processes, functions, server & clients etc'). Typically DTOs will contain only simple properties with no behavior.
POCO Objects that are designed to reflect the internal business data model. For example if you have an eCommerce platform you will…

The GoF Hot Spots - Bridge vs Strategy

As part of my "GoF Design Patterns - The Hot Spots" posts series, this post is focused on two Design Patterns: Bridge and Strategy.

Although these two DPs are completely different, when googling them we encounter several common misconceptions that may make us think that Bridge and Strategy are similar or even same patterns.

I am not sure why but one of the popular misconceptions is that these two DPs shares the same UML diagram.

We will dig into the original GoF Design Patterns (aka: DP) description trying to figure out the real Hot Spots (aka: specific particular parts that differentiating them from each other) of these two DPs and the relationship between them.

In order to maximize the clarity of this article, I used two conventions:
Phrases inside [square brackets] are meant to help understanding GoF definitionsItalic sentences are GoF's book citations
StrategyGoF Definition"Define a family of algorithms [Classes that inherits from the same Abstract/Inte…

The GoF Hot Spots - Factory Method vs Abstract Factory

As part of my "GoF Design Patterns - The Hot Spots" posts series, this post is focused on two Creational Design Patterns: Factory Method and Abstract Factory.

We will dig into the original GoF Design Patterns (aka: DP) description trying to figure out the real Hot Spots (aka: specific particular parts that differentiating them from each other) of these two DPs and the relationship between them.

In order to maximize the clarity of this article, I used two conventions:
Phrases inside [square brackets] are meant to help understanding GoF definitionsItalic sentences are GoF's book citationsFactory Method GoF Definition:" [1] Define an interface for creating an object, [2] but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses."
GoF Description & Hot Pots: "Consider a framework for applications that can present [handle] multiple documents to the user. Two key abstractions in this framework are t…

GetHashCode Hands-On Session

The following is a hands-on post meant to demonstrate how GetHashCode() and Equals() methods are used by .NET Framework under the hood. For the sake of simplicity I will refer to the popular hashed-base Dictionary type, although any other hash based structure will follow a similar behavior, if not the same one. After understanding this post you should be able to spot potential problematic behaviors and resolve them, prevent creation of unreachable items in dictionaries and improve CRUD actions performance on hash based structures. The TheoryGetHashCode() is used to create a unique integer identifier for objects/structs. The hashcode can be used for two purposes: Programmatically, by developers, to distinguish objects/structs form each other (NOTE: Not recommended when the default .NET implementation is used, as it's not guaranteed to preserve the same hash between .NET versions and platforms)Internally, by .NET Framework, when using the object/struct as a key in a hashed based l…

GoF Design Patterns - The Hot Spots

Intro Now days, any programmer working with a language which conforms to the OOP paradigm, understands the power of Design Patterns (DP). A variety of great books are available for plain English interpretations for the various 23 GoF design patterns and the differences between them. Yet, there are still many controversies regarding how certain patterns differ and how they are related. Design Patterns, at first glance, sometimes appear very similar, not to say identical. When searching answers in forums, articles and blogs, I have encountered in a wide range of responses, starting from "It's the same DP and the only difference is the intend of the developer" and reaching "the questioned DPs are completely different and I can't even understand your question". If you sense that the truth lays somewhere in the between those responses, this new series of posts might interest you. This post is a first in a new series of posts, in which I will try to highlight …