London launches world’s first contactless payment scheme for street performers

Charlotte_Campbell_London

Here’s a casualty of the cashless society you might not have previously thought of: the humble street performer. After all, if more of us are paying our way with smartphones and contactless cards, how can we give spare change to musicians on the subway? London has one solution: a new scheme that outfits performers with contactless payment terminals.

The project was launched this weekend by the city’s mayor, Sadiq Khan, and is a collaboration with Busk In London (a professional body for buskers) and the Swedish payments firm iZettle (which was bought this month by PayPal for $2.2 billion). A select few performers have been testing iZettle’s contactless readers on the streets for the past few weeks, and Khan now says the scheme will be rolled out across London’s 32 boroughs.

Charlotte Campbell, a full-time street performer who was part of the trial, told BBC News that the new tech “had a significant impact on contributions.” Said Campbell: “More people than ever tap-to-donate whilst I sing, and often, when one person does, another follows.”

The readers need to be connected to a smartphone or tablet, and accept payments of fixed amounts (set by the individual performer). They work with contactless cards, phones, and even smartwatches. There’s no detail yet on how many readers will be provided to London’s street performers, or whether they will have to pay for the readers themselves.

Although individuals do sometimes set up their own contactless payment systems (and in China, it’s not uncommon to see street performers and beggars use QR codes to solicit mobile tips), this seems to be the first scheme of its kind spearheaded by a city authority.

Microsoft Buys Conversational AI Company Semantic Machines

SemanticMachines

In a blog post, Microsoft Corporate Vice President and Chief Technology Officer of AI & Research David Ku announced the acquisition of Berkeley, California-based conversational AI company Semantic Machines. The natural language processing technology developed by Semantic Machines will be integrated into Microsoft’s products like Cortana and the Azure Bot Service.

On its website, Semantic Machines says that existing natural language systems such as Apple Siri, Microsoft Cortana and Google Now only understands commands, but not conversations. However, Semantic Machines' technology understands conversations rather than just commands. Some of the most typical commands that digital assistants can handle today include weather reports, music controls, setting up timers and creating reminders. “For rich and effective communication, intelligent assistants need to be able to have a natural dialogue instead of just responding to commands,” said Ku.

Microsoft turns SharePoint into the simplest VR creation tool yet

SharePoint_spaces

Microsoft is sticking with its pragmatic approach to VR with SharePoint spaces, a new addition to its collaboration platform that lets you quickly build and view Mixed Reality experiences. It's a lot like how PowerPoint made it easy for anyone to create business presentations. Sharepoint spaces features templates for things like a gallery of 3D models or 360-degree videos, all of which are viewable in Mixed Reality headsets (or any browser that supports WebVR). While they're certainly not complex virtual environments, they're still immersive enough to be used for employee training, or as a quick virtual catalog for your customers.

"Until now, it has been prohibitively complex and costly to develop customized MR apps to address these and other business scenarios," wrote Jeff Teper, Microsoft's corporate VP for OneDrive, SharePoint and Office, in a blog post today. "SharePoint spaces empower creators to build immersive experiences with point-and-click simplicity."

Given, When, Then

Given-When-Then is a style of representing tests specifying a system's behavior. It's an approach developed by Dan North and Chris Matts as part of Behavior-Driven Development (BDD). It appears as a structuring approach for many testing frameworks such as Cucumber. You can also look at it as a reformulation of the Four-Phase Test pattern.

The essential idea is to break down writing a scenario (or test) into three sections:

  • The given part describes the state of the world before you begin the behavior you're specifying in this scenario. You can think of it as the pre-conditions to the test.
  • The when section is that behavior that you're specifying.
  • Finally the then section describes the changes you expect due to the specified behavior.

Since we're talking about using examples as specifications, it makes sense to show this with an example

Feature: User trades stocks
  Scenario: User requests a sell before close of trading
    Given I have 100 shares of MSFT stock
       And I have 150 shares of APPL stock
       And the time is before close of trading

    When I ask to sell 20 shares of MSFT stock
     
     Then I should have 80 shares of MSFT stock
      And I should have 150 shares of APPL stock
      And a sell order for 20 shares of MSFT stock should have been executed
  

The above example uses Cucumber, which a popular way of writing BusinessFacingTests but you can use the Given-When-Then style with any kind of tests. Some people like to put Given-When-Then as comments to mark informal blocks inside unit tests. I've also seen this convention to structure informal prose.

It's usual with this approach to see "ands" used to combine multiple expressions within each clause.

I've characterized the given as a description of the pre-condition state because that's the way I prefer to think of it. A testing framework, however, interprets the givens as a set of commands to bring the system-under-test into the correct state before executing the when command. Testing frameworks provide various query methods for the then commands - these should be free of side-effects.

Although Given-When-Then style is symptomatic to BDD, the basic idea is pretty common when writing tests or specification by example. Meszaros describes the pattern as Four-Phase Test. His four phases are Setup (Given), Exercise (When), Verify (Then) and Teardown. Bill Wake came up with the formulation as Arrange, Act, Assert.

7 Popular Unit Test Naming Conventions

Following are 7 popular unit tests naming conventions that are found to be used by majority of developers and compiled from above pages:

  1. MethodName_StateUnderTest_ExpectedBehavior: There are arguments against this strategy that if method names change as part of code refactoring than test name like this should also change or it becomes difficult to comprehend at a later stage. Following are some of the example:
    • isAdult_AgeLessThan18_False
    • withdrawMoney_InvalidAccount_ExceptionThrown
    • admitStudent_MissingMandatoryFields_FailToAdmit
  2. MethodName_ExpectedBehavior_StateUnderTest: Slightly tweeked from above, but a section of developers also recommend using this naming technique. This technique also has disadvantage that if method names get changed, it becomes difficult to comprehend at a later stage. Following is how tests in first example would read like if named using this technique:
    • isAdult_False_AgeLessThan18
    • withdrawMoney_ThrowsException_IfAccountIsInvalid
    • admitStudent_FailToAdmit_IfMandatoryFieldsAreMissing
  3. test[Feature being tested]: This one makes it easy to read the test as the feature to be tested is written as part of test name. Although, there are arguments that the “test” prefix is redundant. However, some sections of developer love to use this technique. Following is how the above tests would read like if named using this technique:
    • testIsNotAnAdultIfAgeLessThan18
    • testFailToWithdrawMoneyIfAccountIsInvalid
    • testStudentIsNotAdmittedIfMandatoryFieldsAreMissing
  4. Feature to be tested: Many suggests that it is better to simply write the feature to be tested because one is anyway using annotations to identify method as test methods. It is also recommended for the reason that it makes unit tests as alternate form of documentation and avoid code smells. Following is how tests in first example would read like if named using this technique:
    • IsNotAnAdultIfAgeLessThan18
    • FailToWithdrawMoneyIfAccountIsInvalid
    • StudentIsNotAdmittedIfMandatoryFieldsAreMissing
  5. Should_ExpectedBehavior_When_StateUnderTest: This technique is also used by many as it makes it easy to read the tests. Following is how tests in first example would read like if named using this technique:
    • Should_ThrowException_When_AgeLessThan18
    • Should_FailToWithdrawMoney_ForInvalidAccount
    • Should_FailToAdmit_IfMandatoryFieldsAreMissing
  6. When_StateUnderTest_Expect_ExpectedBehavior: Following is how tests in first example would read like if named using this technique:
    • When_AgeLessThan18_Expect_isAdultAsFalse
    • When_InvalidAccount_Expect_WithdrawMoneyToFail
    • When_MandatoryFieldsAreMissing_Expect_StudentAdmissionToFail
  7. Given_Preconditions_When_StateUnderTest_Then_ExpectedBehavior: This approach is based on naming convention developed as part of Behavior-Driven Development (BDD). The idea is to break down the tests into three part such that one could come up with preconditions, state under test and expected behavior to be written in above format. Following is how tests in first example would read like if named using this technique:
    • Given_UserIsAuthenticated_When_InvalidAccountNumberIsUsedToWithdrawMoney_Then_TransactionsWillFail

Google AI can make calls for you

During the on-stage demonstration, Google played calls to a number of businesses including a hair salon and a Chinese restaurant. At no point did either of the people on the other end of the line appear to suspect that the entity they were interacting with was a bot. And how could they when the Assistant would even throw in random "ums", "ahhs" and other verbal fillers people use when they're in the middle of a thought? According to the company, it's already generated hundreds of similar interactions over the course of the technology's development.

MongoDb example

Simple example for MongoDB. Save and retrieve data from Azure Cosmos DB.

Create an Azure Cosmos Db as MongoDb

For creating a new MongoDb on Azure, search from the list of resources, Azure Cosmos Db. Then Add a new database and you see the following screen.

Add new CosmosDB

Overview

When you created a new MongoDb, you see an Overview where there are general information about how many queries the database did (split on insert, update, cancel, query, count, others).

Azure Overview

Under Connection String you have the connection to use in your application. In this project you insert in Program.cs the connection string in the variable called connectionString.

DataExplorer

You can explorer all data in your Mongo database. Click on Data Explorer and you can see everything. Also, you can execute same queries.

Azure CosmosDb Data Explorer

You find an example application on my GitHub.

Never give up!

amazon-bezof-never-give-up

Surface phone: is it the real time?

Surface-phone

Surface Phone Rumors: Microsoft to Finally Unveil Mythical Device at the MWC 2018.

While some people are resigned to the fact that the long-rumored Surface Phone is nothing more than a figment of the imagination, new reports claim that the long-rumored mythical Microsoft device may finally be unveiled at next month's MWC (Mobile World Congress).

Rumors about the Surface Phone have been in existence for two years now, but no one outside Microsoft cannot really confirm if the device is in the pipeline. However, according to recent reports, the wait may be soon over as it is alleged that the Redmond-based company will reveal the Surface Phone at the annual MWC happening at Barcelona next month.

Surface-phone-2

Surface-phone-1

First AngularJs example

If you are looking around for a new job as .NET developer, all companies are asking you AngularJs. Then I’m starting to learn it and I share with you the secret of this framework.

I’m assuming you are a .NET developer like me and you want to learn AngularJs and then I won’t explain you the basis of HTML.

Open Visual Studio and create a new solution with ASP.NET Empty web Site.

AnguarJS1-CreateEmptySolution-VisualStudio2017

Now you have your project.

AnguarJS1-EmptySolution-VisualStudio2017

Add from NuGet AngularJS.Core.

AnguarJS1-AddAngularJs-from-NuGet-VisualStudio2017

Done. We start now with a little complicate example. Two examples.

StartHere.html

<!DOCTYPE html>
<html ng-app="myApp">
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="Scripts/angular.min.js"></script>
</head>
<body ng-controller="ExampleController">
    <h1>Game setup</h1>
    <div ng-repeat="player in players" 
        ng-init="playerIndex = $index">
        <ng-include src="'player.html'"></ng-include>
    </div>
    <script>
        (function () {
            "use strict";
            var myAppModule = angular.module('myApp', []);

            myAppModule.factory('playerService', function () {
                var playerCount = 0;
                var createDefaultPlayer = function () {
                    playerCount += 1;
                    var player = {
                        name: "",
                        prevName: ""
                    };

                    player.onNameFocused = function () {
                        player.prevName = player.name;
                    };
                    return player;
                }

                return {
                    createPlayer: function (name) {
                        var player = createDefaultPlayer();
                        player.name = name;
                        return player;
                    },
                    getPlayerCount: function () {
                        return playerCount;
                    }
                };
            });

            myAppModule.controller('ExampleController', ['$scope', 'playerService',

                function ($scope, playerService) {

                    $scope.players = [playerService.createPlayer('Player1'),
                        playerService.createPlayer('Player2'),
                        playerService.createPlayer('Player3')];

                }

            ]);
        }());
    </script>
</body>
</html>

player.html

<h2>Player {{$playerIndex + 1}}</h2>
<label>Name:</label>
<input type="text" placeholder="Enter Player {{$playerIndex + 1}}" 
    ng-model="player.name" ng-focus="player.onNameFocused()" />
<h3 ng-show="player.name">
    Player {{$playerIndex + 1}} name is {{player.name}}
</h3>
<h3 ng-show="player.prevName">
    Prev Player {{$playerplayerIndex + 1}} name was 
    {{player.prevName}}
</h3>

Explanation

JavaScript frameworks such as Backbone.js, knockout.js, AngularJs and others addressed the problems of scalability, reusability, and testability by embracing a design pattern traditionally used by server-side frameworks.

This pattern is called Model-View-Controller (MVC), and it is an established pattern that was originally introduced in the 1970s. You should already be familiar with it from the ASP.NET MVC fundamentals, but I will revisit it here for reference.

Technically, AngularJS uses a variant of the MVC, which is closer to the Model-View-ViewModel (MVVM) pattern, but the definition of MVC from the next section still applies to it. One of the core members of the AngularJS team declared the main design pattern behind AngularJS as being "Model-View-Whatever works for you" (MVW or MV*) in this post at http://plus.google.com/+AngularJS/posts/aZNVhj355G2.

The design pattern is specific for applications with user interfaces and introduces a separation between the following aspects:

  • Model: This is the application data and the business logic associated with it

  • View: This is the output of the application data in any form that can be consumed or manipulated by a user

  • Controller: This is the logic to get data from the View to the Model and back, and to manage any interaction with the View or the Model

The first highlighted attribute is ng-app, which has a value this time around. The myApp value represents the unique identifier of the current AngularJS application. The next highlighted code initializes a new AngularJS component called module, which will be used via the myApp identifier to bootstrap the AngularJS application.

A module is a container-like object with a unique identifier that groups together the AngularJS components used to build an application: controllers, directives, and others, such as providers, factories, services, values, constants, animations, and filters. The module has methods that are specific to the AngularJS application components I mentioned.

The module controller function takes the controller name and controller constructor function as arguments.

The first highlighted snippet is the service definition that looks similar to a controller definition, with the exception that it returns an object that represents the service factory. This object is used to create the service instance that will be injected in all of the AngularJS components that have this service declared as a dependency.

In the new service, we transformed the previous controller code into a function called createDefaultPlayer(), which will create a new object that represents a player. The service instance has a method to create a new player with a predefined name called createPlayer(name). The service factory function will keep track of how many player objects were created using the playerCount variable. The variable will be returned by the service instance function, getPlayerCount(). On a side note, you can see the revealing module pattern in action here. Although the script section is now bigger, we obtained new features such as code reusability and flexibility to provide more complex functionality than before.

There are other methods available on the module interface to declare an AngularJS service, such as service, value, and constant. The service method will use a constructor function to create the service instance, while the value method will use an already created service instance that will be passed unchanged to the AngularJS injector. The constant method is similar with the value method, with the difference that it will be available during the configuration phase of the application module. The factory method is one of the most flexible methods, and it will be the most frequently used method in the rest of the examples from this book. It allows additional configuration to the returned service instance, and you can even keep track of data outside of the service instance, such as with the playerCount variable from the previous example.

We have used a lot of directives in the examples presented so far, and most of them used the ng- prefix. When you take a look at the directives' documentation pages at http://code.angularjs.org/1.2.15/docs/api, you will notice that the directive names appear slightly different—ng-app is ngApp and ng-controller is ngController. AngularJS removes any data- or x- prefixes from the HTML markup and converts the -, _, and : characters to a camel case directive name. From now on, we will refer to different directives using the names from the AngularJS documentation.

We will explore some important built-in directives and see how to build custom directives. Looking back at the previous example, the HTML markup seems to have been duplicated for the two players. There is a built-in directive called ngRepeat that allows us to remove the duplicated markup as highlighted in the next example.

The ngRepeat directive works with a collection of objects and repeats an HTML markup section for each item in the collection. We created an array of player items in the controller that is used in the ngRepeat directive. The first highlighted code section shows the expression used to iterate through the collection, and the div element that has the directive is repeated for each item in the collection. The player variable defined in the ngRepeat expression is only available inside of the directive. The ngRepeat directive has its own scope that contains other directive-specific variables such as $index, which has been used in the next highlighted code snippet. This variable of the type number keeps track of the current collection item index, and there are other directive-specific Boolean variables available: $first, $middle, $last, $odd, and $even.

The example works for HTML markup that repeats a single element. When the HTML markup that needs repeated elements has separate start and end elements, you need to use two different directive attributes. The first is ng-repeat-start, which is a renamed ng-repeat directive that needs to be used on the start HTML element. The second is ng-repeat-end, which does not have an expression value and is used on the HTML element that ends the markup that needs repeated elements. The previous example of the body element content can now be written using the h2 element as the start of the repeated markup and the h3 element as the end, as shown in the following code:

  <h1>Game setup</h1>
  <div>
    <h2 ng-repeat-start="player in players">
        Player {{$index + 1}}
    </h2>
    <label>Name:
    <input type="text" placeholder="Please enter player {{$index + 1}} name" 
        ng-model="player.name" ng-focus="player.onNameFocused()">
    <h3 ng-show="player.name">Player {{$index + 1}} name is {{player.name}}.</h3>
    <h3 ng-repeat-end ng-show="player.previousName">
        Previous Player {{$index + 1}} name was 
        {{player.previousName}}.
    </h3>
  </div>

The ngRepeat directive example is very useful when we need to manipulate the HTML for a specific application view. However, I can easily imagine scenarios where the HTML for a player has to be reused between different views. If there is a single player game, we want to see only one player editing form rather than two. AngularJS offers a simple but powerful solution through the ngInclude directive. This directive allows the referencing of a separate file that will be loaded and rendered in the current HTML view by AngularJS.

To introduce this directive, I had to change the HTML for the ngRepeat example and add a new file that contains the player HTML markup.

The first highlighted attribute is a new directive, ngInit, that evaluates an arbitrary expression. Although this directive can be used anywhere, it is best practice to only use it in the context of the ngRepeat directive. We use it to create a new scope property that is an alias of the $index variable from the ngRepeat directive. The reason behind this alias is to allow the reuse of the player markup in contexts where there is no enclosing ngRepeat directive.

The next highlighted element is the ngInclude directive, which fetches the referenced player.html file, renders it, and creates a new scope for it. The scope inherits the current ngRepeat iteration scope and its player and playerIndex properties. The last highlighted expression shows how the property created by ngInit is used in player markup.

Advertsing

125X125_06

Planet Xamarin

Planet Xamarin

TagCloud

MonthList