Priyank's blog

Arrowhead Antipattern

Another common Anti-pattern is the Arrowhead Antipattern. Refactoring away from the arrowhead antipattern is as simple as swapping the conditionals, i.e. flatten conditionals statements, to leave the method as soon as possible. It is so common and so much have been written about it, I thought to just copy the links:

Controls Enable Disable Refactoring

How many times we have written such code to enable/disable controls, based on some conditions:

if (string.IsNullOrEmpty(textBoxFind.Text))
{
  buttonFindNext.Enabled = false;
  buttonReplace.Enabled = false;
  buttonReplaceAll.Enabled = false;
}
else
{
  buttonFindNext.Enabled = true;
  if (string.IsNullOrEmpty(textBoxReplace.Text))
  {
    buttonReplace.Enabled = false;
    buttonReplaceAll.Enabled = false;
  }
  else
  {
    buttonReplace.Enabled = true;
    buttonReplaceAll.Enabled = true;
  }
}

The power of refactoring?

Check out this piece of code taken from CodeProject.

bool son;

if (mShowShadow == false)
  son = false;
else
{
  if (DropShadowSupported() == false)
    son = false;
  else
  {
    son = true;
  }
}

if (son)
{
  parameters.ClassStyle += CS_DROPSHADOW;
}

The code doesn't made any sense to me, so I refactored and guess what the outcome:

if (mShowShadow && DropShadowSupported())

Free and Best System Utilities and Diagnostic Software

Advanced SystemCare Free

This utility offers a one-stop-shop for cleaning and maintaining your computer for better overall system performance. The interface is very simple, featuring only a few buttons, which makes it easy to get down to cleaning immediately (in fact, it automatically runs on start-up) and doesn't confuse you with multiple steps.

Kaspersky fails with 0 marks

I was a ardent proponent of Kaspersky until today, when I tested it with some cracks downloaded from internet (not for piracy, but for validating those cracks against my products). Though the sample size was too small (just 2 files) but from the reviews I had read about Kaspersky and its amazing price 10$ (India), I was a huge admirer of this software.

XDocument can't load a simple xml with version 1.1

using System;
using System.Xml.Linq;

class Test
{
  static void Main(string[] args)
  {
    string xml = "<?xml version=\"1.1\" ?><root><sub /></root>";
    XDocument doc = XDocument.Parse(xml);
    Console.WriteLine(doc);
  }
}

Unhandled Exception: System.Xml.XmlException: Version number '1.1' is invalid. Line 1, position 16.
  at System.Xml.XmlTextReaderImpl.Throw(Exception e)
  at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
  at System.Xml.XmlTextReaderImpl.ParseXmlDeclaration(Boolean isTextDecl)

Difference between 'ɡ' and 'g' characters?

It looks like the Microsoft developers don't allow the IPA pronunciation 'ɡ' character but allows the English language 'g' character. The IPA language 'ɡ' character is a two byte character with value: 609, whereas the English character 'g' has value: 67. This bug causes a valid SSML to throw NULL value error in the .NET Speech API. The valid IPA can be found at Wikipedia, see the Bangalore IPA (ˈbæŋɡəloːɾ)

Indian Stock Market

Indian Stock Market

Firefox addon to show the BSE or NSE sensex updates in the status bar. Can show the current sensex index and the change in the stock market index. Just right click to refresh or it will automatically refresh after every 30 minutes.



Every Build You Break

Interview with Mr. JH

Some, rather most organizations reject his CV today because he has changed jobs frequently (10 in 14 years). My friend, the job hopper™ (referred here as Mr. JH), does not mind it. well he does not need to mind it at all. Having worked full-time with 10 employer companies in just 14 years gives Mr. JH the relaxing edge that most of the company loyal™ employees are struggling for today. Today, Mr. JH too is laid off like some other 14-15 year experienced guys, the difference being the latter have just worked in 2-3 organizations in the same number of years.