jay's old blog

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

Developer Tips – Sticky Notes and One Note and Word to Augment Documentation

I am always going on and on about documentation. That’s my jam because I know and have experienced how much things get delayed and messed up when there is no documentation. I have worked on projects large and small, and one thing is for certain. For years now, we are living in an economy where rarely do enterprising individuals will go through at least five employers in their career. Further, people like, work for at least five different employers in any given year. That means, folks who work are constantly on the move. Work gets paused, and then it gets resumed, and that is how it works.

On an individual level, this happens a lot as well. I myself am juggling half a dozen projects – work and personal – at any given point of time. There is no possible way I can remember what I was doing on project A 2 days ago because I am now neck deep in Project B and Project C. The human brain is not designed for memory storage. It is designed for processing.

To that effect, today, I thought I will blog about the many note taking tools I use for my own work, to keep things documented for efficient work flow for myself and for others.

Sticky Notes

All windows computers come built in with sticky notes. The concept of sticky notes (just like the real sticky notes, which is also something I use in my daily life) is simply. Open up a quick note taking page, and start typing anything and everything. Prior to discovering sticky notes, I was using notepad, but notepad has some problems. The problem is that it was designed in an era when everything had to have a menu bar, and it has extremely poor formatting and it does not auto save.

The sticky notes, in some ways, is like a more advanced version of notepad. It auto saves. It is quick to launch and retains formatting. It also has some neat colors, which I don’t know, brightens up my day.

I normally use sticky notes when I am researching something, developing something or working out a problem. Here, the priority is quick note taking, copy pasting and such.

One Note

Sticky Notes is nice, but if it has one flaw, it is that it does sync with other devices. I love working across multiple devices. Even as I write, I have like at least 6 devices around me, which are all cloud enabled. At a given point of time, I may decide to read or write something on any of those devices. I don’t wish to have that uncertainty where something I wanted to mull over is not available.

That is where OneNote comes into the picture. OneNote is like a book binder, which holds multiple books and each book can have unlimited sections, and unlimited pages. It’s also free. It is available on every platform imaginable.

However, I wont trust OneNote to do quick note taking. For that, I exclusively use sticky notes. OneNote is more long term where in all the research is already done and now I want to push it to the cloud. Usually, stuff that is to be stored permanently will move from sticky notes to OneNote. Quick Note taking is not an option on OneNote because it is heavy, and hence slow. For long term note storage, OneNote is excellent because it has excellent syncing, formatting, organizing and sharing features.


Microsoft (who also make OneNote) makes another entry in my documentation tools via their productivity extraordinaire, Microsoft Word. Together – sticky notes and OneNote – take care of all my note taking needs. So, where does Word come into the picture?

Sometimes (actually a lot of times) a lot of stuff needs to be shared, in a proper format with others. Sometimes, it simply makes sense to have something in an easily readable format. This actually happens more often than you think. Most importantly, it is impossible to assume that other people (or unknown devices) have sticky notes or OneNote. However, most of the time folks will have Microsoft Word (or something similar) installed on their work machine.

Along with this, Microsoft has made an excellent job of integrating the cloud with its flagship productivity software. So, it all syncs up on OneDrive, which itself comes with simple version of Word in the browser. To me, that is the best of both worlds. When these conditions are satisfied, it is best to use Word over sticky notes and OneNote.


Obviously, there are alternatives available for those who don’t wish to use the above. There are quite a few replacements available for sticky notes and they all probably have better tools. Much of them free, and they integrate with windows, mac or linux, no problem.

For OneNote, the only alternative I would recommend is Evernote. I have used Evernote, but they are a paid service for advanced features. So, I am not using that. Not when OneNote gives me everything Evernote can give and I don’t have to create one more account.

For Word, there is LibreOffice which is quite good. Google Docs is also okay, but it runs in a browser and I really don’t want to tie my productivity to a browser based app all the time. It simply does not gel well with me. For the cloud, I have recommended OneDrive above. Alternatives are Google Drive and Dropbox, and here, I would rather you go with the latter.

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

Version Control and Git – Part Three

A long time ago (like 6 months ago) I promised that I would complete my git aka version control tutorial. Looks like I get to finally do it. Meanwhile, you can find the first two parts, here and here.

This post talks about actual usage, while the earlier ones talked about some other stuff. There are two things happening here. One, is the online repository. There are many folks who provide repository services, and I use Bitbucket. You can create a free account at them, and they allow any number of repos. Further, they also provide private and public repos. So, that is good because some services don’t allow private repos without having to fork out a lot of money.

So, you will visit Bitbucket website and then create an account. I won’t write how to create an account, because if you want steps for that, you should probably not be a developer. After the account is created, you can create teams (and then add members). You can create projects, and then within projects, you can create repos. All this is pretty self-explanatory once your account on bitbucket is ready.

Once a new account is created, there are two scenarios – you already have code on your programming PC, or you are starting from scratch. Right now, I am looking at the first scenario because that is the most likely scenario for those who begin code on the PC and then wish to push it to the online repo.

Start at the online dashboard of bitbucket. Create a repo. You should probably create a project folder first, and then, create a new repo. This allows better organization as you begin working on multiple projects.

So yeah, you use the ‘create a new repository’ option and will be presented with the standard set of options.

·         Choose an owner – this is useful if you are part of a team. Choose a repo you own, or a repo that will become part of a team, and hence available to team members.

·         Choose project – the repo will become part of a project. Choose a project of your choice, or create a new project.

·         Repo name – the repo name of your choice. As always, try and use meaningful names.

·         Private or Public repo – self explanatory

·         Repo type – use Git. I don’t know much about the other option, which is mercurial.

Once you create a repo, the site should give you two options (and two links with actual steps). Use the first option, which is about mapping existing code files online. Here is a sample of what you might see.

  1. Step 1: Switch to your repository's directory

cd /path/to/your/repo

  1. Step 2: Connect your existing repository to Bitbucket

git remote add origin https://Jay_sn@bitbucket.org/thechalakas/testforblog.git

git push -u origin master

As you can see from the above commands, it is clear that these are the commands we must use on your work PC to get things moving. Now that this is ready in the web browser, it’s time to shift our focus to your PC.

Start off by getting the necessary tools from this link. https://www.git-scm.com/downloads

If you are feeling like a small baby, you can also download the GUI tools, which is okay.

Once you have installed the GIT SCM tools, you should have the git tools installed in your PC. Hopefully, you checked the box that says command line integration. If not, you better go back and do it. After the whole thing is setup, under applications, find ‘git bash’ and open it.

Now, use the step 1 and step 2 from above. Unless the solution is already initiated with the ‘repo’ stuff, the steps will not work and will give an error. To see if git is actually setup for your code files, I always use ‘git status’ command. If git is not setup, you will get this.

fatal: Not a git repository (or any of the parent directories): .git

So, you go ahead and initiate the whole git thing by using ‘git init’. This will do some stuff, and then, you should try ‘git status’ and you should get a different set of things. Mostly in red color. You see, the red color files and folders are those that are now detected by git. The red color means, the files are not being ‘tracked’ for changes. This is of course what we want because the whole point of version control or git is to track what changes you are doing to the code.

Right now I am going to assume that you wish to track everything in this code folder of yours. So, you will use the command ‘git add *’. This will add everything to be ‘tracked’. Now if you try, ‘git status’, boom, all the files will be in green. That’s the universal color for go, so we are good to go. Green also means, we are good to commit stuff, which is another way of saying, we are on the right direction to push things to the online repo.

Before we can push, we must commit the changes. For the now, the biggest change is the new file that has been detected. So, use the command ‘git commit’. This will bring up a ‘vi editor’ which will be familiar to you. If you are not familiar, then, perhaps you should not be practicing for a career in programming. Here, you will write some commit notes (by using a combination of Esc key, arrow keys, a key and i key, and constantly using Esc key, until you figure things out) and then save and quit the vi editor using ‘wq’.

Once you do wq, you are back in the command line, and the committing is done. Now, its time to push. As per the two steps from above, we should set the origin. So, lets do that by using a command that looks something like this.

git remote add origin https://Jay_sn@bitbucket.org/thechalakas/testforblog.git

Since this is the first time you are doing this, you will be prompted for a username and password. That will be your bitbucket login information. Once you do that, the command should work as expected, and then, you are back to the command line. Note that we are still setting things up, so the code is still not yet pushed to the online repo. Now, as per the two steps above, we need to actually push stuff.

 For that, we will use a command that looks something like this.

git push -u origin master

Now, you will get some internet upload type stuff. Depending on the number of files you have, this could take a while. If you are on a slow internet connection, this could take a serious amount. While you are waiting for this to finish, here are some things you can think about.

·         How productive is it to watch a movie while programming?

·         Is it better to work with 2 monitors or 3 monitors?

·         Will there ever be a sequel to Mad Max Fury Road?

·         If you two mice are connected to the same PC, and moved at the same time, which will be given priority while deciding cursor movement on the PC?

Okay, has the code been pushed online? Good. Now, go back to the bitbucket repo in the browser, and you will see all the code which was on your PC, a copy of it, is now online. This was the setting up part.

Now comes the actual usage part. On your PC, go ahead and make some changes to the code file. Or multiple files. Either way is fine. Once again, do ‘git status’. You will see the files you made changes to, in red color. As before, you need to add the file you wish to commit and push. I will simply do ‘git add *’ for I wish to add all files. Then, try ‘git status’ and make sure that the files you wish to push are in green. Now do the ‘git commit’, go through the whole vi editor save and quit thing, and then use ‘git push’. Once again, you should see the whole commit upload files thing happening.

Now, if you are using multiple PCs, it is possible that when you push stuff, you will get some unknown name on the repo. This is a high possibility. In which case, on the web bitbucket page, the name should be attached as an alias to your actual account. Do this and you will get your name (or whoever is doing the commit) in the alias connecting page. Of course, only admins can do it. If you created the repo, then you are obviously the admin. If you are working with someone else’s repo, then ask them to do it for you.

Alright then, good luck on your journey to become a better developer.

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

The Appeal and Non-Appeal Of Becoming A Web Developer

One of the many nice things about being a trainer is that I get to understand what is happening with folks, because when certain technologies are demanded, I get enquiries about stuff they wish to learn. That, indirectly, ties into what are the technologies being used. Over the last few months, the number of enquiries related to building apps that run within a web, in other words, web apps, are picking up speed. I must have dealt with at least a dozen students who asked for some work of web development training which involved either dot net, or one of the many Javascript libraries or a combination of both.

That makes me ask a question, one that gets asked a lot by students, why become a web developer? Alternatively, the question also implies, why not become a web developer? I will try to explain the situation to the best of my ability.

First up, web development is going to only increase in relevance as time grows. That is tied to the growth of mobile devices. Come to think of it, mobile devices are like everywhere now. At the same time, larger screen devices aren’t going anywhere. I use mobile devices, tablets, desktop PC and laptops with varying time spent, to get my work done and earn a living. A lot of times, I am using some variation of the same service to get work done.

That is where web apps become important. The appeal of web apps is that they run using the rules established for web browsers. That thing about web browsers is that they have a web engine, which in turn can work with these rules and regulations (or technology framework or web platform or…well, there are just so many words) and get things to work. This means, as long as this ‘web engine’ is running, the web app would run. This is where all those ‘hybrid’ apps and development tools become suddenly relevant. Hybrid apps are those that are (usually, because the web is such a stickler for using all kind of crazy words without standardizing it first) build using web technologies (HTML, CSS and many many Javascript libraries) and then deployed as apps. You could, technically, build a code, that can then run on the browser, android, iOS platforms with minimal changes.

This is where the opportunity to become a web developer arises. Let’s talk about the good stuff first. Unlike say, android development or windows development or iOS development, the tools needed to learn web development are pretty simple. An old laptop that costs less than rupees 10000 can be used (with some tradeoffs) to learn essential web development. That’s kind of neat isn’t it? When I started windows phone development, I spent a fortune (Windows Pro license, windows phone, a PC that can run the emulator, the developer license) to actually start learning the whole thing.

With web development, the costs of actual development are low. Along with this, the actual time it takes to learn web development is also on the lower side. The bedrocks of web development – HTML, CSS and JavaScript – are quite easy to become familiar with. A decent student, with enough dedication can become familiar enough to write basic apps in a matter of months. Becoming an expert is another story altogether.

With the mobile devices becoming truly ever prevalent and now in everybody and their mother’s hands, there is dearth of work. That means, even decent skills is enough to land some kind of employment. This is all the good stuff.

The two bad stuff, can get pretty sad for everybody involved. There is such a thing called platform diversity. You know how there are so many versions of android that plays havoc with android developers? You know how game developers complain about developing for windows, when compared to building for a Xbox One? Again, diversity of platform is the problem. Now expand that to include the web engine which should run on everything from PCs to mobiles to tablets to mobile devices. Then, there are so many operating systems. Even the same browser will exhibit different behavior on different platforms. Then, screen resolutions that vary like crazy. This is what is called a messed up kitchen, and this is also where you look at things and go, ‘This is Heavy doc!’!!!

As if this is not enough, there must be dozens of JavaScript libraries out there. Every company wants people to use their own library. Facebook wants people to use React JS. Microsoft wants people to use TypeScript. Then there is jQuery, which has its own agenda. Don’t forget the visual enhancements provided by Bootstrap which also does some script work. There is also good old JavaScript which does a lot of things. Then, there are modules that are in turn used by these libraries, and many of them are self-tested with or without update support.

When I think about all this, all I can think of is a house of cards. It gets scary, and that is why developers should be scared. Or at least worried. There is just too much to keep track of, and more importantly, you never when something (like a module, or a library) will suddenly become not available, and then your app simply stops working! This happens with any software, but at least with a windows environment or an android, there is a big company in charge, which can usually provide some kind of a normalcy by fixing things.

With web, everybody owns some piece of something. In other words, when things go bad, nobody will take responsibility or will not be required take ownership. It can get crazy, but the web is a crazy world.

The second problem is an offshoot of the lower learning costs that I talked about. When costs are low, the barriers of entry also reduce. That means, more people will try and become part of the party. When there are too many people standing in queue to join a party (that is looking for employment) the party organizers (in this case organizers) have more choice. More choice means less pay. This also means less security when it comes to jobs. Given the ever changing nature of the web, folks who just finished learning something must be ready to learn again, or else, someone younger, cheaper and equipped with the latest skills will replace them. Heck, automation (the irony being that they were build using these web languages) itself will begin replacing developers!

If you are looking to enter this crazy world of web development, the key is to look at how talented or desperate you are. If it is the former, you will make a killing. If it is the latter, god help you.

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

Async and Await Revisited - Update 1

I have already written about async, here. yet, thought I will just revisit here.

The thing is about async and await is all about improving responsiveness. What is responsiveness though? In different context, it takes on different meanings. In a website, the ability to move content around to suit the screen size is responsiveness. You see this a lot in mobile websites which also look equally good on desktop. In a application though, responsiveness comes down to the ability to keep the user engaged when stuff is happening in the background.

A simple everyday application activity is waiting for a photo to load. There would be a photo area, which will be surrounded by the usual application buttons and options. While the photo loads, the rest of the application should still be usable. Perhaps a loading screen with a percentage to show what is happening. Stuff like this is what async and await is all about. It is about making sure that the thread that manages the user interface is able to isolate itself from other stuff such as data queries and processing of data which is happening in the background.

This is the whole point of writing asynchronous code. keeping things from freezing or becoming unresponsive when stuff takes longer than expected.

To this effect, c sharp provides the async and await keywords. These keywords allow a particular method to be marked for the benefit of the compiler, indicating that stuff that follows will be asynchronous. Then, the compiler can go ahead create the necessary task related code. This is the key stuff about async and await. It takes the load off the developer from having to write actual asynchronous code, reducing errors in the process. This also means, all that stuff you know from reading about tasks and threads will come in handy here as well.

As always, find the code sample for this entry at my repo.

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

Threads and Tasks Revisited - Update 1

I have already written about threads and tasks here, here, here, here, here and here. I thought, perhaps it is time to revisit those topics.

Tasks and threads in c sharp are interconnecting concepts. Both allow you to build an application that can mimic the behavior of a multi threaded application. The idea behind any multitasking application is the same. There is just too much power at disposal and by switching them fast, you are able to give the impression that many things are happening at the same time. Perhaps the best example would be when you are driving. Obviously, your eye is on the road, but your hands are on the wheel, your legs on the breaks. While driving, you are able to glance at the speed, fuel level, and so on, all without ever stopping the  vehicle itself. You are doing many things at once, however they are not happening in a parallel fashion. Your attention does go from the road to the speed dial and come back, fast.

Same things happen in applications. Most computers today have super fast processors. It is possible to ask these processors to work with multiple 'thread' and make them do many things at a given unit of time, like per minute or per hour or per day. That is where threads and tasks come into the picture.

The primary difference between threads and tasks is the amount of control you have. With a thread, you simply assign stuff to another thread, and that's pretty much it. Threads do not return stuff, which make it 'not so easy' to use them when you are trying to make things happen after something has happened. You could say, a thread is like a one way street. Stuff goes away from you, but nothing comes back. With tasks, you have an option to keep track of things.

You use threads when you dont want to have extra control over the multi threading you are attempting to do. You use tasks when you want that extra control. Almost in all real life situations, you will end up tasks and threads. Also, when using tasks, you end up using a lot of lambda expressions as well.

As always, find the code at my bit bucket repo right here.

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

Weak References

We have been discussing memory stuff for a while now. One last topic (for now) when working with memory are weak references.  

You know how if a item in the memory is 'live' (being referenced by a root item) it will never be cleared by the garbage collector. This is good because you don’t want to lose reference to something that is currently being used. However, what if you are working with large list that your project is using? Large lists (that are still referenced) will take up a lot of memory. Keeping them in the memory may be good in theory but the performance hit (memory usage) might not be worth it.  

Perhaps you don’t mind if these objects are cleared from memory everytime a garbage collection happens. If they are lost, its okay. You can just run another query from where you can simply build a new list and have it populated. You could simply check if it is still in memory before using it. If it is, you use it from memory. If it is not in memory, you simply load the stuff from the server or a file or from wherever the list was originally populated. 

The use case for this is pretty straightforward. If your application frequently uses lists that become populated with lots of data (and the list itself gets very long) it may become easier – performance wise - to simply reload the list rather than keep it in memory.  

Since I have not yet started blogging about lists, I am just going to leave the code out of this post for now. 

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

Strings and stuff

Can you think of any program where you don’t use a string? I cannot. We are constantly working with strings. When learning programming, the first thing that we do is write the 'hello world' program which is about displaying a string. When working with web services, and data comes back in json, it’s a string. Everything and anything can be represented as a string. Numbers, decimals, date, weather, temperature and you name it. All of them can be represented as strings.  

That is why c sharp has a lot of  string related stuff to help you, the developer, reduce the workload related to playing with strings. Almost anything and everything related to strings (manipulating them, traversing them, building them and so on) is already available in .net and c sharp.  

Other blog posts will spend a little more time on focusing on specific string related features. Here, I want to emphasize on one simple thing. That is the fact that strings are immutable. What does that mean really? The thing is, once you create a string (and assign a value to it) it cannot be modified. It's sort of like a tattoo. It's set in shape until it dies.  

So, when you do  

string hello_world = "hello world";  

The string "hello world" will remain as its until it is no longer referenced and garbage collected. That means, the following statement will make you think. 

Hello_world_2 = hello_world + "there"; 

When executing this statement, a new string is created called "there". Then, the contents of "hello world" and "there" are copied over to another new string which will eventually contain "hello world there". Why did two new strings created instead of the original string modifying itself from "hello world" to "hello world there"? That would be simpler isn't it?  

On the outset, it would be simpler. However, the property of being immutable makes sure that the string object cannot be modified. This is a better way of dealing with strings because, as a developer, I know that once a string is created, it cannot be modified by any part of the program. This certainty allows me build thread save string related applications.  

I have not attached any doe to this blog post. We have already used strings many times in many our previous code repos.

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


When discussing the basics of string earlier, I mentioned how each time you try to append a string to an existing string, a new string gets created.  

string hello_world = "hello world"; 

string hello_world2 = hello_world + "there"  

The second statement actually creates two new strings to make "hello world there" 

What if you do something like this 

for (int I =0;i<100;i++) 

hello_world_2 = hello_world2 + hello_world; 

By the time the loop finishes, a 100 string objects would have been created. That is crazy and is not practical in many scenarios. In fact I cannot imagine any scenario when this would be considered appropriate.  

When you are doing something like this, you use a StringBuilder, as the name suggests, maintains a buffer internally. So, when you append a string, it will join the buffer instead of creating a new string.  

Find code demonstrating the string builder. 

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

String Formatting

Ah! The most useful part of displaying stuff. The thing is string formatting is a topic on its own. Like, you could keep getting better at it and there would still be something to write about.  


One of the first things I use when formatting a string is using the {position} thing. When you want to display a string which has to intersped with variable values, you may choose to concatenate them. This could get cumbersome when you wish to include too many variables. That is when you can use {} and you put a location value at that spot.  

The number inside the brackets indicates the location of the parameters on the right side of the console writeline. 

Culture Info 

The 'culture info' is an option that allows you to let the string method automatically display information in a culturally relevant way. For instance, when the culture is set to 'en-US' and a currency is being displayed, the string will be automatically formatted as dollars. This also applies to stuff like date and time which are all culturally sensitive 

formatting key 

Now, there is no such thing as a formatting key. I am just making this word because depending on the key, the display will change just like it does when a culture info component is attached. 

custom formatting key 

By default, some components have a default key to use. Like date objects have 'd', 'D', 'M' which accordingly change the display.  

Just like those formatting keys, you can build your own formatting keys that can be used to decide how the display works. Of course, you will use them with the tostring() definition.  

As always, you can check our code here that shows all these in action.

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

String – Formatting – ToString

Another cool thing about string is that it has a default implementation of toString method. You have already seen this in action in many of our code samples. Just to refresh, if you were to use the tostring method with an int, you will get a string representation of that int value.  

Now, that is pretty cool. The same string method is available for every type (and hence all its objects) that you define. By default, it simply gives the type of the object. However, you are happy to override it, and make it give any string that you want. It is normal practice to give a string representation of your object. This is particularly useful when you are building json services or when you want other objects to get a string equivalent of the object in question.  

Of course, find the code that does this here.

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