Adaptive Code in C#: Agile Coding with Design Patterns and SOLID Principles


 Adaptive Code via C: Agile coding with design patterns and SOLID principles

For anyone who is serious about writing good, clean code that is adaptive this book is a must. Even though the book is written for C# programmers, any programmer who needs to learn agile coding using design patterns and SOLID principles will find this book of great value.

The book is partitioned into three sections. Part 1 provides you with a foundation into agile software project management using Scrum. Then you learn about programming with dependencies and layering, before you move on to reading about interfaces and design patterns. This part finishes with a look at unit testing and refactoring.

In Part 2 you are guided through the process of writing SOLID code. There are eight chapters in all in Part 2. These chapters cover the single responsibility principle, the open/closed principle, the Liskov substitution principle, interface segregation, and dependency injection.

You then move on to Part 3 which guides you through the initial phases of developing an adaptive software product over two sprints. Using a fictitious team and project, chapters 10 , 11, and 12 describe the conversations the team members have and the decisions they must make along the way.

You can find the code samples on GitHub. The code examples reflect a selection of some of the patterns and practices that were covered in Parts 1 and 2. Not everything is covered, but some of the more common implementation questions are answered.

All-in-all a very good book, and one that is easy to read from cover-to-cover.

Advertisements

Unity 2017.1


I have just visited the Unity website to view the Asset Store, and have learnt that they are moving to a new release cycle. The current release is 2017.1, and I must say that the new additions to Unity are impressive, especially for teams, artists and designers. You can read about the new release on the Unity Blog.

I am looking to enhance my game created with Unity called Muddle Puzzle. Improvements include making the game available on other platforms, and adding the ability to take photographs and use them in the game. So I will be downloading the new version of Unity, and will be developing my game against it.

Xna 4.0 Game Development by Example: Beginner’s Guide


XNA 4.0 Game Development By Example authored by Kurt Jaegers is an excellent book for anyone who wants to learn XNA 4.0 games development. As you work through the book you develop some games including Flood Control, Astroid Belt Assault, Robot Rampage, and Gemstone Hunter.

This book comes in two versions one for Visual Basic .NET programmers, and the other for C# programmers. The good thing about this book is that it is very easy to read, and the examples are easy to follow. For anyone new to games programming this is a good place to start

Silverlight UserControl Binding to Object Properties


On your main user control create a member variable for your object. Your object will need to implement the INotifyPropertyChanged interface. In your constructor, set the data context to the member variable. Your child user control will need to provide a dependency property and implement the INotifyPropertyChanged interface. Place your child user control on to the main user control, and set its binding in XAML to the name of the property, and set its mode to two way: Text="{Binding MyDataProperty, Mode="TwoWay}".

Silverlight UserControl Type Not Defined Exception


I have had a really frustrating day and a half trying to get a Silverlight UserControl to work in another project of mine. The solution consists of an ASP.NET website with domainservices made available to a number of Silverlight applications. The Silverlight UserControl was properly namespaced, inline with all the other projects. But could I add it to my Silverlight applications. NO!

I knew it had to be something to do with namespace issues, and I tried all sorts. In the end I managed to solve the issue with the help of my senior colleague.

The solution was as follows.

Here are the original namespaces of the web host project, and the UserControl respectively:

  • Lucid.Online.Assessments.Server (the web host)
  • Lucid.Controls.Silverlight.BlockButton (the user control)

Here are the modified namespaces:

  • LucidOnline.Assessments.Server (the web host)
  • Lucid.Controls.Silverlight.BlockButton (the user control)

Just one period caused all that hassle! Why? I don’t understand why. But at least this has fixed my issue.

So if you get the Type ” undefined exception, just check your namespaces.

Silverlight with WCF Services and SQL LocalDB Development and Deployment using CassiniDev.


Problem: You are required to deploy a Silverlight application that accesses a database via WCF Services onto a standalone computer that does not have IIS, IIS Express, or SQL Server Express installed.  Your end users are people with very limited or no real technical background that find even simple day-to-day IT tasks difficult. What database and web server do you use, and how can you make the installation as easy as possible for your end users with little, or preferably no configuration?

Solution.

  • Install SQL Server 2012 or higher on your development computer.
  • Connect to the LocalDb server instance in management studio using: (localdb)\v11.0.
  • Create a new query and enter the following command to create     your database:

    create database databaseName on (name=’databaseName’, filename=’fileLocation\fileName.mdf’)

  • Create your tables.
  • Create a new Visual Studio Silverlight with WCF RIA Services project.
  • Right click on the web project and select Manage NuGet Packages…
  • Select the online option and type entityframework.
  • Install EntityFramework.
  • Add a model.  The server name should be: (localdb)\v11.0.
  • Build your project.
  • Create your domain service.
  • Build your project.
  • In your Silverlight application import the System.ServiceModel.DomainServices.Client namespace, and the namespace of your web project.
  • Create a member variable for your domain context and IEnumerable of your domain object.
  • In the appropriate method that will instantiate the domain service add the relevant EntityQuery and LoadOperation lines of code.
  • Add you method that will handle the LoadOperation.Completed event, check that args is not nothing.
  • Use your entities as required.
  • Now add a Windows Form application.
  • Download and install CassiniDev.
  • In your Windows Forms application add a reference to the CassiniDev4-lib.dll.
  • For the tutorial on Using CassiniDev to host ASP.NET in your application.
  • Build your solution.
  • Copy the deployable portions of the web project into the WebContent folder located in the Windows Forms executable’s root folder.

On the client computer that you are going to deploy the solution on you will need to install:

  • Silverlight 5;
  • the .NET Framework 4.02 update (NDP40-KB2544514-x86-x64.exe);
  • and the SQL Server Local Database (SqlLocalDB.msi).

There is the Express Edition of InstallShield which is free to use.  Use this to create a Basic MSI project that will silently install the above components, and copy your application onto the client computer.  Create a desktop shortcut.  Run the executable from the shortcut to test that the application is working.

Update WPF UI During Method Execution


Samuel Jack of Seaturtle Software Limited has produced an interesting method that allows you to force the WPF UI to update during a method call. Here is the code:

void AllowUIToUpdate() {
DispatcherFrame frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate(object parameter)
{
frame.Continue = false;
return null;
}), null);
Dispatcher.PushFrame(frame);
}

This code help me to fix an issue that I had with my WPF program. The original article is called Forcing Update of UI before my function exits.