Showing posts from May, 2017

How does NgModule work in Angular

How does NgModule work in AngularThe first time I saw the NgModule decorator and its arguments I was completely lost.
I couldn’t understand what was the meaning of imports, declarations, exports, providers or bootstrap and I had a hard time finding clear explanations.
So today I will go through each attributes and provide an explanation together with an example to understand what is the role of each NgModule argument.1. How does a NgModule declaration look like? 2. Imports 3. Exports 4. Declarations 5. Providers The full source code is available on my GitHub How does a NgModule declaration look like?Angular utilises the typescript decorators to define NgModule.
It accepts imports, declarations, exports and providers.A typical declaration would look like that:import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { SquareComponent } from './square.component'; import { SquareServ…

Saving data with Entity Framework Core with SQLite

Saving data with Entity Framework Core with SQLiteEntity Framework is a framework abstracting away all the complexity of dealing with storage. This abstraction is also known as ORM ~ object-relational mapping.
There is a number of provider which are implementation of the storage like SQL server or MySql or also SQLite, the one we will be seeing in this post.
SQLite is a embedded database. The whole database is contained within a single .db file which makes it highly portable, so portable that it is the default database installed in mobile OS like iOS and Android. It is extremely easy to use and to maintain. It also offer a powerful implementation of SQL. Today we will see how we can make use of Entity Framework with SQLite provider in a ASP.NET Core application. 1. Install EF and create a new DbContext 2. Create migrations 3. Use in ASP NET Core 1. Install EF and create a new DbContextStart by installing the packages:Install-Package Microsoft.EntityFrameworkCore.SQLite Once we have …

Razor syntax and helpers

Razor syntax and helpersRazor is a HTML templating engine which allows us to construct HTML pages from a combination of data and HTML markup. The power of Razor resides in its typesafety and support for well known operators, conditional ifelse and iterators forwhileforeach. It allows us to directly use our C# models in the templates and call functions accessible by the view. Together with intellisense, it is quick way to build UI.
Today we will explore some of the features from Razor: 1. Syntax 2. Layout and partial views 3. View components 4. Tag helpers 1. SyntaxRazor expressions can written in two ways, implicit or explicit notation.For implicit notation, we start with @ and then we directly have access to values either from the view itself or some we created in the view or static functions.@{ var a = 10; } <label>@a</label> One useful property of the view is the Model.
It gives access to the model linked to the page. By going @Model.XXX, we can access the prop…

Attribute route in ASP NET Core

Attribute route in ASP NET CoreAttribute route in ASP NET Core is an easy way to define URL routes for Web API projects. There can be instance where it gets confusing because of all the options provided. Today we will see the meaning of the different options and how they affect the constructed route. This post will be composed by 3 parts:1. Route attribute 2. Route values and token replacement 3. "/" or "" 1. Route attributeThere are two ways to define routing, convention and attribute. When both are set, attribute route takes priority over convention route. In this post we will only discuss attribute route.Attribute route is specified using the [Route(...)] attribute. The route attribute can be set on controllers and actions. Setting the attribute on a controller will prefix all action route by the controller route.So for example specifying the following:Route("values") public class ValuesController: Controler { Route("list") public IA…

Opinions and decisions, how to be a successful team mate

Opinions and decisions, how to be a successful team mateI have been working for more than 8 years in the software industry and have dealt with loads of developers from junior to senior.There are multiple points which can make a successful team mate. One of them is knowing when to express opinions and when to take decisions. One thing I have learnt is that decisions, forcefully agreed on, will most likely not be respected by the team. I also learnt that decisions come from opinions and the way we express opinions will dictate the level of respect team mates attributes to you and the level of trust they place in you. Just like in sport, respect and trust are the most important values to have.
Today I would like to explore the different scenarios where we, as developer, should express our opinions and also when should we, as developer, take decisions.1. OpinionsThose are rules that I have followed and which have lend me into building lasting relationships with team mates.There are two ru…