How to use Angular 2 built-in directives – *ngIf and *ngFor


In this post we will briefly explain what are the structural directives and why they make our life easier…

Structural Directives

Basically these kind of directives actually change the HTML layout – they either add or remove a DOM elements.


As you can guess from the title, this directive will allow us to show or hide some div for example, depending on a certain condition.

So imagine that you want to display some text after someone clicks a button or even after exactly 3 clicking, like in the following example:



Firstly, we need to define our class, where we will have two properties: counter and requiredClicks and one function clicked()

The counter will increase every time the function is called.

The requiredClicks parameter will be used as a condition on whether to show some DOM element or not, but you will see more about it later on.

The function clicked() will do something when the button is clicked.

  selector: 'my-app',
  template : `
       <p>Please click the button {{ requiredClicks }} times </p>
       <button (click) = "clicked()">Test me</button>
export class App {
  counter: number = 0;
  requiredClicks: number = 3;
  clicked() {
    this.counter += 1;

The next thing is to define a DOM element in our template which will “look” if some condition is satisfied. In our case we will define div element with a directive NgIf which will only come true if we clicked 3 times on the button.

If counter > requiredClicks – 1 is true, than every child element of the current div will be displayed.

  selector: 'my-app',
  template : `
       <p>Please click the button {{ requiredClicks }} times</p>
       <button (click) = "clicked()">Test me</button>
       <div *ngIf = "counter > requiredClicks - 1">
          <div>The button was clicked {{ counter }} times</div>
export class App {
  counter: number  = 0;
  requiredClicks: number = 3;
  clicked() {
    this.counter += 1;

Looks really intuitive, right?

Let’s continue with another useful directive:


When I wondered what should be the mock data for my next example I saw few kids playing Pokemon Go so let’s use the names of the most famous pokemons 😛


  selector: 'my-app',
  template : `
<ul *ngFor="let pokemon of pokemons">
	<li>{{ pokemon }}</li>
export class App {
  pokemons: string[] = ["Charizard", "Pikachu", "Charmander", "Bulbasaur"];

As a normal for loop with the syntax “let pokemon of pokemons” we are saying that we will use the name “pokemon” for every element from the given array called “pokemons”, just like we are normally using index or i. Than we will display every element from our array in “li” tag.

  • Charizard
  • Pikachu
  • Charmander
  • Bulbasaur

Hope this content would be useful for you.



Creating custom pipes in Angular 2



In this post we will discuss:

  • What is Angular 2 pipe
  • How to use it
  • How to make custom pipes


In my last post we were discussing how to apply some styles to Angular 2 variable. Now we will take a look at how to format such variable in a different way.

You can think of pipes as some sort of filters or data formatters, which can apply styles to DOM elements, by binding to variables with Angular 2.

In Angular 2 we have pre-defined pipes, which allow us to make string uppercase or lowercase, to format data string and so much more.


As you can see in the code snippet, the only thing that we need to do, is to declare we want to use pipe with this symbol “|” and to specify which pipe from the core you want to use.

import { Component } from '@angular/core';
	selector: 'my-pipe',
	template: '<span> {{ myString | uppercase }} </span>',
export class PipeComponent{
	myString: string = 'test';

The key part here is  {{ myString | uppercase }} where you are saying something like “I want to apply the “uppercase” filter to myString”.

In the Angular 2 core, you can find others pre-defined pipes, such as LowerCasePipe, PercentPipe, ReplacePipe, SlicePipe, DatePipe and more (link to the docs).

It is worth it to pay special attention to the pipe DatePipe. If we set our variable myDate, as follows:

myDate: number =;

The output of {{ myDate }} would be 1468917543306, which is not very readable.

However if we apply the date pipe:

{{ myDate| date}}

The output would be:  ‎Jul‎ ‎19‎, ‎2016.

We can also apply additional formatting:

{{ myDate | date : yMMMMd}}

will display the full month – July instead of only Jul (December instead of Dec)

Custom Pipes

In this section we will create our personal pipe, which will apply filter to array of numbers.

So let’s create a file called pipes.component.ts

import { Component } from '@angular/core';
import { FilterArray } from './custom.pipe';

	selector: 'my-pipe',
	templateUrl: 'pipes.component.html',
	styleUrls: ['pipes.component.css'],
	pipes: [FilterArray]
export class PipeComponent{
 	value: number[] = [1,2,3,4,5,6,7,8,9,10];

We will need to import our custom pipe and in the @Component decorator we need to state that we will use it.

The file custom.pipe.js would look like this:

import { Component, Pipe, PipeTransform } from '@angular/core';

@Pipe({name: 'filterArray'})
export class FilterArray implements PipeTransform {
  transform(array: number[], parameter: number): number[] {
   const newArray: number[] = [];
   	parameter = 10; // set up our default parameter to be 10 if we don't specify it.
    for(let i = 0; i < array.length; i++){
if(array[i] > parameter){
   return newArray;

Here the new part is that we need to import the Pipe decorator and the PipeTransform interface from the core.

With @Pipe({name: ‘filterArray’}) we specify how our pipe will be named.

Our class FilterArray will implement a specific version of the transform function, so the following code:

{{ value | filterArray : 6}}

will display only the digits greater that 6.

So our initial array [1,2,3,4,5,6,7,8,9,10] will display as [7,8,9,10].


Feel free to comment or share and stay tuned for more Angular 2 posts.



Angular 2 CSS style bindings


In this post we will take a look on how to bind different styles to DOM elements in Angular 2.

You are all familiar with the following markup, right?

<div style="color:red;">Angular 2 is awesome</div>

Now, let’s put some Angular 2 sugar on it:

<div [ngStyle] = "{color: "red";}">Angular 2 is awesome</div>

Ok, it does absolutely the same thing as a simple html style. So why we should bother using it?

There is something called Angular 2 Directives, which helps us get some dynamic in our front-end. Now is the time to mention that there are 3 types of directives:

– Components
– Structural directives
– Attribute directives
In our example we used the attribute directives. Their purpose is to change the behavior of any DOM element. And that is exactly what we need.

Imagine if you don’t want your color always to be red, in some conditions you want it to be green. Here the directive comes in. We simply need to put a variable instead of particular color.

Angular 2 is awsome
So far, so good. But you may wonder from where this variable comes in.

If you are familiar with the basic structure of Angular 2 application, you should know that we should have a basic component, like the one below:

  selector: 'test-styles',
  templateUrl: 'app/app.component.html'
export class AppComponent {
  //you can either define myColor in the class
  public myColor: string = ‘red’;
  //or you can create a function to define it
  getColor() {
    return 'green';

And here is how app/app.component.html looks like:

<div style="color: red">Angular 2 is awesome</div>
<div [ngStyle] = "{color: "red"}">Angular 2 is awesome</div>
<div [ngStyle] = "{color: "myColor"}">Angular 2 is awesome</div>
<div [ngStyle] = "{color: "getColor()"}">Angular 2 is awesome</div>

In browser the final result would be:

Angular 2 is awesome
Angular 2 is awesome
Angular 2 is awesome
Angular 2 is awesome

Angular 2 is also allowing us to use directives directly with CCS styles, so the following statement is valid one:

<div [style.color] = "red">Angular 2 is awesome</div>

Have you seen how much time we just saved?

Angular 2 is indeed awesome!

Scope Management Plan



Speaking of Scope Management, it is essential to develop a plan, which can guide us in process of getting clear view of what we want to achieve and how we will achieve it.

In this article I will lead you through the steps, required for successful scope management plan.

In order to create such a plan it is good to have a template as a starting point. You can find a number of free templates on google or you can check this one: Scope Management Plan – Template

Plan the Plan

In the first part of developing scope management plan you need to “Plan the Plan”. I know this sound silly, but accordingly to the best practices you should have an overview on how the project scope will be defined, developed, and verified.

Another thing to consider is explaining the approach and project roles (sponsor, programmer, tester, designer, etc) :

  • Who is going to create the scope statement
  • Scope Management and Verification
  • Who is authorized to address changes to scope
  • Acceptance and approval of project deliverables

…and this is only the beginning.

Collect the Requirements

Key element in collecting the requirements is getting them to be SMART:


Methods on collecting requirements:

There are many ways of gathering the requirements, but we will take a look only on few:

  • Interviewing the stakeholders (it can be one-to-one or group interview)

You need to ask questions, until everything clears up.

  • Prototyping 

You can use quick sketches as prototype, in order to help your client to get a better idea of what she wants exactly.

  • Questionnaires

This is an electronic or paper based approach of collecting needs from stakeholders.

  • Focus Group

A focus group is a gathering of people who are representative of the users or customers of a product to get feedback.

The next step is to prioritize your requirements.

Remember, you can’t include everything that everyone wants… or at least on your first release.

Good technique is MoSCoW principle – you need to decide with your client which is ‘must have’, ‘should have’, ‘could have’ and ‘would have’.

Once you are finished, the document, which you should fill in is the Requirement Traceability Matrix: Requirements Traceability Matrix – Template

Project Scope Statement

You have to consider the following things:

  • Justification – why the project is undertaken
  • Acceptance Criteria – agreed rules on what is going to be considered as an successful deliverable
  • List of the deliverables
  • Constraints, assumptions and exclusions from the project


The process of subdividing the requirements into smaller pieces is called “Creating Work Breakdown Structure”


In the end, you should have a tree like the one below – with different levels of division.

This kind of view helps us to understand better the structure of our project and to deliver greater results. Of course creating a hierarchical list is also an option.You can find templates for both in the following files:

Work Breakdown Structure – Template


If you go on the path of creating WBS you will need also a WBS Dictionary where you need to give a little more details on the work packages: WBS Dictionary – Template

Scope Baseline

Typically the Scope Baseline consists the documents of approved Scope Statement, WBS and WBS dictionary.  

Control Scope

In this phase we you need to develop a process for the scope change requests.

But we will discuss this topic another time 🙂

Validate Scope

This is the process of getting a formal approval from customer about the project deliverables.

If the client is not satisfied with the final result of some deliverable, you can agree on a change request, which you can perform on the next release/phase.

Please note that you can make changes on the documents and the processes I have explained.

This article is only a recommendation that worked for me in the past. If you want you can take a look at the Scope Management Plan of the project, described in my last post.

Scope Management Plan – Estimation Tool













How to manage software project


Starting a project from scratch could be very overwhelming. Especially if you are beginner in the project management and  you are not sure from where to start or how to connect all the pieces.

Would it be nice to have a complete guide on how to manage a project with a real-life example? From the initial phases of creating a business case, collecting the requirements, to the executions and all the way to closing.

The experiment

Having all that said  I decided  to create a series of blog posts where I will introduce a Software Project and plan it step by step, including all the necessary parts and relevant tutorials for it.

For being more specific and closer to the real world I will plan and build an open source software project. Sounds interesting, huh?

cartoon-admitting-mistakes.jpgThe product

Some time ago I did a small research about the estimation practices in the project management.

While I was doing that I didn’t found any useful web application which provides tools for performing Monte Carlo Analysis and basic estimations like PERT or 3-points.

So I thought it would be awesome if we have a simple tool, which can provide this functionality – simple, easy and user friendly.

The best of both worlds

I will begin my experiment following the Watefall model – create the project charter, collect the requirements, create Work Breakdown Structure (WBS), define and estimate the activities.

Meanwhile, according to the plan, I will write some code and create the application myself 🙂

The main goal here is to apply all the theory I have learned from the PMBOK, practice my PM skills and create a valuable product at the end.

Feel free to share your thoughts about my experiment or give advises, using the following twitter hashtag #onlineestimations or comment here 🙂

So, let’s start!

In this article I will create a project charter and identify the stakeholders, as part of the initiating phase.

The Project Charter

Creating a project charter is one of the most essential parts of the project planning. At first it may looks unecessary, however it can help:

  •         the stakeholders to have an overview of the project’s main goals
  •         you clear your mind over the project
  •         finding the weak spots

Here you can find great tutorial on how to write your project charter (free template in included).

Back to our project: in the next few paragraphs I will fill out all the components, needed for creating a project charter.

Business Case Statement
Currently in the market it is hard to find a free system, which allows the project managers to create estimations of the tasks in their projects and compare different approaches.

The system we are aiming to create should give the end user different options for their time or costs estimations, using the most popular and useful techniques. It would also allow them to perform Monte Carlo analysis, which can predict many different possible outcomes, based on statistical formulas.

Problem Statements
1. Turn the complex statistical formulas in programming algorithm.
2. Create the system simple and user-friendly.
Goal Statement
1. To have a tool, which can use different estimation techniques and can show the difference in the end results.
2. To have a graphical representation of the results.
Project Scope
Deliverables: The system should have options for using a PERT and 3-Points estimations, should allow to perform a Monte Carlo analysis, should show a graphical representation of the results, should compare the different techniques and export the end results.

Assumptions: The system shouldn’t have a very complex architecture.

Constraints: One or two months for development and one resource.

Out of Scope: Only one type of Monte Carlo should be implemented.

High-Level Project Risks
One risk would be the transformation of the statistical Monte Carlo formulas to working algorithm.
Stakeholders & Affected Business Areas
The project will be open sourced, so every project manager could benefit from it.
Core Team Members
As this is experiment, only me 🙂 I can use some external consultants though, so every volunteer is more than welcomed.

Our next step will be to create a stakeholders list. In our case this is only an experiment and we don’t have any different sides involved, so we should kind of skip this part.

However as I try to design the system to be useful after all, I will treat myself as an end user.

If you want to see how the planning will go, use the hashtag #onlineestimations


How to read and create Pareto Charts


Pareto Principle

We have all heard something about the Pareto Principle. Actually it goes with different names, such as:

  • Pareto Low
  • 80-20 Rule
  • The Principle of Imbalance
  • All kind of modifications of these

It is very powerful tool, which can help us perform a root cause analysis and detect the most important issues in our project.

The most common phrase related to Pareto principle is:80-20




You can encounter the following as well:

  • 80% of the results come from 20% of the efforts
  • 80% of the sales come from 20% of the customers
  • 80% of the work is completed by 20% of the team
  • 80% of the customers uses only 20% of the features

In this article we will have an overview of the Pareto Diagrams, how to read them and how to create them.

First let’s take a look at the following scenario.

The problem

Our management is giving us a task to improve the user experience in the company’s website. So what should we do first?

One option is to collect feedback from the current users for what is bothering them.

The result of online survey, sent to 200 of our regular visitors, is a total of 162 responses.

What should we do next?

Create a list

Divide the responses to different categories (it is considered a good practice to have less than 10 different categories).

At the end we come up with the following list, which now should be analyzed.


That’s the moment when the Pareto Diagram comes to our mind.

Take a look at the graphic below, it looks complicated, but actually it is not at all.


As you can notice the blue bars represent the number of users complaining about similar issues. The interesting part here is the orange line which is also called cumulative line or Pareto curve.

This line gives us the cumulative weight of every bar.

So far, so good. But where exactly lies the Pareto principle here?

Imagine you can draw a line across from the 80% mark to the cumulative line and then down into the bars, as in the diagram above (the dotted red lines).

This means that 80 percent of our complains come from the first 2 issues – the site is too complicated to navigate and it is too slow.

This sounds awesome, right?  If we manage to eliminate the two problems we will get significantly higher feedback.

Create your own Pareto Chart

Now when you already bought the idea of using Pareto Diagrams, let’s learn how to create them.

Step 1

We need to get our initial statistics and sort them out from largest to smallest:


Step 2

We need to create another column for the cumulative values. For each cell in the Cumulative Count row as value we need to set the total number of complains from the rows above.

So for instance, in the cell C2 we put the same value as the one in B2, as this is the first row we count.


Step 3

After that in every cell we put the sum of the users’ complains (the current row included).


As you can see in the last 7th row we have the same value as the total number of complains. This means that our calculations are correct, so we can proceed with getting the cumulative percentage.

Step 4

The next thing is to create a Cumulative Count % Column which can count the percent of every row from the totals. You can do this by dividing the cumulative value by the total and multiply by 100:


After we do that for the whole table it is time to create the graphic.

Step 5

First you need to select Column A, B and D at the same time without selecting the Total row.

Then click on Insert tab of the Excel and select a graphic.


Right after you do this, you will receive the following diagram, which of course needs to be modified a bit.

Step 6

You have to select the orange bars and click right button of the mouse, then select Change series char type.


You will get the following screen from where you need to pick the Combo type and select the second chart.


That was the last step before our creation is done.

I hope the article was useful to you.


Project estimations with Monte Carlo Analysis


The estimation process in project management is quite an important activity because many decisions depend on its precise completion. It is quite challenging considering all the different factors impacting the project’s execution. That is why there are various techniques which can help us create our estimations.

In this article we will have a brief look at the most common practices according to PMI and we will pay special attention to those of them based on mathematical approach.

Estimation Techniques

  • Analogous estimating – we compare our current project with past similar ones. This technique is also known as “top-down”. We should be careful with it because sometimes it’s not very accurate.


  • Parametric estimating – we estimate the unit cost/duration per activity and then the number of units required for completing it, e.g. $10/hour or 3 days/module. The measurement, however must be scalable, otherwise we risk to lose accuracy.
  • Bottom-up estimating –  we have concrete information about the atomic activities, so we can estimate them in lowest level, then easily combine them in order to get estimation for the composed activities and thus for the entire project. This approach might be very time consuming, so it needs special attention when it comes to lager projects.
  • Three-point estimation – this technique considers the risk and uncertainty by taking in mind estimations for the optimistic, pessimistic and most-likely outcomes:


We can use it by identifying values for optimistic (best-case scenario), pessimistic (worst-case) and most-likely values of the current task. After that we can calculate the formula for receiving more accurate result for the Mean – the technical definition of “average” value.


  • Three-point estimation – PERT – variation of 3-point estimation where we have again the values for Optimistic, Pessimistic and Most-likely estimation. The difference lies in the formula where we calculate the most-likely value with different weight.


Based on the Beta distribution, this statistically proven formula will give us more realistic result of the Mean.

We can also calculate the standard deviation – “σ”, which measures the amount of variation from the mean. This can be quite useful when we measure the risk of the uncertainty, but this is a topic for another article 🙂


The last two techniques are really common in the project management world, but unfortunately they give us only rough estimations. There are times when we need a justification of the decision we have made and this simple formula would not be enough.

This is where the Monte Carlo Analysis comes in.

Monte Carlo Simulation

Technique, used in project management where we can calculate random project estimations within a given range, as many times as we want. This simulation is based on probability distribution and produces many different outcome values.

Now, let’s see how this estimation works…


We were given the following data for completing a simple task in days. You can think of something like creating a super simple mobile application upgrade.


We will calculate the Mean with the techniques above and will monitor the differences

Three-Point Estimation omp1

Using this formula the result for our Mean is  = 7.667


PERT Estimation

omp3  Using this formula the result for our Mean is  = 7.833

Did you notice the difference between the two values?  Now let’s take a look at another technique for estimation…

Monte Carlo Simulation

First we will try simple simulation of random values from 5 to 10 and apply it 500 times.

The result here for the Mean is 7.547.

You can notice that in this scenario we don’t use the most-likely value, that’s why the mean is a bit lower. However if you try it with very large numbers the difference won’t be that significant.

Note: For those of you who are interested in testing this in Excel, the formula for random number between a range is RAND()*(P-O)+O this is necessary because the rand function returns a random number between 0 and 1 and this way we can use it for whatever range we want.

Monte Carlo Simulation v2

In the next test we will use the Monte Carlo Analysis with the Triangular distribution – it will use optimistic, pessimistic and most-likely values:


From this graphic we can notice that the values which are occurring most frequently are between 7.5 and 8.5.

The average of all the 500 random values is 7.733 a lot closer to our most-likely value. Therefore our Mean is 7.733.


As we tried different estimation techniques we found out that the result are approximately the same with slight difference, see below.


However every project is unique and it is our responsibility to find the right method and use it, but remember these estimations will never give us 100% probability.