Things any programmer should know #1

  1. Create shared library only when you know the context. Sometimes, while decreasing the number of line of code in the system the number of dependencies is increased.
  2. Care for the team’s code. Make it a little bit better than when you checked it out.
  3. Debug your own code before rushing to blame others.
  4. Choose the right mix of tools:
    1. avoid architectural mistmatch (some tools are good only in some specific contexts)
    2. avoid using too many
    3. should be easy to configure
    4. licensing terms matter
    5. start by using only the tools that are absolutely necessary

ASP.NET Core Authorization

Authentication – when you ask someone who they are and you get its identity.

Authorization – decide what identity is able to do.

You can authenticate but you don’t have to authorize.

You can authorize without having any authentication.

Two main HTTP codes in web security:

401 – Unauthorized – You are not authenticated

403 – Forbidden – You are authenticated but you don’t have access

ASP.NET Authorization workshop

 

 

What is legacy code?

Legacy code can have multiple definitions:

  • code we have gotten from someone else
  • a slang-term for difficult-to-change code that we don’t understand
  • code without tests. Without tests we can’t be sure if our code base is getting worse or better. With tests we can change the behaviour of our code quickly and verifiably.

Working Effectively with Legacy Code (Robert C. Martin Series)

Notes #4 – Git vs SVN, git-flow

A comparison between Git and SVN. Git’s major features:

  • Git was designed to be fully distributed from the start, allowing each developer to have full local control
  • Git branches are simpler and less resource heavy than Subversion’s
  • Git branches carry their entire history
  • Branch merging is simpler and more automatic in Git.
  • Git is extremely fast. Since all operations (except for push and fetch) are local there is no network latency involved

git-flow – a successful git branching model

The main branches:

  • master – the main branch where the source code always reflects a production-ready state.
  • develop – the main branch where the source code always reflects the latest delivered development changes. The « integration branch » where any automatic nightly builds are build from.

Other branches, with a limited life time,  with a specific purpose, to aid parallel development:

  • feature  – it branches off from develop and it must merged back into develop. It exists as long as the feature is in development
  • release – it branches off from develop  and it must merged back int develop and master. Branch name convention: release-*. Use it for minor bug fixes and preparing meta-data for a release
  • hotfix – it branches off from master and must be merged back into develop and master. Branch naming convention: hotfix -*. Use it when you need to act immediately upon an undesired state of a live production version, when a critical bug in a production version must be resolved immediately.

Automate git branching workflow – use  git-flow library of git subcommands that helps automate some parts of the flow to make working with it a lot easier.

Issues with git-flow – The git-flow process is designed largely around the « release » but when you need to deploy regularly (every day), like GitHub does, a much simpler workflow is required.

 

Read and Write from the Interactive Shell

To write a value to the shell you can use the Write-Host command. It also allows you customize the console output.

$name = "Marius"
Write-Host -ForegroundColor White -BackgroundColor Black $name

To read a value from the interactive shell you can use Read-Host. This command will read a line of input from the console.

Write-Host "Please enter your age"
$age = Read-Host

Common cmdlets in Powershell

Here are some common used cmdlets in Powershell:

get-help

get-help process

– retrieves a list of commands available on a specific topic. For example, process

get-process

get-process

– returns information on processes

get-service

get-service

– returns information on the services that are installed on the computer

get-item

get-item C:\

– Gets the item at the specified location

get-content

get-content C:\file.txt

– returns the contents of the specified item

PowerShell – A really short introduction

PowerShell, seen as an evolution of the former Windows command-line shell, offers a new way the shell interprets the commands (not as plain text but allowing more interaction).  This scripting language interprets objects with methods and attributes that have have access to much of .NET Framework. For example, for retrieving the length of a string, we can call the property Length of an object of type System.String.

PowerShell also allows you to work with COM, WMI, XML and Active Directory.

A cmdlet is a lightweight command that is used in the Windows PowerShell environment

To run the simplest commands we only need the interactive shell from Windows. Type Powershell.exe. It is compatible with DOS commands and UNIX commands.

However, there are several tools that provide syntax highlighting, debugging, like PowerShell ISE or PowerGUI.

 

.NET is now cross-platform

Microsoft is building a new version of .NET, called .NET Core, which is open-source and which will allow us to write cross-platform code (Windows, multiple distributions of Linux and OS X). The goal is to run .NET Core in as many places as possible. In fact, the code is portable and it can be run on different supported platforms: .NET Framework, Mono, Xamarin,  Windows 8, Windows Phone, Universal Windows Platform (UWP). There is a list of multiple implementations based on .NET Standards and it can be found on github.

The design and the architecture of .NET core are modular and its component are all separate entities. This way the developers can choose the libraries and the dependencies that are needed.

We can write code for .NET Core on:

  • cross-platform ASP.NET Web apps using ASP.NET Core 1.0. Until February it was called ASP.NET 5
  • cross-platform console apps
  • cross-platform libraries and frameworks
  • UWP apps (apps that target the family of Windows 10 devices)

.NET has now 2 flavors: NET Core and .NET Framework

First of all, .NET Core is not a subset of .NET Framework. It is a different stack. We will still be able to use the same languages: C#, F#, Visual Basic but we should see .NET Core and .NET Framework as two different stacks that coincide and co-evolve. .NET Core was created so that .NET could be open source and cross-platform.

A big difference between .NET Framework and .NET Core is the way how they are serviced and where they live. As we know, .NET Framework is a Windows component serviced through OS updated while .NET Core is composed of Nuget packages and it can be serviced per-application and through a package manager.

The .NET Framework will continue to be the stack to use when writing application ranging from console applications, rich client (WPF) applications to scalabe web applications.

Notes #3 – Career, developers, git

5 Essential Pieces of Career Advice No One Ever Told You

In my opinion the most important of all: Your boss matters more than your company. Having the right mentor is the real key. The second important advice is don’t use data to pick a job, just do what you enjoy doing and be great at it. Also, the technical skills will only get you so far. You will have to learn how to navigate the world of office politics.

What distracts developers

The survey surprised me: « unplanned worked », 24.9% of the votes and « only » 22.7% of votes, social media. Chatty coworkers, meetings, forums and reading/writing emails are other reasons.

Git Commands and Best Practices Cheat Sheet – Print this git cheat sheet!