Moving To The Cloud

For some interesting reading, range about the Internet for articles detailing the way the software world has changed in the past few years with the success of companies like Facebook and similarly ubiquitous, social-node technologies. Those companies have fostered the advent of the DevOps strategy, which is more a paradigm shift in corporate culture than merely a mechanical development/quality assurance/deployment strategy, and it demonstrates a new way of thinking about deployment scaling using the cloud (with an unbelievable number of servers available) while maintaining an aggressive development schedule. Sprint-cycle application development and cloud-based deployment are the order of the day for these newer entities. No longer does dev sit in a development cycle of a year or more, but rather a cycle that is measured in months at most, or weeks – even days. Getting customer-requested features quickly into the product and out to the customers is still job one, but – Oh, hey! – the difference in implementation! Ben Horowitz Article “How Software Testing Has Changed”
Continue reading

How To Add Or Change XML Encoding With .NET

Last time I wrote about comparing XML strings in .NET, and continuing that theme I’d like to discuss another handy XML trick.  As the last article pointed out, not all XML strings are created equal.  In fact, sometimes they are missing the necessary XML version and encoding information, like in the following sample XML:

    <SampleField2 value="test value" />
    <SampleField3 type="int">456</SampleField3>

Notice anything missing?   Yes, the declaration information is not at the start of the XML string.  Declaration information like in the below example:

<?xml version="1.0" encoding="utf-8"?>

Continue reading

How to minify your JavaScript files and why you shouldn’t wait

It is common in fast responsive web apps to minify JavaScript files to reduce file size and increase app performance.

What is it?
Minification means to remove all unnecessary characters (e.g. comments, spacing, line breaks, shortening names, etc.) from a JavaScript file so that the resulting file behaves the same but is much more compact.

Why should you minify your JavaScript files?
Here are some benefits:
– Faster load speed
– Small files and cache size
– Less demand on your web server
– Uses less bandwidth especially on mobile devices

How to minify your JavaScript files with two popular tools: Continue reading

Creating Case Insensitive Dictionaries In .NET

For millennia, mankind has looked to the stars and wondered, “How can I create a generic Dictionary in .NET that allows me use case insensitive strings as keys?” Well today that age old question will be answered with this neat trick.

Simply put, all you need to do is add a StringComparer object when constructing a generic Dictionary that uses a string key, and make sure to use on of the IgnoreCase StringComparers that are offered. Below is some sample code to illustrate just how easy this is.

// Create a generic dictionary with a string comparer that ignores case sensitivity.
// This includes the following:
//  - CurrentCultureIgnoreCase
//  - InvariantCultureIgnoreCase
//  - OrdinalIgnoreCase
Dictionary<string, string> stringMap = 
     new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
stringMap.Add("Test Key", "Some value");

// Now try to access or change the corresponding value with the key.
// The case of the key string no longer matters.
stringMap["test key"] = "This will work";
stringMap["TEST KEY"] = "And also this";
stringMap["tEsT kEy"] = "And this as well";
stringMap["tEST kEY"] = "And finally this";

// This can be done with any dictionary that uses a string as the key
Dictionary<string, int> numberMap = 
     new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
numberMap.Add("Test Key", 0);

// Same deal here, you can use any case to get or set the values in the map
numberMap["test key"] = 1;
numberMap["TEST KEY"] = 2;
numberMap["tEsT kEy"] = 3;
numberMap["tEST kEY"] = 4;

And that’s all there is to it.  I hope you enjoy and find this useful.

Richard Franzen
ImageSource, Inc.

What Johnny Cash, stolen cars & software development have in common

“Now the headlights they was another sight
We had two on the left and one on the right
But when we pulled out the switch all three of ‘em come on.”
– Johnny Cash
“One Piece at a Time”

Many years ago, Johnny Cash sang a song called “One Piece at a Time”, in which he describes an automobile assembly plant worker stealing parts and pieces of various automobiles and assembling them into a very distinctive, one-of-a-kind car.

Given the nature of software, the essence of which is some form of code, building software is somewhat like putting that car together.  Technology evolves over time, operating systems change, and new tools all contribute to the complex process of building an application.  Code is pieced together in files and modules, and the output of the code in the form of log files and/or visual display on a monitor are the effects of the code.  When building an engine, putting on the heads and bolting up the crankshaft before attaching the pistons and connecting rods isn’t recommended.  Similarly, software designers aren’t always able to see all the parts until there is a basic framework constructed, and limitations of the system come to light.  Re-designing components and restructuring development schedules are not uncommon. Continue reading

Update UI controls form background worker

When you try to update an UI control from background worker, you might see this error message.

Cross-thread operation not valid: Control ‘MyLabel’ accessed from a thread other than the thread it was created on.

This is how you update UI controls from background worker.

public void UpdateLabel(string text)
MyLabel.Invoke((Action)(() => MyLabel.Text = text));
   MyLabel.Invoke((Action)(() => MyLabel.Update()));


Using SQL Parameters for Insert statement.

Sometimes you need to insert a data to your database. Here is the safer way to insert a row using SQL parameter.
Passing parameters to SQL prevents you build dynamic SQL statement. Building a dynamic SQL statement is a security risk such as SQL injection.
Here is the sample code for insert statement using parameters.

public void InsertRowToDatabaseUsingParams()
//create SQL connection.
using (SqlConnection conn = new SqlConnection(connectionString))
//open sql connection.
string sqlCommand = "Insert into TestTable (column1,column2) Values(@column1,@column2);";

using (SqlCommand cmd = new SqlCommand(sqlCommand, conn))
//add column value to parameters of SqlCommand
SqlParameter param = new SqlParameter("@column1", SqlDbType.VarChar, 50);
param.Value ="value1";

param =new SqlParameter("@column2", SqlDbType.VarChar, 50);
param.Value ="value2";



Kyoungsu Do
Software Developer
ImageSource, Inc.