About Me

My photo
Northglenn, Colorado, United States
I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).

Friday, September 28, 2007

Choosing a programming language...

An interesting checklist to follow when starting out in computer science or developing one skills to get hired.

1) Is it a standards based language?

You will want to develop your skills in a language that is either supported very well or is a standard. Example of languages that have standards: C++, C#, C, Ada, Eiffel, Fortran, ECMAScript...

2) Does the language have strong corporate or community support?

An ideal language will have enough support for the following reason:



  • Career Placement - it is very important to be able to market yourself. Learning or honing your skills in a language that is dead or soon to be will limit your options. Go to a popular job searching website, like dice.com and do a search on your programming language. See how many hits do you get. Also while viewing the popularity of the language, also view what other support is needed for that job. For example, HTML might return a lot of hits, but usually there will be other web development requirements that follow such as javascript, asp.net, ajax, php, etc..


  • Developing Skills - when searching for a language it is also important to see how much support there is in developing your skills. Does the language come with some sort of Integrated Development Environment (IDE). The IDE should be easy to use, support multiple roles (developer, database, etc..), support tools (addins), support commercial interest (Game Design, App Development, Web Development, ...), and also implement features that make development less of a hassle.

3) What are you interested in developing?

Some languages are better suited for certain styles of commercial interest. A language that is suitable for game design, might not be the best for web development. While, some languages are solely used for a single purpose, like artificial intelligence, database design, etc... others are not. Some languages, such as C#, have a wide spectrum of uses that can be useful if you are having trouble fitting toward one type of interest. For example, if you want to develop window applications and develop interesting web pages.

4) How productive/robust is the language?

At this point, you might still have a list of several languages still to consider. One thing to look into is how productive and robust is the language. Some languages are very robust allowing you to have more options for developing more intrigued items, but it might take longer to develop in that environment. Some languages that are more productive will allow for quick turnover, but might be limited in what can be done.

You might also have to consider what other support the language might have from other languages. In web development: a language like javascript is a great support to other languages that don't have as much power. While asp.net might be very powerful on the server side, it needs the help of javascript to do some more robust options on the client side.

5) Do you want to be versatile/portable?

As you probably have noticed, that some languages are platform dependent. Developing in a language that is only supported toward one type of operating system, web browser, etc... is a tough decision. This is basically limiting your audience, or upsetting your users (like Linux users who have to switch over to Windows)

While a operating system like Windows is the most popular, do you want to also develop for *nix, Apple, HP, etc... Some languages are designed only for one operating system, while others are more versatile. Languages that are versatile and easily portable can be tougher to develop with. A language like C would probably work on most operating systems, but at a price where it is somewhat limited and tough to learn to develop with.

6) How easy is it to do maintenance?

A language that is maintainable is a very nice luxury. To be able to update, clean, and apply easy documentation should be something to look for to help save time (and money).

For example, in C# 2.0, a nice feature that is noticeable is when changing the name of a variable. The IDE basically ask the programmer if it is OK to go through the whole project, where the variable is in scope, if it should change the name there as well. In past, I would have to use a search and replace while stepping through each one checking if it should be replaced, or use a regular expression to limit the search pattern.

With that all said, I hope this is a decent check list to help find and target a language. It should be said, that some languages are easier to learn, if given a background in other languages.

A language like C was a gateway to other popular languages like C++, C#, Python, Java, etc... A programmer that learned one of these languages will have a quicker learning curve when introduce to these other languages. This might be a factor as the days of the C has been dieing down, but a programmer with this knowledge had a easier time switching to a more popular language and not becoming obsolete. Compare this to a language like COBAL which is not very popular and doesn't have any transition language that I know of.

Some steps when converting Dynamic tsql to Static

Here is a list of things to keep in mind when converting dynamic tsql stored procedures into a static version (for performance enhancement).

1) Remove quotes (carefully). - Going through and eliminated the outside quotes is the easy part. You do have to be careful of the single inner quotes, for example a single quote(s) might be necessary in a varchar statement.

2) Look over the convert statements. - A majority of the convert statements, especially the converting to varchar will need to be looked over and possibly removed in most cases.

3) Replace variables that dealt with parsing. - Some stored procedures might be sending in multiple data into one variable for example @Y = ('1,2,3,4,5') and being accessed like: WHERE x in @Y. This will need to be replaced with either a PATINDEX or CHARINDEX.

4) Remove unnecessary declarations - Some variables are going to end up not being used now, for example the varchar variable that was used to make the dynamic tsql string.



These are the tips, I might remember some more and add them later.

Thursday, September 27, 2007

Interesing line count of MS Dev Products

Code sizes:
• Visual Studio 2005: 7.5 million lines
• SQL Server 2005: 3 million lines
• BizTalk Server: 2 million lines
• Visual Studio Team System: 1.7 million lines
• Windows Presentation Foundation: 900K lines
• Windows SharePoint Services: 750K lines
• Expression Blend: 250K lines
• SharePoint Portal Server: 200K lines
• Content Management Server: 100K lines
• Dynamics SL has 3.4 million Lines

Biztalk Apps

Here are some BizTalk apps that can be used to make development easier.

BizTalk SSO Configuration Data Storage Tool (http://seroter.wordpress.com/2007/09/21/biztalk-sso-configuration-data-storage-tool/) - A Single Sign-On App that sets access permissions for applications, account groups, etc..

CodePlex's BizTalk Open Source Apps (http://www.codeplex.com/Project/ProjectDirectory.aspx?TagName=BizTalk) - Dissambler, MicroSoft ESB Guidance, automated testing, distributed systems, biztalk server 2006 documenter, pipeline component wizard, tcpip adapter, wcf adapter, biztalk server 2006 orchestration profiler, biztalk extensions, pattern wizard, adapter wizard, lifecycle management, solution kits, app software factory, map tester, host configurator for applications, powershell, counters, etc........

Tuesday, September 25, 2007

Progressive Development Blog

Here is an interesting blog, that discusses some issues that I and others always love to argue/debate over. It makes for an interesting read.

http://blogs.msdn.com/progressive_development/default.aspx

Friday, September 21, 2007

Quick Reminder: Parsing in T-Sql

When a set of values are sent in as a varchar and need to be parsed. Ex: '1,2,3,4'
In this example the values are sent into the stored procedure's variable @atInvNum.

DECLARE @aInvNum varchar(4000)

SET @aInvNum = LTRIM(RTRIM(@atInvNum))
DECLARE @pos INT
DECLARE @piece varchar(500)

DECLARE @tInvNum TABLE (ID int)

IF right(rtrim(@aInvNum),1) <> ','
SET @aInvNum = @aInvNum + ','

SET @pos = patindex('%,%' , @aInvNum)
WHILE @pos <> 0
BEGIN
SET @piece = left(@aInvNum, @pos - 1)

INSERT INTO @tInvNum SELECT cast(@piece as int)

SET @aInvNum = stuff(@aInvNum, 1, @pos, '')
SET @pos = patindex('%,%' , @aInvNum)
END


---------------------A better way---------------------

IF (LEN(RTRIM(LTRIM(@atTaskIDs))) > 0)
SET @atTaskIDs = ',' + @atTaskIDs + ','

CHARINDEX(',' + Convert(varchar, SRT.TASK_ID) + ',', @atTaskIDs) > 0 )

Thursday, September 20, 2007

Regular Expression App

I made a quick and simple app that would allow me to open a file and run regular expressions on to it. I also implmented a replacement, so if you wanted to run replacements on the file it would be easily done.

http://williamandrus.tripod.com/RegEx.html

Wednesday, September 12, 2007

Reminder: Bulk insert through a store procedure

Ok, my problem was I had a large collection of item; where each item is suppose to be inserted in a database and I didn't want to do a bulkcopy.

This is accomplished by using XML in the store procedure and sending it in through the ADO.Net

In the C# code:

//Make xml
using (SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["connectionString"]))
{
   SqlCommand cmd = new SqlCommand("insBulkFTSEDCFileDetail", conn);
   cmd.CommandType = CommandType.StoredProcedure;
   StringBuilder sb = new StringBuilder();
   sb.Append("\r\n");
   foreach (oEDCItem item in edc)
   {
      sb.AppendFormat("\r\n",
      item.ModuleName, item.PartNumber, item.SerialNumber, item.TestPosition, item.SupplierName, item.EDC, item.Opt);
}
   sb.Append("
");

   cmd.Parameters.AddRange(new SqlParameter[] {
   new SqlParameter("@EDCFileID", EDCFileID),
   new SqlParameter("@LastUpdateUserID", UserID),
   new SqlParameter("@XMLDOC", sb.ToString())});

   conn.Open();
   cmd.ExecuteNonQuery();
   conn.Close();
}



The stored procedure:

Create Procedure insBulkFTSEDCFileDetail
{
   @EDCFileID int,
   @LastUpdateUserID int,
   @XMLDOC varchar(MAX)
}
AS

DECLARE @xml_handle int

EXEC sp_XML_preparedocument @xml_handle OUTPUT, @XMLDOC

INSERT INTO [TABLE]
(EDCFileID,
ItemType,
Model,
SerialNumber,
EDCPosition,
SupplierName,
EDC,
Options,
LastUpdateDate,
LastUpdateUserID)

SELECT @EDCFileID,
EDCXML.ItemType,
EDCXML.Model,
EDCXML.SerialNumber,
EDCXML.EDCPosition,
EDCXML.SupplierName,
EDCXML.EDC,
EDCXML.Options,
getUTCDate(),
@LastUpdateUserID
FROM OPENXML( @xml_handle, '/EDCItems/EDCItem')
WITH ( ItemType varchar(8),
Model varchar(50),
SerialNumber varchar(50),
EDCPosition varchar(50),
SupplierName varchar(50),
EDC varchar(50),
Options varchar(80)) AS EDCXML

EXEC sp_XML_removedocument @xml_handle

Tuesday, September 11, 2007

Quick reminder: Implement ICallbackEventHandler

A quick reference on how to implement ICallbackEventHandler instead of using the new Ajax, do it old-school style.

The page source (client-side):

<script language="javascript" type="text/javascript">
function Save()
{
   var message = '';
   var context = '';
<%=sCallBackFunctionInvocation%>
}
function Result(result, context)
{
   if(result != 'ok')
   alert("Error: " + result + "\n\nFile was not saved.");
}
function OnError(message, context)
{
   alert('An unhandled exception has occurred:\n' + message);
}
</script>


The code-behind (server-side):

public partial class EDCWUC : System.Web.UI.UserControl, ICallbackEventHandler
{
   public string sCallBackFunctionInvocation;
   protected void Page_Load(object sender, EventArgs e)
   {
   sCallBackFunctionInvocation = this.Page.ClientScript.GetCallbackEventReference(this, "message", "Result", "context", true);

   }

   #region ICallbackEventHandler Members
   public string GetCallbackResult()
   {
      return sCallBackFunctionInvocation;
   }

   public void RaiseCallbackEvent(string eventArgument)
   {
      sCallBackFunctionInvocation = DoServerSideEvent();
   }
   #endregion
}

A good hint: If you need to do several callbacks, then set it up so that the eventArgument sends in the function name with its values, then all you need to do is split it, get the function name and send in the necessary values
For example:
FunctionName;<uniqueDelimeter>;Values

Saturday, September 08, 2007

Some Interview Questions given to me in the past.

1. What is a PostBack?
2. What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?
3. Demonstrate definition of a property in a class (in c#)
4. Demonstrate populating a dropdownlist from an xml file (in c#)
5. How do you assign a static IP Address to a Windows 2003 Server?
6. Draw out what the outcome of an Inner Join, Left Outer Join and Right Outer Join would be on two tables.
7. How would you access the database connection strings from a web.config file in VS 2003 and VS 2005?
8. Where would you setup “Impersonation” and when would it be a good time to use it?
9. How many static IP Addresses can a Windows 2003 Server have?
10. A client needs a web page that collects the following: first name, last name, phone number and then pushes the data to them via email. Please provide sample code of a form that sends that data to the client.
11. Demonstrate in Asp.Net how to pull a remote user’s IP Address, Referring URL, and the [cookieid] from a user’s machine for domain [SAN].
12. Please provide an example of a time when you have ever used web services.
13. How would you go about debugging a web service SOAP Message?
14. How do you view the methods and properties of a web service within Visual Studio?















1) What is a postback?

http://www.xefteri.com/articles/show.cfm?id=18 does a nice job in explaining what a postback is, in detail.

In my own words: In a standard postback a web page, with a web form is submitted and then processed on the server-side. The server-side then updates the page on the client-side by reposting the data. This is usually seen with something similar to a page refresh. (Which is why, if you are buying something on the web, it's a good idea not to hit refresh button or it would duplicate the last sent request.)

Now with, javascript and nowadays Ajax, it isn't necessary to refresh the whole page. It is possible to just refresh a certain control, allowing the user to see updated information without refreshing and redrawing other controls.



2) What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?

In my own words:
A viewstate is a serializable hashtable of objects that are used to store information on the client-side. During a postback, the informatin is then used on the server-side before reposting to the client-side. This allows the data found in controls like a textbox to be repoulated, or to use the viewstate to store global variables which can be reused.

A viewstate is stored in base64, and encryption by default is set to auto. This means, as long as no control in the form does not need encryption, then the whole viewstate is unencrypted; otherwise the whole viewstate is encrypted. You can set the view state for each page:

<%@Page ViewStateEncryptionMode="Always" %>

, or you can set it for the whole website by using the web.config:

<configuration>
<system.web>
<pages ViewStateEncryptionMode="Always" />
</system.web>
</configuration>


3) Demonstrate definition of a property in a class

class MyClass
{
private string _name = “”;

public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
}


4) Demonstrate populating a dropdownlist from an xml file


Not tested:

XML file:

<library>
<book>
<author>Dietel & Dietel</author>
<title>C how to program</title>
</book>
<book>
<author>William Shakespare</author>
</book>
</library>


XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("Library.xml"));
XmlNodeList nodeList = doc.SelectNodes("library/book/"); //xslt path
foreach(XmlNode node in nodeList)
{
DropDownListTitle.Items.Add(new ListItem(node.SelectSingleNode("title").InnerText));
}


5) How do you assign a static IP Address to a Windows 2003 Server?

I personally don't know much about setting up servers, I'm a developer. So, I look it up:
http://technet2.microsoft.com/windowsserver/en/library/36c35b2c-8b8b-4517-812e-913a60ff551d1033.mspx?mfr=true

The basic info provided:

To configure TCP/IP for static addressing
1.
Open Network Connections.
2.
Right-click the network connection you want to configure, and then click Properties.
3.
On the General tab (for a local area connection) or the Networking tab (for all other connections), click Internet Protocol (TCP/IP), and then click Properties.
4.
Click Use the following IP address, and do one of the following:

For a local area connection, in IP address, Subnet mask, and Default gateway, type the IP address, subnet mask, and default gateway addresses.

For all other connections, in IP address, type the IP address.
5.
Click Use the following DNS server addresses.
6.
In Preferred DNS server and Alternate DNS server, type the primary and secondary DNS server addresses.








6) Draw out what the outcome of an Inner Join, Left Outer Join and Right Outer Join would be on two tables.

Can't draw







7) How would you access the database connection strings from a web.config file in VS 2005? (Don't care about VS 2003 anymore :P )

This question really sucks, I wish it was more specific.
If I just need to look it up, I would just open the web.config file and look in the appSetting tag:

<appSettings>
<add key="sqlConn" value="Server=myPc;Database=Northwind" />
<add key="smtpServer" value="smtp.mydomain.com" />
</appSettings>

If I need to access it in the program:

this.sqlConnection1.ConnectionString = ((string)( System.Configuration.ConfigurationSettings.AppSettings.GetValues("sqlConn.ConnectionString"))));


8) Where would you setup “Impersonation” and when would it be a good time to use it?
"When using impersonation, ASP.NET applications can optionally execute with the identity of the client on whose behalf they are operating. The usual reason for doing this is to avoid dealing with authentication and authorization issues in the ASP.NET application code. Instead, you rely on Internet Information Services (IIS) to authenticate the user and either pass an authenticated token to the ASP.NET application or, if unable to authenticate the user, pass an unauthenticated token. "
In the web.config:
<identity impersonate="true"/>
http://west-wind.com/weblog/posts/1572.aspx goes in nice detail on how to access information that is not allowed with the standard asp.net permissions.

Tuesday, September 04, 2007

Lorem Ipsum

I was curious about "Lorem Ipsum", since I have seen this as a subsitution for dummy text. It's a very interesting read.

The use of using this text for dummy text has been around since 1500, which was taken from a book "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC.

http://www.lipsum.com/

What is also cool about this site, it has a Lorem Ipsum generator.