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)

Angular 2

Angular – a framework for dynamic web application. It was released in 2011 and it is maintained by Google and open-source community. It helps you organize the HTML, CSS and Javascript code.

Angular 2 is faster that Angular 1.

Angular 2 uses components instead of controlers and scope in Angular 1.

Data binding is more intuitive.

Creating custom directives is more simpler.

Services are now a class.

Other small improvements.

You can use Javascript with Angular 2 but not all browsers support the newest version of Javascript.

Workaround – transpile – write code the code in latest version of Javascript and transpile it into Javascript compatible with all browsers.

  • Babel
  • Typescript – superset of Javascript (including the ES2015 features) developed by Microsoft. It adds type checking and object oriented features.

Front-end basics #1 HTML

Microsoft bot

Microsoft bot strategy

Bots are conversational agents are they are meant to help users to complete a particular task. There are not new and they are not specific to Microsoft. The user doesn’t need to have an application or to go to a specific Web site and he can provide information directly to the bots.

 

Why Microsoft just made a big bet on bots

Satya Nadella thinks that bots are a simple concept with a profound impact. Microsoft hopes that boots become the next major computing platform even if for now the consumer interest is not overwhelming. Bots are cataloged as the website builder of the future. Some startups are already creating bots, Google tried to buy Chatfuel and Facebook is expected to open Facebook Messenger to third-party bots. Microsoft will make easier for developers to write bots  in Windows and run them on the Azure.

https://dev.botframework.com/

To get started you will need a Microsoft account.

Microsoft Bot Framework contains Bot Connector,  Bot Builder SDK and Bot Directory.

Bot Connector allows you to register, connect and publish the bots to services like text/sms, Office 365 mail, Skype, Slack and others.

Bot Builder SDK will provide anything you need to build great dialogs within your bot. For C# you can get started from docs.botframework.com/sdkreference/csharp/.

The Bot Directory is a public directory of all approved bots registered through the Bot Connector.

 

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.