jay's old blog

this blog will be deleted soon - please visit my new blog - https://thesanguinetechtrainer.com

free to play - hearthstone - the good and bad and the worst

Thanks to the lengthy commutes of my daily grind, I am forced to mobile game on the go. Of the many games I could pick up, I decided to go with Hearthstone , about which I heard some good things. One of them being that the game strikes a decent balance between being a 'free to play' title and not a 'pay to play' in disguise.

So, I downloaded the hefty (almost 1 GB of download) and started playing. I was intrigued by the game play. It is a online version of the good old fashioned trading card game. You place your cards on the table, and let the opposite party do the same. Then, using a combination of smart thinking, combo attacks and patience, you try your best to defeat your opponent. In the beginning the game was very cool. In fact, I was convinced that the game is indeed 'free to play'.

Some sections of the game, like the Arena, were actually locked out if you dont pay. And, there were some optional adventures which were locked behind a pay wall. So far so good. I want none of that stuff, so its alright. Then, I started building my deck, and i started playing. Eventually, I became pretty good at it and the effect was a pleasant experience.

Then, the grind started!!!

The game has a ranking system which allows you to play with folks who are similarly ranked. After winning back to back for days together, I eventually plateaued at rank 20. No matter how well I play, and how good my cards were, I could no go beyond that. Even when I had excellent card collection, good health and what not, I always ran into opponents who had cards (like restore full health if your hero is less than 5!!! I mean, what the hell is that all bout?) that I could not find in my deck. Nor could I earn them.

That's when it hit me. Hearthstone is just another 'pay to play' game disguised as a 'free to play'. You pay, you get more packs and you get more cards, and you get better cards. It's just as simple as that. Now, let it not be said that I am too cheap to pay. God no! If the product is worth it, I don't mind. I spend thousands on entertainment anyway. However, the actual price and what you get in return is just bad. For a decent set of cards (I am talking about 100, and you are not guaranteed that you will only get new stuff or stuff that is actually useful) I am looking at a bill of 3000 bucks (yep, three thousand rupees) per month. That's right.

The game releases new stuff every so often, and that means, the 'powerful cards' that you have this month could be outdated (or even removed) in a few months. That is when I realized, this is really just another free to play. You pay you win. I had given up on free to play games a few months. And now that I have seen it again, I see that, it is the same old horse and bull stuff all over again.

Please folks. When downloading these free to play games, think what you are getting into. As for me, I have chucked hearthstone out of my devices, and now engaged in Tomb Raider, Hitman Go and Hitman Sniper. All paid games (with some optional purchases) with excellent value for money no plateauing. Thank god for such small baskets of joy.

Route configurations in asp dot net

In asp dot net, the controller is sort of like the brain. It dictates how others are done by in the entire website project. However, it does not decide what routes (especially when it comes to the views that needs to be displayed) need to be taken when web pages that belong to the web app are being accessed by the user.

That job belongs to the route configuration file. You will find this in the App_Start folder of the project.

By default, that project will come bundled with a default route configuration. For most scenarios, the default configuration will be useful to you. Obviously, you can customize route configuration for different scenario as it pleases.

A simple route configuration will look something like this.


                name: "Default",

                url: "{controller}/{action}/{id}",

                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }


This, as the name implies, is the default route to follow by all controllers. It looks at this portion

url: "{controller}/{action}/{id}"

and informs the project MVC system that the controller comes first (after localhost or the server where the site is hosted)  and that will be followed by the action. Further, the code also implies that the third component (the id) is actually optional. That means, if an id is missing from a request path, that should not throw up an error. However, if the id is there, it should be ‘picked up’ and the controller action methods can process it for their own usage.

The fact that this particular route has a name must mean that you can write as many routes as you want. This also means, you can indicate while working with the rest of the project, when it comes to navigation which route configuration to use. So, that facility is also available. For now though, understand that this is where your project gets the idea about how to resolve routes.

MVC in asp dot net

Hopefully you reached after reading some theory I have written about the MVC design pattern itself. In this write-up, I am going to focus on how asp dot net provides the MVC platform.

MVC pattern is one of the three ways you can build an asp dot net website. You can find out more about the other here, here and here. The asp dot net MVC is most suitable for building full-fledged web applications which sometimes go with the name of ‘single page applications’. As is understood from the pattern, when you create a MVC project in visual studio, you already get a very clearly defined Model, View and Controller divisions that is ready to use.

The MVC in asp dot net would be nothing without the kind of support that comes built in with project creation via visual studio. In many ways, visual studio is the real hero when it comes to building projects on any dot net project. Okay, let me stop my love for visual studio and get back to explaining how this work.

In asp dot net, upon creating a project (actual project creation is explained here) you are immediately presented with a set of pre-declared folders that mirror M and V and C. Further, visual studio also includes all the necessary libraries need to kick the start the web development right away. That means, the project already has been ‘boostrapped’ to start working out of the box. This is extremely cool.

Now that’s about what visual studio. The actual dot net implements the MVC with its own components. When it comes to model, MVC strongly recommends and I also recommend, going ahead and using the ‘Entity Framework’ package. I have written more about Entity Framework here, but in simple terms, the Entity Framework provides you with a set of features that allows you to truly decouple the Model part from the project. Further, it also decouples the Model itself from the database.

Model is split into two parts. On one side (the side that faces that code) you define your models as classes. On the other side, (the side that faces the database) you connect to the database of your choice via connection string and the above mentioned Entity Framework. I will also add here that Entity Framework seamlessly converts your model classes into the database tables. As to why this is cool and awesome, you can read more about this post I have written explaining even more stuff about Model in MVC asp dot net here.

On the View side, asp dot net uses a combination of Razor Syntax with HTML stuff. Razor syntax allows you to use c sharp type code to modify and play with data in the View. The HTML stuff does the standard web rendering. Of course, the MVC implementation here already includes JQuery and Bootstrap. This means, your project here is already mobile ready, and ready for mobile optimization from the word go. Even more stuff about the View is written here.

On the controller side, it is completely c sharp. Most of this will be familiar to you. The controller works with the models on one side, and views on the another side. Even more stuff about the controller is written here.

Overall, I am personally very pleased with how MVC is implemented in asp dot net and how cool it works with asp dot net.

The M in MVC

Earlier, I have written about the MVC implementation in asp dot net. Now, let me go a little deeper into it in this post.

The Model part of the implementation is something that I love about asp dot net MVC. To really appreciate how this is awesome, let’s look at how websites would normally work with a database. Say you have a website that is keeping track of students at a college. You would have to design the tables first. Work out the external relationships between the tables. Work out the primary keys and foreign keys. Work out the scripts that work with these tables that include all the CRUD operations.

So, as you can see, it is a lot of work.

Now, an additional challenge is when, as the project grows, you realize that you have to change some or all of the tables. Now, that will be a back breaker because, if you had some hundred scripts, then probably all of them are affected by the change in the table design. That means, it’s up to you to not only change the tables, you also need to ensure that the new changes don’t break the database. Then, you also need to update the scripts that you are using everywhere.

Now, I might be exaggerating things a bit, there is no denying that yes, the work involved will be heavy. The M in MVC brings to the table the Entity Framework. Now, do you remember the decoupling of things I was talking about in when discussing MVC design pattern (find it here, if you have forgotten)? Well, the M in MVC allows you to tightly couple the database (thereby creating a problem). However, MVC strongly recommends that you use Entity Framework.

Thanks to EF, your MVC app need not have a tight coupling with the database. You know how you design variables before you use them in your application? Similarly, you design the classes that will be used for storing data in your application. Then, you had over these classes to EF and wash your hands of it. The EF will then, using its own built in technologies will take care of doing the CRUD with the database. You don’t have to worry about designing the database. You don’t have to worry about writing the SQL scripts. You tell EF what to do, and the EF will take care of actually interfacing with the database. And that is awesome!

Now, there is even more awesomeness at your disposal. Think of that above mentioned scenario where you have to change some of the data models (which means changing the tables in the database as well). Again, you make the changes and EF will automatically update the database according to your changes. Not only that, EF will also you to come back to the previous schema, in case things did not go as planned.

Further, EF also gives you a really cool Seed method which allows you to automatically populate the database with default data. Again, without you having to write SQL scripts. You will be using LINQ for that, which I will discuss at a later point of time.

Adding a View

A view works both ways – showing stuff and also taking information from the user. You can more about View and what it does, right here.

Adding the actual view happens in two ways. You can do it via scaffolding, back when you add a controller with help from Entity Framework (you can read about that here) and you can manually add as many views as you want. When you add view yourself, you can still use the models and database context but I personally feel that it is best to do that when you are adding the controller with the model and database context.

When you are adding empty views, there is one thing you need to understand. You will notice that the website navigation is actually controller by the routing configuration (you can read about hat here) and that has to go through the controller to whom the view belongs to. That means, when you add an empty view, you will have to navigate to the Controller file as well. There you will add a view method with the exact name that you used while creating the view.

Understanding namespaces

One of those things that bugged me a lot (and even today as I write this) are namespaces. You could be designing the model of your project or the controller or some other method functionality or class or whatever it is, you will find this word ‘namespace’ stamped right at the top (after all the libraries including code is written) of your c sharp file.

namespace can be an odd concept to wrap your head around, but when you get what they are doing, you will be happy that they are there. One every day way of looking at namespaces, is to think of your workspace. Now, as I look around my own workspace or desk space, I see a lot of things. I see my laptop, which has its large external monitor connected. I see my water bottle (ah! The water bottle again) and my headphones when my surroundings get too loud (they frequently do). I also see my trusty wireless keyboard and wireless mouse from Microsoft. I see my bag, and notebooks and my post its. I also a huge jumble of cables that connect to my many phones and other USB devices.

Now, my wireless keyboard and the water bottle have nothing in common. Same goes the phone on my desk and the employee card in my bag. However, they all have one thing in common – me, and my work space. All these objects belong to me and they get to live in my workspace, and that means they are all related.

Similarly, in a project, a namespace is like a virtual work space in which your project lives and breathes. Thanks to the way object oriented programming divides, not everybody can access each other. In fact, many of the things you put in your project may never interact with each other. For instance, the models you design in your project will never know where the database is located, where the actual data is stored. Yet, they are both part of your namespace.

This is also the reason why, when you add something, you will notice that the code file automatically includes that in your namespace. This is similar to you buying a new pen and keeping it on your desk. The pen is a new adding (like that new controller or the model class) and now belongs to your work space (just like that controller now belongs to your project namespace).

Also, this is an interesting proposition when it comes to namespaces. It is actually possible (and essential when you are working on truly large projects) to have namespaces that extend beyond the current project solution that you are working on. That means, you could create two different projects in visual studio, and then have both of them have the same namespace, although they are not on the same project at all. That is when you start watching matrix in a room filled with mirrors, and lose all idea about what is real what is not.

Good luck with that :)

The V in MVC

Earlier I have talked about the MVC implementation in asp dot net. In this post, I will spend a little more time talking about the View and its components in MVC.

The View is responsible for showing all the things that the user sees when the web application is alive, is being served by the server, and shown the client i.e. the browser. That means, there are two components to a view – show stuff and get input (text/mouse click/tap) from the user. From a developer perspective, the View is made of standard HTML code. Along with this, you will also find ‘Razor’ syntax all over it.

Razor is kind of a like programming language hybrid that mixes the c sharp type of things with that of HTML. When you are building your View, you can usually split that into two parts. The first part is where you use HTML to build the layout of your view. You use the standard HTML tags like p, h1 and so on. The second part is where you are working with data that is being sent from the controller. For that, you will use Razor syntax.

Just to make it extra clear, all the UI cool stuff that you do or you want to do via bootstrap, CSS, Javascript and jQuery (for the DOM manipulation) is all still valid. So, those skills if you already have will be essential here as well. At the same time, whenever you wish to play with data, you depend on Razor which gives an almost jQuery/C sharp type access system that works just as well.

One way to look at Razor is to think of it like what jQuery (and other Javascript packages) do for the web pages. The difference is that Razor works with asp dot net, but then you still have jQuery to help you out. However, you will lean on Razor a lot because, it has access to data that is sent from the controller.

Another thing which I wished to add here is that Razor is not something that you will have to go out of your way to learn. It is simply one of those components that makes MVC happen. If you already know how to write web code (HTML, Javascript, JQuery), you are already ready to use Razor. If you not, well you can find tutorials we have written here to learn the same. 

Dot net versions, libraries and understanding their importance

Versioning is one of those many necessary evils of software development. Versioning allows software development to continue to make it better by improving stability, add features and overall polish the end product. At the same time, it also leads to any number of confusing scenarios (for both developers and end users) because not everybody can have the ‘latest’ and ‘greatest’ all the time.

Here is an example, and a real life one. Let’s say you buy a water bottle (version 1.0). For that water bottle, you buy a stand, which is compatible with version 1.0. You have been using this for a while now, and things are fine. However, after some time, you find out that the cap on the water bottle keeps sliding out. Just like you, other owners of the water bottle are facing a similar issue. Eventually, the water bottle company releases a new cap. You buy the cap (since the cap is firmly a loosely coupled component of the water bottle) and find that it works just fine with the existing water bottle.

Since this improvement, the water bottle is now version 1.1 (with improved cap that won’t fall off). Everything is still hunky dory. Then, something something happens, and the water bottle company releases a new version with improved base. So, all new water bottles are now version 1.3. Since your existing water bottle (version 1.0) is getting old, you buy the new version water bottle. However, you find out to your disappointment that the improved base of the new water bottle no longer works with your version 1.0 water bottle stand.

The dilemma here is that you water bottle stand (although old) is still in good shape and you have no practical reason to throw it away. However, your new water bottle (with all the new bells and whistles) does not work with the existing bottle stand. That means, you have to throw away your perfectly functional bottle stand and buy a new bottle stand (which is compatible with version 1.3). Of course, this does not mean you can happy. That’s because, next year, the same company may release a new water bottle with a much improved base, and that means you are once again back to abandoning perfectly working stuff for the latest stuff. And the cycle continues.

Anyway, hope that explained to you the concept of versions. So, dot net (which has been around for more than 15 years now) also has many versions. There is a strong connection between the version number of asp dot net and the libraries it contains. I am going to assume that you know what libraries are. If not, read one of our blog posts about it, right here.

You see, each version of dot net platform contains a set of libraries. This is just like that water bottle, which has many features attached to it. As and when Microsoft discovers something new, it will test it and then add it to the next release (with a new version number) of the dot net platform. That means, each time you see a new version released, you can expect something new feature that is designed to make your life better.

Although I have exaggerated things with my water bottle example, companies like Microsoft don’t let things to so bad when new versions are released. Microsoft almost always ensures that when a new version is released, the older stuff is still perfectly functional. Suppose you built an application with version 3.0 and the current version is 4.1. Your application will still happily run because 4.1 would have preserved everything that made 3.0 application run in the first place. A good example for this would be games that run on windows. Many games that were originally designed to run on windows XP can still run on windows 10, with minor modifications. So yeah, with Microsoft you can be sure that stuff will keep running, most of the time.

Now, a question that will bother developers is, should they constantly upgrade themselves to newer versions? The answer is an absolute yes. However, developers will (sometimes for real reasons) will complain about the constant upgrading of skills. Unless it is a major revision (like 3.X to 4.X), you will only need a few hours of reading to figure out what is new in the new version. Further, minor upgrades usually add minor components which may not be relevant to your current or even future projects.

For instance, there is a lot of talk about replacing HTTPS with some other, more secure web technology. Taking this into account, Microsoft might release a new version of asp dot net to work with that. So, you probably need to learn how to use those libraries by using msdn and stack overflow. However, if the project you are currently working at your client has no need for this new security technology, then knowing or knowing about the latest version of asp dot net will be a moot point.

At the end of the day, it comes down to this. When you are assigned a project, you will be informed which version of asp dot net you will be working on. Unless you haven’t learnt anything new in the last 3 years, you are probably in the safe. You may have to learn some new libraries but your existing knowledge will suffice. Over time, depending on what or where your next project might take you, upgrade yourself to the relevant version of asp dot net (by looking at the release notes of msdn) and be ready with it.

Follow me on twitter, facebook and instagram for more updates. Thanks!

what is asp dot net

By now, you have got your intro towards the dot net platform, and small sneak peek at c sharp. From a developer perspective, dot net platform is like a city filled with lots of people. C sharp is the language you speak. Lastly, asp dot net or simply asp, are these ‘people’ to who you speak with, make use of them, build some applications that work over the internet.

To understand asp dot net, lets look at something else that you are more familiar with. You build windows desktop applications with c sharp and XAML. You build windows phone applications with the same two combinations of tech tools. When you are thinking of building web based software (I am talking web sites, web apps, web services and whatever web-something that will come in the future), you resort to using asp dot net.

Whenever I am building an asp dot net web something, I head over to asp.net site. I would recommend you do the same because it has some excellent reading stuff.

In recent times, Microsoft has decided to branch out and give something called ‘asp dot net core’. You can read about this here.

In order to understand the full offerings of asp dot net, you also need to understand the current state of the web. There was a time when the web was just some place you went to get some information. Kind of like going to the library. You pick a book, read it, and then that is pretty much all you could do. Today though, the web is something else.

Today, if you feel like watching a movie, you could just stream it. Before, you probably had to download the video as a file, wait for it to finish downloading and then watch it.

Today, if you feel like building a photo collage, you could do it. Before, you probably had to download a photo editing software, install it and then use it.

Today, if you feel like booking a ticket, you can login to your account, do everything and get your tickets instantly. Previously, you probably had to send a form, wait for it to be processed and see where that takes you.

So, what is happening is that the web has transformed itself into (almost) like your desktop computer. A lot of things which you could only on your computer, can be done through the browser. That means, you are no longer limited to doing work on the computer at your home or office or friends house.

In the older days, if a movie was stored on computer at your home computer, that is the only place where you could watch it. Today, the movie is available online, you can watch it from any computer because it has a browser, and the browser can use your online account details to get your movie. Of course, all of this comes with a caveat. We are making an assumption that you have the necessary internet speed.

Since the web has changed to become this huge complicated monster, so also have the tools available from asp dot net to help you build. Using asp dot net, you can build a whole lot of things. Check them in depth at this link http://www.asp.net/get-started/framework

With asp dot net web sites, you can do

  • Web Pages – This is where you build simple web sites that don’t actually interact with your user. For example, our very own study nildana website is one such simple website. You can get information from it, but you cannot do anything else with it.
  • Web Forms – This is where you build a site, but you also allow some kind of interaction. Like, when you are collecting data from the user, by asking him to fill up a form. Nothing fancy but you are allowing the user to send some data in a simple form format. Think of a survey form or a application form and stuff like that.
  • MVC – The big boss, and main reason for these tutorials. MVC is where you combine all the tech to build a truly alive web alive application. Think of that video streaming website you use all the time. Or that restaurant website where you can order food through an interactive menu. All that and more is possible with asp dot net websites.

Asp dot net can also do even more cool stuff like APIs and Real Time communication. I cannot go into too much detail on that, but you can read my shot notes on these two here (APIs) and here (Real Time). Of course, you can also read about asp dot net core, here.

Adding a Model

The MVC application that you will have will work even if you don’t have a Model. And, if your web app is simply taking data from another source (like a web api) then you have no need for a database at all. In which case, you can completely bypass the M in the MVC.

However, you are almost always building some kind of a web application that needs to do the database CRUD stuff. So, you will be adding models as it please you.

Adding a model starts by you navigating to the model folder, and adding a model. You will note that this is simply a c sharp code file, and there is nothing extra special about it. Just remember that you will ensure that the class is public because visual studio for some reason makes it private by default. Or you will get an error when you define the database context.

Once you have the Model file created, you will two a minimum of two things. You will define at least one class that will represent the data you wish to store. If you go with the defaults, the names you use for the fields will also end up becoming the name that are given to the tables, columns that are generated by Entity Framework when it works with the database.

Once you have your data class defined, next comes the database context. The database context is the actual name that you will be using in the connection string. So, whatever name you use here, ensure that you will use it exactly same in the web config file.