Nintendo World New York and A Quick Update

I recently had the privilege of a two-week holiday in New York City. During this time I visited Nintendo World (located in the Rockefeller Center) and it was a great experience. There were a lot of amazing displays, showing examples of every Nintendo console ever made and even a Gameboy that was damaged in a bombing during the Gulf war that was still functioning. Here are some photos:

If you are ever in New York, I would recommend going to have a look.

Here are some other photos from the trip:

While there I also picked up a few things that I will be covering on the blog over the next few months:

Nintendo World New York and A Quick Update

Bite Size C# – Eventing\Observer Pattern

Let us have a look at the eventing or observer pattern. This pattern is based on the raising and handling of events. Events are a mechanism for the communication between object that allow us to build loosely coupled applications that can be easily extended.

At a high level this pattern functions as follows:
An object (known as the Publisher) defines a contract (delegate method) to which other objects (knows as Subscribers) must comply in order to be notified of a certain condition occurring in the Publisher object. This is achieved as follows, when a certain state is reached in the Publisher object an event will be raised, which will then trigger all the Subscriber objects to react by executing the method defined within the individual Subscriber objects that matches the delegate method as defined in the Publisher.

Now let us have a look at an example:

First let us create the Publisher, here we have to do three things:
1. Define a delegate which will act as the contract between the Publisher and Subscribers.
2. Define an event based on the delegate.
3. Raise the defined event.

public class KillerRobotPublisher
{
	public delegate void KillerRobotEventHandler(object source, EventArgs args);

	public event KillerRobotEventHandler KillerRobotAction;

	protected virtual void OnKillerRobotAction()
	 {
		if(KillerRobotAction!=null) //check if there are any subscribers
			{
				KillerRobotAction(this,EventArgs.Empty);
			}
	 }

	public void DoKillerRobotAction(string action)
	 {
		Console.WriteLine(“Killer Robot is doing “ +action);
		//add additional action logic here

		OnKillerRobotAction();
	}
}

Next let us create a Subscriber to subscribe to the KillerRobotAction event on the Publisher.

public class KillerRobotSubscriber
{
	public void OnKillerRobotAction(object source, EventArgs args)
     //this method conforms to the delegate defined in the Publisher
	 {
		Console.WriteLine(“The Killer Robot did something!”);
	 }
}

Now lastly let us create a basic application to instantiate the objects and to subscribe the Subscriber to the Publisher:

class Program
{
	static void Main(string[] args)
	{
		var killerRobotPub = new KillerRobotPublisher(); //Instantiate Publisher Object
		var killerRobotSub = new KillerRobotSubscriber(); //Instantiate Subscriber Object 

		killerRobotPub.KillerRobotAction += killerRobotSub.OnKillerRobotAction;
		//Subscribe the KillerRobotSubscriber to the KillerRobotAction event on the KillerRobotPublisher.

		killerRobotPub.DoKillerRobotAction(“A Dance”);
	}
}

The console output of this application will look like this:

console_Output

Bite Size C# – Eventing\Observer Pattern

Review – RAZER MAMBA TOURNAMENT EDITION

Recently my Mad Catz R.A.T. 5 died after several years of great service, so I found myself in the market for a new mouse. After shopping around I decided on the Razer Mamba Tournament Edition as it is a larger form factor mouse which I find more comfortable.

From a feature perspective it measures up against the R.A.T.5 as follows:

R.A.T. 5 Mamba TE
Year Released 2010 2015
DPI Adjustable up to 5600dpi Adjustable up to 16000dpi
Buttons 8 9
Connectivity Wired USB (braided cable) Wired USB (braided cable)
Weight Adjustable up to 150g 133g
Sensor Lazer 5G Lazer
Additional Features Adjustable length, Aluminium Chassis, Removable Thumb Rest RGB (Chroma, configurable)

The Mamba TE does offer a lot less as far as configurability of the mouse’s physical attributes (e.g. weight and length) is concerned, however I do find it extremely comfortable. It is fractionally lighter than the R.A.T. 5 at its heaviest configuration (17g lighter) but in all honesty I cannot feel a meaningful difference. I find that the Mamba TE does feel like a more refined product, which is to be expected with a product 5 years newer.
I loved the R.A.T.5 and I loved that it was built like a tank, however I am really enjoying the feel of the new mouse and it also looks good, especially if you enjoy RGB.

This slideshow requires JavaScript.

Review – RAZER MAMBA TOURNAMENT EDITION

BOOK REVIEW – VIRTUAL REALITY FOR BEGINNERS! by MURRAY RAMIREZ

IMG_3720

Virtual Reality for Beginners! is a basic, but comprehensive introduction to Virtual Reality, covering topics such as the history and development of Virtual Reality, current VR hardware and software, 360° cameras and a basic analysis of the VR industry.

The book goes into a fair amount of detail with regards to currently available VR headsets, covering everything from the Google Cardboard to the Oculus Rift and HTC Vive. It provides a detailed breakdown of each product, giving a good amount of detail on the specifications and features of each as well as available software.  This does provide an interesting read, however because so much focus is placed on current hardware this will result in the book becoming outdated very quickly.

All the information in this book can be sourced online, however I found the book to be an interesting, well written quick read which was also inexpensive. Given this I would still recommend this book to anyone interested in VR, who currently has very limited knowledge on the topic.

BOOK REVIEW – VIRTUAL REALITY FOR BEGINNERS! by MURRAY RAMIREZ

Bite Size C# – Extension Methods

Extension methods allow us to add methods to existing classes without changing the class’ source code, nor by inheriting from the class. Extension methods are more relevant when wanting to add a method to a class from which one cannot inherit, such as sealed classes.
Just note, you cannot use extension methods with a static class as extension methods require an instance variable for an object in order to be utilised.
Let us look at an example, here we will add an extension method to the string class, which is a sealed class (i.e. you cannot inherit from this class).

class Program
{
	static void Main(string[] args)
	{
		string sentence=  “This is something a person would say.”;

		var robotSentence = sentence.ToRobot();
		Console.WriteLine(robotSentence);
	}
}

public static class StringExtensions
{
	public static string ToRobot(this string str)
	{
		if(String.IsNullOrEmpty(str)) return str;
		var words = str.Split(‘ ‘);
		var robotStr = String.Empty;

		foreach(var word in words)
		{
			if(word.Length > 4)
			{
				robotStr+=“BEEP “;
			} else {
				robotStr+=“BOOP ”;
			}
		}

		return robotStr.Trim();
	}
}

Also note that extension methods must be non-generic static methods defined in a static class.

Bite Size C# – Extension Methods

BOOK REVIEW – VR UX BY CASEY FICTUM

VR UX by Casey Fictum aims to inform the reader on the topics of Virtual Reality User Experience, focusing on experience design, sound, storytelling, movement and user controls.

The book does not go into great depth on these topics, but rather gives a high-level overview. The book only weighing in at 100 pages, including a lot of diagrams and images.

It does provide some interesting insights regarding how to storyboard a 360° scenario, a unique problem to VR.

A lot of focus is placed on movement, be that either player or objects in the virtual world and the effect this can have on the player, i.e. VR sickness. It gives a good amount of design guidance with reasons supporting the recommendations.

There are however some inaccuracies in the book, it was published in 2016 so it is slightly out of date. In the controls input chapter where various user input options are discussed, it mentions that in VR users cannot see input devices even with the Oculus Touch controls, as they will not be projected into the virtual world. We know this is untrue as projecting the user controllers into the virtual world, as with the HTC Vive, has become common practice in VR.

This book does provide a nice overview on the topics covered, and having everything in a single place and in a very easy readable format is nice, however I do feel that most of the information contained in the book can easily be found online, and as VR is still rapidly evolving the information online will also be more up to date.

BOOK REVIEW – VR UX BY CASEY FICTUM

Bite Size C# – Delegates

A delegate is a form of a type-safe function pointer. More simply put, it is an object that knows how to call a method, i.e. a reference to a method. Delegates are useful as they assist us in writing flexible and extendable applications.

Delegates are useful when using the eventing design pattern also known as the observer pattern. The eventing or observer pattern consists of an object, called the subject or publisher, which maintains a list of dependent objects, called observers or subscribers, and notifies them automatically of a state change in the subject-object by raising an event and then calling a method on the observer objects by using a delegate. We will cover this pattern in more detail when I cover events in a separate post.

For now, let us simply focus on delegates.

So, let us look at an example:


public class KillerRobot
{
	public string Name { get; set; }
}

public class KillerRobotActuator
{
	public delegate void KillerRobotActionHandler(KillerRobot robot); 	//Declare delegate which will act as a
															//signature for methods that can be
															//referenced.

	public void DoAction(string robotName, KillerRobotActionHandler actionHandler)
	{
		var robot = new KillerRobot {Name = robotName	};
		actionHandler(robot);
	}
}

public class RobotActions
{
	public void RobotTalk(KillerRobot robot)
	{
		Console.WriteLine(“{0} is Talking.”, robot.Name);
	}

	public void RobotDance(KillerRobot robot)
	{
		Console.WriteLine(“{0} is Dancing.”, robot.Name);
	}
}

class Program
{
	static void Main(string[] args)
	{
		var robotActuator = new KillerRobotActuator();
		var robotActions = new RobotActions();
		KillerRobotActuator.KillerRobotActionHandler actionHandler = robotActions.RobotTalk;
		actionHandler += robotActions.RobotDance;
		actionHandler += RobotPowerOff;

		robotActuator.DoAction(“The Geek”,actionHandler);
	}

	static void RobotPowerOff(KillerRobot robot)
	{
		Console.WriteLine(“{0} has turned off.”, robot.Name);
	}
}

So, in this basic example we have a class KillerRobotActuator which declares a delegate:

public delegate void KillerRobotActionHandler(KillerRobot robot);

Any method that complies to this signature can then be added to this delegate and in the DoAction method where the following is executed:

actionHandler(robot);

All the methods that have been added to the actionHandler will then be executed.
We can see in the Main method of the Program class that a new KillerRobotActionHandler is declared and three method references are added to it as below:

KillerRobotActuator.KillerRobotActionHandler actionHandler = robotActions.RobotTalk;
actionHandler += robotActions.RobotDance;
actionHandler += RobotPowerOff;

And then finally the DoAction method on KillerRobotActuator is executed, passing in the above declared actionHandler containing references to the three methods:

robotActuator.DoAction(“The Geek”,actionHandler);

All three the methods that are referenced by the actionHandler comply to the signature defined in the delegate declaration in the KillerRobotActuator class. i.e. a void return type and an input parameter of type KillerRobot.
It is also worth mentioning that of the methods referenced, two are contained in a separate class RobotActions and the third is a static method declared in the Program class, so methods from multiple different class locations can be added as long as they comply to the signature of the delegate declares.

 

Bite Size C# – Delegates