Convert XML Timestamp to SQL DATETIME

Tags

, ,

I came across a situation inserting XML timestamp field to SQL DateTime field. This what I did:

DECLARE @v_XML XML
SET @v_XML = '<TimeStamp>2010-02-19T15:15:33+05:00</TimeStamp>'
SELECT @v_XML.value('xs:dateTime(/TimeStamp[1])', 'datetime');

Any other ways?
PS: If you are using the same method, please note that “xs:dateTime” has “T” upper case :)

- Happy Programming!

AnkhSVN as the Source Control Plugin for Visual Studio

I am using TFS as the source control for my daily work. But for my personal work, I like to use SVN with TortoiseSVN, because:

  1. Easy to configure
  2. Easy to use
  3. Integration with Explorer

What is missing now is the integration with Visual Studio. I found in the net about VisualSVN and AnkhSVN. I was skeptic to use AnkhSVN based on the comments available all over the place. But as it is a free option, I thought of giving a try.

Alas! I didn’t face any problem with it till the date. Its been one week after installing it.

Happy Programming!

Short vs. Long variable names

For a long time, I haven’t written any post. I was a looking for a good topic. Now I came across a post by Isaac Schlueter in “YCombinator”. So thought of sharing it.

There’s a lot of “short vs long” going on in the comments here. That seems silly to me.Code should be written so as to completely describe the program’s functionality to human readers, and only incidentally to be interpreted by computers. We have a hard time remembering short names for a long time, and we have a hard time looking at long names over and over again in a row. Additionally, short names carry a higher likelihood of collisions (since the search space is smaller), but are easier to “hold onto” for short periods of reading.

Thus, our conventions for naming things should take into consideration the limitations of the human brain. The length of a variable’s name should be proportional to the distance between its definition and its use, and inversely proportional to its frequency of use.

Global config setting that gets specified once and used in 4 places throughout the program? 10-20 characters is probably appropriate. Might wanna go with UPPER_SNAKE_CASE to make it stand out a bit more, even.

Iterator variable that you define in a 3-line for loop and then never see again outside of it? Call it “i”.

Another way to look at this: The first time you meet someone, you learn their full name. When discussing them with someone else who knows them, you use just a single name. If they’re standing right there, you don’t bother using their name, but just make eye contact, and maybe a “Hey”. Should be the same way with variables.

Read the full post and reader comments in “http://news.ycombinator.com/item?id=840331

Happy Reading!!

The Next Big Programming Idiom

We were talking about ”MapReduce, Functional Programming, Lisp” in my previous post. The question is the next big programming idiom.

In a post titled The Next Big Programming Idiom, Peter discussing this issue.

I’m not asking here which language will be the next popular language, but what programming style will be popular. Will functional programming make a comeback? Will OOP refuse to die? Or will it be something we haven’t seen before?

-Happy Reading,

Nubie

MapReduce, Functional Programming, Lisp

I have been hearing about functional programming these days.

In an article titled “Can Your Programming Language Do This?” Joel discusses about the MapReduce algorithm which makes Google so massively scalable.

According to Google,

MapReduce: Simplified Data Processing on Large Clusters
Jeffrey Dean and Sanjay Ghemawat

Abstract

MapReduce is a programming model and an associated implementation for processing and generating large data sets. Users specify a map function that processes a key/value pair to generate a set of intermediate key/value pairs, and a reduce function that merges all intermediate values associated with the same intermediate key. Many real world tasks are expressible in this model, as shown in the paper.

Programs written in this functional style are automatically parallelized and executed on a large cluster of commodity machines. The run-time system takes care of the details of partitioning the input data, scheduling the program’s execution across a set of machines, handling machine failures, and managing the required inter-machine communication. This allows programmers without any experience with parallel and distributed systems to easily utilize the resources of a large distributed system.

Our implementation of MapReduce runs on a large cluster of commodity machines and is highly scalable: a typical MapReduce computation processes many terabytes of data on thousands of machines. Programmers find the system easy to use: hundreds of MapReduce programs have been implemented and upwards of one thousand MapReduce jobs are executed on Google’s clusters every day.

But MapReduce can be implemented only using Functional Programming languages. Did I say “only”?? But how they implemented MapReduce in Google using C++?

Joel continues…

Without understanding functional programming, you can’t invent MapReduce, the algorithm that makes Google so massively scalable. The terms Map and Reduce come from Lisp and functional programming. MapReduce is, in retrospect, obvious to anyone who remembers from their 6.001-equivalent programming class that purely functional programs have no side effects and are thus trivially parallelizable. The very fact that Google invented MapReduce, and Microsoft didn’t, says something about why Microsoft is still playing catch up trying to get basic search features to work, while Google has moved on to the next problem: building Skynet^H^H^H^H^H^H the world’s largest massively parallel supercomputer. I don’t think Microsoft completely understands just how far behind they are on that wave.

 

The moral of the story is that there is a lot of interest towards functional programming. Many functional programming languages are getting attention. Some popular languages are Erlang, Microsoft F#, Haskell.

But the real hero among these languages is Lisp. Lisp is a programmable programming language which can support functional and object oriented programming.  Read The Truth About Lisp by Secret Geek and Why Isn’t Everyone Using Lisp? by Peter.

-Happy coding

Manual Software Factories

Microsoft has coined the word software factories to describe the concept of creating a customizable and extensible baseline architecture for a project to start on.

They are expecting to leverage the domain expertise and experience of senior developers by creating software factories. The software factory is a software development tool that can automate a software solution addressing a well known and described specific problem. To know more on software factories, visit: Building software factories

Be sure to read the above post before make a decision on creating a software factory. Then get Software Factory Toolkit from clarius consulting.

A medium sized company can make the software factory concept without automating it if they feel it will be costly. They can set up a team of architects, senior software engineers, and domain expertees. This team will create an initial platform for all the projects in their company. So the developers can build onthis baseline architecture. Gradually this will create a feeling of re-usable components and many of the components can be reused in the next project. Then they can automate the creationof solution and reusable components.

I don’t know whether this is a good idea or not. Nor I don’t know whether this kind of practice already exists in software industry. Sorry if I posted anything wrong :)

-Happy Coding 

IDs versus GUIDs

This week, I was trying to understand the architecture of Windows Workflow Foundation (WF). In most of the sample programs I saw, they have used WorkflowInstanceId (a Guid) as the primary key in the database. The main reason being the use of instance id in Passivation (Passivation is the term WF is using to describe the process of moving idle workflow instances to persisent storage medium like database so that the program need not be in memory while waiting for some external stimulus like user input or input from other programs). They need to know the instance id to get the program back to memory.

During that time I had situation where I need to get the data from database based on the primary key. What about writing a query statement with a where clause like “where userid=’{BAE7DF4-DDF-3RG-5TY3E3RF456AS10}’”?. It’s difficult to write like that. So I did a search to know whether I should use Guid or integer key as primary key.

No need to search it any more. Find the Coding Horror article on Primary Keys: IDs versus GUIDs

-Nubie

Follow

Get every new post delivered to your Inbox.