Home » Software Development

Software Development

Debugging Angular 2 Applications from the Console

Learn how to access useful information from your Angular 2 components right from your browser’s console There have been some quite useful articles for how to debug Angular 1.x applications from the browser’s console. But how can we achieve the same in Angular 2? Is there even a way? Let’s see. I always found it quite neat how to debug ...

Read More »

Learning Angular 2: Creating a tabs component

A follow up on thoughtram’s excellent article on creating a tabs components with Angular 2 This is a follow-up article of thoughtram’s excellent article on developing a tabs component with Angular 2, where we’re going to explore an alternative way of creating a tab component by learning about @ContentChildren and AfterContentInit. That said, definitely read thoughtram’s article on how to ...

Read More »

The importance of a data format: Part II – The environment matters

When designing a new data format, it is important to remember in what environment we’ll operate in, what are the requirements and what type of scenarios we’ll face. With RavenDB, we are talking about the internal storage format, so it isn’t something that is available externally. That means that we don’t have to worry about interchange with anything, that frees ...

Read More »

Learning Angular 2 – Conditionally add styles to an element

Here we’re going through a couple of ways to conditionally apply some styles to a DOM element in Angular 2. Directly manipulating styles property A rather unconventional way would be to return the styling property as a string and then to directly set it on the desired element: //our root app component import {Component} from 'angular2/core' @Component({ selector: 'my-app', providers: ...

Read More »

Multi Content Projection aka Multiple Transclusion

How named/multi-slot transclusion works in Angular 2 If you’re an Angular developer, I’m sure you heard about transclusion. Sounds really weird and mysterious, at least that’s what I thought when I first heard it. If you google for it, you’ll probably land on one of Thoughtram’s articles (as you’ll do 90% of the time if you search for Angular articles ...

Read More »

Legacy Code to Testable Code # 12 : Instance Constructors

So we talked about static constructors and how to go around them. How about instance constructors? Are they innocent or guilty of the same crimes as their static brothers? I think Java got the terminology right (although not the implementation). What we call a “Constructor” is different than an Initializer. A “constructor” instantiates the object, and an “Initializer” initializes it. ...

Read More »

Find the bug – The case of the degrading system – Answer

In my previous post I showed the following code, and asked what the bug was, and what the implications of that would be. class Program { private Timer nextcheck; public event EventHandler ServerSigFailed; static void Main(string[] args) { var program = new Program(); if(program.ValidateServerSig() == false) return; program.DoOtherStuff(); } public bool ValidateServerSig() { nextcheck = new Timer(state => ValidateServerSig()); var ...

Read More »

Find the bug – The case of the degrading system

The following code contains a bug, can you spot it? class Program { private Timer nextcheck; public event EventHandler ServerSigFailed; static void Main(string[] args) { var program = new Program(); if(program.ValidateServerSig() == false) return; program.DoOtherStuff(); } public bool ValidateServerSig() { nextcheck = new Timer(state => ValidateServerSig()); var response = DoRequest("http://remote-srv/signature"); if(response.Failed) { var copy = ServerSigFailed; if(copy!=null) copy(this, EventArgs.Empty); return ...

Read More »

Code review challenge – The concurrent dictionary refactoring – answer

Here is the full method that we refactored: public void ReturnMemory(byte* pointer) { var memoryDataForPointer = GetMemoryDataForPointer(pointer); _freeSegments.AddOrUpdate(memoryDataForPointer.SizeInBytes, x => { var newQueue = new ConcurrentStack<AllocatedMemoryData>(); newQueue.Push(memoryDataForPointer); return newQueue; }, (x, queue) => { queue.Push(memoryDataForPointer); return queue; }); } And here is the allocation map for this method: public unsafe void ReturnMemory(byte* pointer) { <>c__DisplayClass9_0 CS$<>8__locals0 = new <>c__DisplayClass9_0(); CS$<>8__locals0.memoryDataForPointer ...

Read More »