Category: Code

SWIFT: Implicitly Wrapped Optionals

Just a quick explanation of how an implicitly wrapped optional can be used. Logically, I would think optional variables are probably more computationally expensive than a normal variable (IMO because it is a fatter object, did not research). So, as far as it goes, it would be best to declare a normal variable in cases where it can not be… Read more →

Android: Singleton vs ApplicationContext

Well here’s a topic that’s hotly debated in Android design. Technically, both of them could work for rapid development. However, I prefer Method B as you can modularize your singletons to support specific functions in each class definition. Best if you can work without them, but its often not the case. Method A – Extending Application Context Step 1: Create… Read more →

MySQL command via shell script (using variables in SQL)

Running mysql commands on the shell is pretty simple. However, things can get tricky if you need to enclose variables within those aprostophes in your script. Spend some time trying to figure this out. The short sample code below shows how it can be done. Note the cats on “echo $1“. Hope this helps you as well.

Read more →

Shadowing vs Hiding vs Overriding

In C#, it is easy to confuse hiding with overriding. Both are ways to change the implementation of elements from a base class. But there are some significant differences between the two. A further confusion steps in with the term shadowing. Shadowing is a VB concept. In C#, this concept is called hiding, though there is a subtle difference between… Read more →

Multi-threading in C Sharp (C#)

Threading is fun, because with it you can do a lot more stuff at the same time. For example, keeping your UI updated while your background tasks are running. C# supports parallel execution of code through multi-threading. A thread is an independent execution path, able to run simultaneously with other threads. Here, we examine three simple C# approaches to help… Read more →