An introduction to Interface Segregation Principle (ISP)

Last week I wrote a post about Dependency Injection (DI) with some basic examples in C#. Today I would like to write and offer a simple example of what is known as Interface Segregation Principle (ISP) which can happen if you are not careful when using and implementing interfaces in your code.

What is Interface Segregation Principle (ISP)?

The goal behind ISP is that no client consuming an interface should be forced to depend on methods it does not use. For example, you might have a class that implements an interface called IPersist. Let’s call it ReservationDatabase, and this class has code that persists a hotel reservation details to a database. IPersist contains the public method declaration of the method in ReservationDatabase that performs the persistence to the database. IPersist looks like this:

public interface IPersist
 {
    bool Save(ReservationDetails reservation);
 }

As you can see, this interface is very simple and it only has one responsibility. You could implement this from several classes that have a public method labeled “Save” to save some data to a database, to a XML document, to other data repository, etc… Everything is good so far.

Now, let’s say that you have a new class for logging some of the tasks related to the reservation, and you would like this ReservationLog class to implement IPersist as well as one of the functions of ReservationLog is to save this to a log repository. To implement IPersist you simply add the following at the top of your class:

public class ReservationLog : IPersist

This is the entire ReservationLog class that now implements IPersist:

public class ReservationLog : IPersist
 {
    public bool Save(ReservationDetails reservation)
    {
       // imagine some code here to perist data to database...
       return true;
    }

    public void Log(ReservationDetails reservation)
    {
       // imagine some code here to log to a log repository
    }

    public void SendNotification(ReservationDetails reservation)
    {
       // imagine some code here that notifies about logging
    }
 }

Now, since we are already implementing IPersist in our ReservationLog class which has two other methods, we update IPersist so it includes the two other methods from ReservationLog because it will be easier for the class or classes consuming IPersist to access these methods when logging is needed. So the updated IPersist interface looks like this now:

public interface IPersist
 {
    bool Save(ReservationDetails reservation);
    void Log(ReservationDetails reservation);
    void SendNotification(ReservationDetails reservation);
 }

What we did above might not look like a big change but it is. What we did above is wrong if you didn’t first carefully consider the consequences of implementing IPersist in a class that has multiple public methods and then adding those new method declarations to IPersist. The main responsibility of IPersist was until now to abstract the details from classes that allowed to save reservation details to some data repository. By implementing IPersist on ReservationLog and adding all of its public method declarations to this interface, the result is broken code in all of the classes that are implementing IPersist IF they don’t have public methods that match with those in the IPersist interface.

For example, the original ReservationDatabase class looks like this:

public class ReservationDatabase : IPersist
 {
    public bool Save(ReservationDetails reservation)
    {
       // imagine some code here to persist data to database...
       return true;
    }
 }

This code won’t compile anymore as this class and perhaps other classes in our code that implement IPersist, do not have methods that implement the two new declarations we added to IPersist:

void Log(ReservationDetails reservation);
void SendNotification(ReservationDetails reservation);

The common and not recommended “fix” for this is to “implement” these methods in all classes that implement IPersist and then just return a not implemented exception if anyone ever uses it. Using our example, our ReservationDatabase will look like this if we apply the quick fix:

public class ReservationDatabase : IPersist
 {
    public bool Save(ReservationDetails reservation)
    {
       // imagine some code here to persist data to database...
       return true;
    }
    public void Log(ReservationDetails reservation)
    {
       throw new NotImplementedException();
    }
    public void SendNotification(ReservationDetails reservation)
    {
       throw new NotImplementedException();
    }
 }

The code above is a clear example of breaking the interface segregation principle, which advises not to force any client to depend on methods that it does not use… like the two methods in our illustration above. If you ever see code like this in your projects, where the methods are implementing an interface and all its methods and just throwing NotImplementedException errors on some of them, the code is breaking the interface segregation principle. It is bad as the fix is quite simple and by fixing it you will end up with more maintainable code that can be easier to read and debug.

How to avoid violating the ISP principle?

It is actually very easy, it does require a bit more work but in the end you will have better organized code, you will be following this principle and a few more such as single responsibility and the universal KISS principle.

If you wanted to implement IPersist in your ReservationLog class you can still do it. However, do not update IPersist to accomodate for the other public methods in your ReservationLog class, instead create a new interface, implement it and use it to add any log related methods from your class to it. This is what this new interface might look like:

public interface ILog
{
   void Log(ReservationDetails reservation);
   void SendNotification(ReservationDetails reservation);
}

Now you can implement ILog in your ReservationLog class. You can do this by adding a comma and typing the name of it after IPersist which was implemented earlier.

public class ReservationLog : IPersist, ILog

That’s it! by doing this you can still implement IPersist without having to change other classes that might implement it and you also create a new interface that can be used by any classes wanting to implement the Log and SendNotification methods.

You could probably remove the SendNotification method and abstract it to yet another interface named INotify to keep your code simple, organized and maintainable.

Also, if your code is already violating ISP and you have interfaces that already have multiple method declarations then your should consider fixing this by refactoring your code using the Adapter pattern, take a look at this to see a clear example of it.

Hope this is useful to you. Happy coding!

 

An introduction to Dependency Injection (DI) and Inversion of Control (IoC)

There is so much confusion and arguing about what dependency injection is and whether is the same as inversion of control or just one form of it. If you are new to these terms it can be very confusing to say the least. I’ll try to describe what these are with some examples written in C# and hopefully you’ll have a better understanding of what this is and how to actually implement them in your code.

Dependency Injection (DI) vs. Inversion of Control (IoC)

According to Martin Fowler these two are exactly the same thing, here is some text extracted from his own article about inversion of control:

As a result I think we need a more specific name for this pattern. Inversion of Control is too generic a term, and thus people find it confusing. As a result with a lot of discussion with various IoC advocates we settled on the name Dependency Injection.

Based on this I have personally settled on calling it all Dependency Injection which can be implemented in different forms. So, what is Dependency Injection? my definition of it? instead of having your classes creating a dependency or asking a factory object to make one for them, you pass the needed dependencies in to the constructor or via property setters, and your class doesn’t care about much else. This helps you to decouple dependencies that your classes are dependent on to do their work to make your code more flexible and testable.

For example, let’s say we have a booking service which we use to create a reservation object when a traveler books a hotel in a website. The reservation class might include things like validation and other business logic but it also calls code from another class to save the reservation details to a database. Here is an illustration of what I just described: mockup The photo above shows how the Reservation class depends on the ReservationDatabase class. In other words, Reservation knows that it needs a ReservationDatabase instance in order to be able to save the reservation details. The question to ask is, does the Reservation class really needs to know that it uses ReservationDatabase? It should be enough that Reservation class knows about the behavior, the methods, properties etc, of ReservationDatabase without knowing who actually implements that behavior. Let’s take a look at the code representation of the above:

public class Reservation
    {
        public void ProcessReservations(ReservationDetails reservation)
        {
            // business logic, validation, etc...

            // save booking to database
            new ReservationDatabase().Save(reservation);
        }
    }

Now, imagine if you wanted to test the code in the Reservation class, it wouldn’t work as in the example above uses an instance of ReservationDatabase which has the code to save the reservation to the database. In other words, you would need a database to test the code above. Also, the code above is not very flexible as it forces one class to know about the class that implements some of the code. For example, if you wanted to unit test the Reservation class you would need to test the code behind the Save method too as it is a method used in the code above. You cannot isolate your code using the implementation above.

Applying Dependency Injection

With dependency injection we can solve the potential problems we described above and with a few simple changes our code can be more flexible and testable. We can isolate our code and decouple our classes so one does not have to know the details of the other, just needs to know about the interface and not the class that implements it at run time. So how we do this? We can remove the dependency of Reservation on ReservationDatabase by extracting an abstract definition of the behavior used by Reservation in ReservationDatabase, in other words, let’s create an Interface to separate the two classes and ‘hide’ the implementation details of ReservationDatabase to the Reservation class. This is illustrated below: dependencyinjection In the illustration above, ReservationDatabase implements IPersist (interface) and Reservation uses it. At this point Reservation might still be using ReservationDatabase but it doesn’t know it, it just knows that is uses something that implements IPersist. We could change what happens in ReservationDatabase and the Reservation class wouldn’t know about it, or perhaps we could have a new class implement IPersist and again, Reservation wouldn’t know or care about it. Here is the code representation of the above, first you’ll see how Reservation now uses the new interface IPersist which is implemented by ReservationDatabase in our example:

public class Reservation
    {
        private IPersist reservationSaver;

        public Reservation(IPersist reservationDatabase)
        {
            this.reservationDatabase = reservationDatabase;
        }

        public void ProcessReservations(ReservationDetails reservation)
        {
            // business logic, validation, etc...

            // save booking to database
            reservationSaver.Save(reservation);
        }
    }

The code above shows you a basic implementation of Dependency Injection (DI), now let’s see how we benefit from this. The code above shows how we injected the dependency (IPersist) into our Reservation class by using a constructor. We did this by using what is called constructor injection, where we supply the IPersist instance to Reservation’s constructor, or property injection where we supply it to Reservation after it has been instantiated by setting a property on it.

This gives us the ability to use any code that implements IPersist without knowing the details of that code. For example, let’s say that we wanted to not only persist the reservation to the database but also to some XML document for whatever reason. With the updated code we would just need to write a new class that had all of the code to create a new XML document and then make sure that implements our interface IPersist. By doing this, our Reservation class will now be able to save the reservation data to XML without having to make any code changes in that class. See illustration below:

dependencyinjectionThe above illustration shows clearly how Reservation only needs to know about IPersist but it doesn’t know what other classes implement it, and that is OK. As you would imagine, we could keep adding classes to perform some sort of persistence without having to make a single change on Reservation, all we need to do is implement IPersist and we’ll be done.

Dependency injection in this example is what we showed in the code example above, notice how Reservation has a constructor which requires an instance of IPersist as a parameter. It stores this instance in a field and when invoked the last step of ProccessReservations method uses this injected instance to save the reservation.

I will write about Dependency Injection Containers / IoC Containers in a follow up post but for now, use the examples above as a basic way to implement Dependency Injection in your code to make it a bit more flexible and testable. Cheers!

Building a Todo web app using PHP, Laravel and Bootstrap

I want to learn more about web frameworks that I am not too familiar with. My plan is to write simple web and mobile apps using different frameworks and technology stacks that I don’t have much experience with. While this is not going to make me an expert on any of these technology stacks or frameworks, it will give me the right amount of knowledge to decide if I like it by learning how to set up my environment, the tooling and the basic syntax of each. The first one of these apps is a to-do list which I wrote using PHP and bootstrap. Since I want to try new (to me) web frameworks I also used Laravel which is a PHP web framework that has everything you need to build a web application.

If you are learning PHP I want to recommend you give Laravel a try.

Setting up your environment

I recommend using Composer to install Laravel, Composer is a package management for PHP, just like Nuget for .NET, Maven for Java, RubyGems for Ruby, or npm for Node.js – you get the idea…

To install Composer you can do one of the following:

curl -sS https://getcomposer.org/installer | php
php -r "readfile('https://getcomposer.org/installer');" | php

Or using the Windows installer. The installer will download composer for you and set up your PATH environment variable so you can simply call composer from any directory.

Download and run Composer-Setup.exe – it will install the latest composer version whenever it is executed.

Once you have composer in your system, use it like this:

composer create-project laravel/laravel your-project-name --prefer-dist

This command will download and install a fresh copy of Laravel in a new your-project-name folder within your current directory. Next run the composer install command in the root of your manually created project directory. This command will download and install the framework’s dependencies.

Serving your web app

You can use a web server such as Apache or Nginx to serve your Laravel applications. Also, if you are in a Windows environment and have Webmatrix installed, you can use this to serve and also write your Laravel applications as well.

However, for this example I used PHP’s built-in development server, it is great for use while developing a Laravel application.

You will need to have PHP 5.4+ installed in your system to use it.To start PHP’s built-in development server and launch your application type the following command

php artisan serve

By the way, artisan is the name of the command line interface (CLI) included in Lavarel, you can read more about it here.

After executing the above command, you should see the following message:

Laravel development server started on http://localhost:8000

This development server automatically uses port 8000 to serve web applications, you can change the port number if necessary by specifying it as --port=some-port-number

php artisan serve --port=8080

 Setting up Routing

Setting up routes using Laravel is quite easy. See example below:

Route::get('hello', function()
{
      return 'Hello World';
});

The above route will return “Hello World” when you browse to http://localhost:8000/hello.

In my web application example I have the following routes:

Route::get('todos', function()
{
	$todos = Todo::all();

    return View::make('todos')->with('todos', $todos);
});

Route::post('todos', 'HomeController@savetodo');

The first route basically returns http://localhost:8000/todo with a list of all todo items stored in the database. The second route posts to the HomeController, and used the function saveTodo to save a new todo item. Before we can use the above routes, we have to setup our views, model and database.

Setting up Views

Views live in the app/views directory and contain the HTML of the application. We’re going to place two new views in this directory: layout.blade.php and todo.blade.php. First, let’s create our layout.blade.php file which you can find in its entirety here, but this is the one important line that needs to be included in the view:

@yield('content')

The code above is the entire layout.blade.php view which acts as a template for your web application. The rest of the views use this template, they are rendered by calling @yield(‘content’).

In order for the rest of your views to use this template you have to add the following to the top of your views:

@extends('layout')
@extends('content')

I am excluding the rest of the content in the view todos.blade.php for brevity but you can download the entire project here.

That is all for this PHP ToDo web app built using the Laravel framework and Bootstrap. Hope it is useful for some and please feel free to download it, use it, change it and please let me know any thoughts you might have about it. Cheers!

I am currently available for freelance – contact me if you need help with a software project.

Install MongoDB service on Windows 8

MongoDB (from “humongous”) is an open-source document database, and the leading NoSQL database. Written in C++.

MongoDB is great for modeling many of the entities that back most modern web-apps, either consumer or enterprise:

  • Account and user profiles: can store arrays of addresses with ease
  • CMS: the flexible schema of MongoDB is great for heterogeneous collections of content types
  • Form data: MongoDB makes it easy to evolve structure of form data over time
  • Blogs / user-generated content: can keep data with complex relationships together in one object
  • Messaging: vary message meta-data easily per message or message type without needing to maintain separate collections or schemas
  • System configuration: just a nice object graph of configuration values, which is very natural in MongoDB
  • Log data of any kind: structured log data is the future
  • Graphs: just objects and pointers – a perfect fit
  • Location based data: MongoDB understands geo-spatial coordinates and natively supports geo-spatial indexing

Continue reading

Turning 40

Today I am turning 40 years old. What does that mean? that I am old? that I am about to go into mid-life crisis? that I should give up all of my dreams? that I am entering into one of life’s most dangerous ages for men? The truth is that most of the things I mentioned above can only be true if you allow it.

I still remember when I was in my teenage years and I wanted to reach 20 years of age, I was frustrated that I couldn’t reach that age fast enough. When I was around 16 or 17 the idea of being a 20-year-old opened all sorts of opportunities and freedom, or so I thought. By the time I was about to reach 30 years of age I felt stressed, I knew I was reaching an important part of my life where every time you make a decision regardless of being good or bad, you know it would affect you down the road. It also meant that every decision I made would affect not only me but my wife and kids, I was no longer a unit of one.

It wasn’t until about 3 years ago that I started feeling worried and a bit sad that I was approaching 40. I remember thinking of people who age when I was in my early 20s as I looked at teachers, my parents, uncles, etc… to me it meant that if you were a 40-year-old person, you were a super old person. How naïve I was.

Recently I started to realize how our core and our mind doesn’t really change that much with age after you reach your 20s. You do start seeing wrinkles in your face and you notice how your body starts to change but inside, you are still you; The same person who thought a 40-year-old person was super old and this, this is exactly what made me and so many others feel sad about getting older.

I have respect for people of all ages, and sympathy for those who are trapped in an older body when their mind and spirit is still the same, young and full of joy. However, it isn’t easy to accept that your body is just a wrapper and that you are what’s inside of it. You must remember that your feelings, memories, experiences and thoughts are what makes you, the person.

I’d like to think that I still have a long way to go, that I am still in the beginning of my journey, that there are still many awesome things out there to be discovered and that makes me feel young and happy. I think of all the joy that my kids have brought me so far and that this is just the beginning. I imagine myself being a grand father and walking with my grandkids on the beach or a small street somewhere in Europe. I imagine holding hands with my wife and laugh at our ourselves and our old bodies. Sitting somewhere contemplating the horizon and thinking about all the things we’ve done together.

So I have come to the conclusion that age is nothing but a number, it means nothing really and it only helps humanity to divide people by “age” so we can create rules and laws around that.

Perhaps the fact that we acknowledge age and see it as something important is what causes all of us to become old and feel like it. Think about it, we could be convincing ourselves to feel and behave differently just because we are older. How naïve.

What have I done these years since my 20s? here some of the most important things I have done since then:

  • Said bye to my family in Mexico and moved to the United States, undocumented.
  • Got a job and helped my family back in Mexico.
  • Fell in love with my wife.
  • Got married after dating my wife for 3 months.
  • Got my first apartment, for me and my wife.
  • Got my first real job, working at a factory and earning minimum wage.
  • Became a citizen of the Unites States.
  • Went to College in Minnesota.
  • Had our first child, our beautiful Jennifer Lee.
  • Kept working fulltime and going to college in the evenings.
  • Found a job as tech support in a small company.
  • Learned to code and started doing some websites and consulting.
  • Started a Tax preparation company which my wife runs today.
  • Graduated.
  • Got promoted at my job, I was no longer making a minimum wage.
  • Had our second child, our handsome Ricardo Ervey.
  • Moved to another city in Minnesota.
  • Things improve professionally, and the Tax preparation business takes off.
  • Got tired of the cold winters and the snow.
  • Moved to Texas.
  • Bought our first house.
  • Found a job as a software developer.
  • Traveled to Europe for the first time.
  • Had our third child, our handsome and energized Mauricio Dioni.
  • Things improve professionally, my wife takes over the Tax business.
  • Travel a lot.
  • More travel.
  • Move to another job.
  • Start another business.
  • Sell our first home and move into our second home.
  • Kids are growing. Jennifer is in High School now.
  • My brothers and sisters are growing, and so are their kids.
  • By now my wife and I have traveled to almost 10 different countries, and have drank and ate more food that you can imagine.
  • Turned 40.

Today I am 40 years old and I am very happy. If you are into history and would like to know what “other” famous people are turning 40 this year, click here.

[Update]

Meet Tokio, new member of the family and a gift for my 40th birthday from my wife.

tokio

Until next time, I’ll write something similar when I get to 50 :)

How to add a full page background image to your landing page

I recently decided to update the landing page of one of my projects. I wanted to have a full-page background image and change this background image every time a user landed in this page or refreshed it. Here is what I ended up doing:

The <html> tag

Since we are replacing the entire background of your page, let’s add the background image to your html tag. We are going to do this by using some JavaScript that will update the <html> style when the page loads. The reason I am doing this instead of using CSS is because I want to be able to change the background image every time the page loads or it is refreshed.

The first step is to add an id to the <html> tag as shown below:

<html lang="en" id="landing">

Adding an id to the <html> tag allows us to identify it when doing the image background change in JavaScript.

The JavaScript

In order to display a different image every time the page loads or gets refreshed I wrote a function that randomly picks one image from an array. Basically I look at the length of the array (# of images) and then just pick a number from the array using both the Math.floor and Math.random methods from JavaScript.

The last step is to change the background image style of <html> to be the current selected image from JavaScript as shown below:

// <![CDATA[
  function Randomize() {
     var images = new Array("/images/journal1.jpg",
         "/images/journal4.jpg",
         "/images/journal6.jpg",
         "/images/journal7.jpg",
         "/images/journal8.jpg",
         "/images/journal9.jpg",
         "/images/journal10.jpg",
         "/images/journal12.jpg",
         "/images/journal13.jpg",
         "/images/journal14.jpg");
     var imageNum = Math.floor(Math.random() * images.length);
     document.getElementById("signup").style.backgroundImage = "url('" + images[imageNum] + "')";
  }
  window.onload = Randomize;
// ]]>

If you haven’t already I suggest you place your images and any other static content in a CDN. If you have Azure, take a look at my previous post where I explain how to serve static files from Azure.

Please share your comments or feedback in the comments section below. Happy coding!

 

How to serve static files for your website using Azure

Killer features and a beautiful design are important things when developing a website. However, none of that matters if your site doesn’t perform well or is not able to scale when necessary. Serving static files such as CSS and images from your web server is not ideal.

These are some of the disadvantages of serving static files directly from your web server:

  • Unnecessary deployment of files that do not change often, potentially slowing the deployment process.
  • Increase the load of your web server, making it less responsive.
  • Increase of hosting costs
  • Etc…

Here are some of the advantages of not serving static content from your web server:

  • Distribute web server load.
  • Save bandwidth.
  • Boost performance and reduce your existing hosting costs.
  • Ability to update static files by replacing them in CDN without having to deploy entire website.
  • Etc…

In this blog post I will show you how to take advantage of Microsoft’s Azure CDN and Blob storage to make your website serve all of its static content from the Azure CDN. If you don’t have an Azure account and you are a web developer you are missing out. Azure supports a wide range of frameworks and technologies including but not limited to Python, MySQL, Oracle, Java, Linux, PHP, Ruby and of course all of Microsoft products such as .NET, MS SQL, etc… Also, they offer a program for startups called BizSpark where you get Azure services for free, you can sign up here if you like.

Create a Blob storage account and a container

First of all you need to create a blob storage account and then a container which you’ll use to store all of the static content. To do this open your Azure portal and then click on the + NEW button located at the bottom left corner of the portal and select Data Services > Storage > Quick Create > as shown below, then just type a URL to identify this new blob storage account. In this example I used the name “mystaticfiles”.

Create Blob Storage Account Image

It takes approximately 1 minute for the blob storage account to be created. Think about it, it takes a minute (or less) to deploy a blob storage account/instance capable of logging, monitoring and redundancy.

After that you’ll see your newly created storage account, click on the name of it, then on the Containers link and then on Create Container as shown below:

Create Storage Container Image

After the Create Container window opens, type the name of the new container and its access type. For this example we are going to select Public Blob which allow us to have a container where all files are available to the public. The other two options are Private which makes the container available to you only and Public Container which allows anyone to have access to the files, metadata and pretty much everything else in this container.

create container in Azure

Manage the blob storage account and container

Now that you have your new storage account and container, you can start transferring static files from your website to the container(s) you’ve created. To do this, you can either write a service that does this for you or use one of the programs available that help you manage your containers and files in an Azure storage account.

I found an open source application to help me manage my storage accounts and containers and so far it has worked out very well for me. If you are interested, you can download it here and even get the source code for it too:

Azure Storage Explorer

You can use this application to browse your files as well. Once you have all your static files in your Azure blob storage containers you can then update your static file’s path to point to the Azure containers. For example, here is a link to one of my images stored in Azure blob storage:

https://foreverbitapp.blob.core.windows.net/images/journal9_medium.jpg

Are you using Azure blob storage? please share any tips or feedback in the comments below.

How to become a software developer

Originally posted on OnTechies:

How to become a developerA person looking to become a professional software developer would ideally have a bachelor’s degree in computer science or engineering. If that is you, then you can go ahead and skip to the next section below. However, if you don’t have such a degree and getting one is not feasible then you need to learn about programming and other related skills on your own. This is now easier than it was before due to the increase of online courses, programming bootcamps and coding schools which have made it easier to become a software developer today. While none of these approaches teaches you as much as a regular computer science curriculum, it does teaches you the necessary skills to get started by focusing strictly on what you need to learn to start coding efficiently. Some of these code school programs and online courses will go as far as helping you get a job by referring you to…

View original 860 more words

Error 0x80131902: Failed to create the managed bootstrapper application.

This error message has been giving me headaches for a while, I have seen it happen in different Windows computers when trying to install a Visual Studio update or a new version of Visual Studio. If you Google for the string “Error 0x80131902: Failed to create the managed bootstrapper application.” you’ll find some sites and forums where the following advice and tips are given:

The error in the log, 0x80131902, means that the .NET Framework could not be loaded (more specifically, an AppDomain could not be created).

Do you have at least .NET 3.5 installed/enabled on your machines? You might also connect to Windows Update and make sure you have all required updates installed. There may be some bugs that have been fixed in the .NET Framework.

Another possibility – though not for this specific error but in general – is that your graphics drivers our out of date or not appropriate for your card (mentioned to @TobiasUlm below in another thread). Setup uses WPF and sometimes bad graphics drivers can cause issues (happened with VS itself for some users).

Visit your graphics card’s manufacturer web site and make sure you have the newest driver available for your card and, on Windows 7, that you have the latest DirectX runtime installed. See http://support.microsoft.com/kb/179113 for more information.

- Heath @ http://blogs.msdn.com/heaths; Visual Studio Professional Deployment

Also…

As you can install VS11 with the same ISO successfully on other machines, I think your VS11 ISO should be fine. And please follow the steps below to see if it helps you:

TemporarilyTurn off your anti-virus/antispyware software during installation;
Install the latest Windows updates from the Windows Update site: http://update.DataZX.CN;
Complete or dismiss Windows Update before installation. (And don’t forget to turn it on
later);
Clean your %temp% folder (Start Menu >>Run >> Type “%temp% >> OK);
Then run the setup with Administrator privilege: right-click the installer -> Run as administrator.
Thanks.

Vicky Song [MSFT]
MSDN Community Support

And…

Do you also install VS11 Developer Preview on that Windows7 machine? If so, I am afraid you need to first uninstall the VS11 DP and then install the VS11 Beta again.

In addition, please try to uninstall VS11 Beta completely from your machine and then try re-install it to see if you get the same result. And for the .NET application related issues, I think can consider reinstall .NET Framework 4.5 again. You can find it here:

http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=27541

If you still get the same result, please offer me the complete installation log files you get.

Of course I tried all of those suggestions but none of them worked for me. Every time I tried to install a VS update or a new version of VS – this is the entire log showing me the errors, the error messages were exactly the same for both updating or trying to install a new version of VS:

…..

[0898:1304][2014-04-11T09:08:22]: Loading managed bootstrapper application.
[0898:1304][2014-04-11T09:08:22]: Error 0x80131902: Failed to create the managed bootstrapper application.
[0898:1304][2014-04-11T09:08:22]: Error 0x80131902: Failed to create UX.
[0898:1304][2014-04-11T09:08:22]: Error 0x80131902: Failed to load UX.
[0898:1304][2014-04-11T09:08:22]: Error 0x80131902: Failed while running

…..

[0898:1304][2014-04-11T09:08:22]: Error 0x80131902: Failed to run per-user mode.
[0898:1304][2014-04-11T09:08:22]: Exit code: 0x80131902, restarting: No

As you can see the advice is very similar and while this might have helped some people, it did not help me. After looking around extensively and trying different approaches, I did the opposite of what most people suggested and actually turned off the Microsoft .NET Framework 3.5.1 Windows feature located under Programs and Features – Turn Windows features on or off – see screen shot below:

disable 3.5 .NET framework photo

After turning off Microsoft .NET Framework 3.5.1 I tried installing the updates for VS2012 and installing VS2013 and everything worked flawlessly. After the installations completed successfully, I opened back the Windows features on or off menu and enabled the Microsoft .NET Framework 3.5.1 once again.

This is what I got after my simple fix/change and I hope you can get to the following screen too!

VS install successful photo

 

 

 

Programming languages and work opportunities

What is the best programming language to learn these days? this is a question that I hear all the time and this question usually generates all sorts of responses, both good and bad. The reality is that when people ask that question they do it for different reasons and so there is no right answer. Programming languages are like people, they are all alike but yet unique. For someone new to programming I recommend learning about programming without picking a programming language, at least not from the start.

Programming in a hackathon

Learn about programming before picking a programming language

Learning about programming is much more than just learning a programming language. Programming is about finding solutions to a problem and you do this by performing tasks such as understanding and analyzing these problems to find the right solution for these problems. There are many things to be learned about programming that do not require the commitment to a programming language, start with that, learn about logic, computing, and start by playing with some programming languages once you understand the concept of programming.

When you are ready to learn your first programming language or are already a software developer and perhaps are looking to learn a new programming language just for fun, then I recommend you just start playing with a dynamic language and a static one.

Static or dynamic Languages

If you are new to programming, let me explain the difference between static and dynamically typed languages. In short, a statically typed language is where the type of a variable is known at compile time, this means that you as a programmer must specify the type of each of your variables as it is the case in static languages such as C, C++, C#, Java, etc… In dynamic languages the majority of its type checking occurs during runtime as opposed to compile-time. As a programmer, a dynamic language allows you to move a bit faster as you don’t have to specify the type of your variables, etc.

Marketability of programming languages

If instead you are looking to increase your marketability, then here is some data to help you decide. The numbers below are changing constantly, however the general position for all programming languages listed below is very consistent. All of the data from the chart below came from digging in the number of current job openings in the Unites States for the specified programming languages in the following job listing sites: Indeed, Dice, LinkedIn, StackOverflow Careers.

Number of Job openings by programming language in the U.S.

One programming language that has become popular in recent years is JavaScript. In the past, JavaScript was mostly used as a utility language and most programmers used it to compliment (and hack) their user interfaces. With the increase of HTML5 apps and the many JavaScript based frameworks, this programming language has become more relevant and the number of companies (and startups) looking for experienced JavaScript developers has increased, a lot.

Currently, JavaScript is the second most popular requested skill in programming jobs posted in the largest job search engines out there in the United States.

Conclusion

If you are looking to learn a programming language to increase your chances of being hired, look at the chart above, keep monitoring the demand as it might change in the future AND learn at least one static programming language such as C# or Java and one dynamic language such as JavaScript, Python or Ruby.

A good programmer is the type of person who is always learning, and enjoys doing it. Most programmers I know are highly skilled with one programming language but familiar with most. Knowing a bit about multiple programming languages gives you the flexibility to learn and become more experienced with certain languages when you have the need. For example, for many years I was a Visual Basic developer until the day came when most job openings from companies working with .NET technologies where looking for C# developers, I started looking at the language, tried to create a few simple programs and eventually got a job as a C# developer.
After getting into C# I started to learn PHP and JavaScript as I ran across a few projects that needed that expertise. Learning these programming languages wasn’t hard, it was mostly teaching myself to do things differently, discovering and taking advantage of each of these languages’ capabilities and features instead of complaining or getting stuck on its differences.

Today, I try to keep myself current with some of the newer programming languages and frameworks, it is our duty as professionals to stay current and as challenging as this is, learning is always enjoyable. If you have any thoughts or questions about the chart above please leave a comment below.