Archive

Archive for July, 2006

Nice article about Test First Development

July 21, 2006 Leave a comment

Timothy King has really nice entry about Test First Development

<quote>Why do programmers hate writing unit tests? Why do they hate even more writing unit tests before coding?

Most software developers have never seriously tried test-first.So they come up with excuses: “We don’t have time to write unit tests.”

Actually It’s faster than writing code without tests! Or to put it another way, skipping unit tests is faster, unless you actually need the code to work. Most of the effort we spend on code, we spend fixing it after we’ve checked it in to the source-code repository. But test-first eliminates much of that waste by allowing us to get more of it right to start with and by making bugs easier to fix.</quote>

Read more here

http://www.jtse.com/blog/2006/07/11/twelve-benefits-of-writing-unit-tests-first?t=xp

 

About thoughtworks

July 11, 2006 1 comment
Well well well, ‘ The other big ugly involves the work. Sometimes there’s no getting away from the fact that the work that’s available just isn’t the most interesting there is.’
Something which I wasn’t expecting over there.
May be the otherside of the river is always green 😀
 
Don’t stop here read the other plusses posted by Simon Stewart.
Categories: .NET Framework

VB.NET and the ‘/’ operator

July 11, 2006 2 comments

Program 1: What is the output?

Sub Main()

Try

Dim a As Integer

Dim b As Integer

Dim c As Integer

a = 1

b = 0

c = a / b

Catch ex As DivideByZeroException

Console.WriteLine("Divide by zero error!")

Catch oex As OverflowException

Console.WriteLine("Overflow error!")

End Try

Console.ReadLine()

End Sub

Program 2: What is the output?

Sub Main()

Try

Dim a As Decimal

Dim b As Integer

Dim c As Integer

a = 1

b = 0

c = a / b

Catch ex As DivideByZeroException

Console.WriteLine("Divide by zero error!")

Catch oex As OverflowException

Console.WriteLine("Overflow error!")

End Try

Console.ReadLine()

End Sub

Surprise, I was really bounced by this one. Via buddhike’s blog

Categories: .NET Framework

Talking about SQL Server Questions 9

July 10, 2006 Leave a comment

This guys has lot of posts / questions. Worth a book(blog)mark

Quote

SQL Server Questions 9

Sort Order
Binary is the fastest sorting order, and is case-sensitive. If Binary is selected, the Case-sensitive, Accent-sensitive, Kana-sensitive, and Width-sensitive options are not available.

Sort order

Description

Binary

Sorts and compares data in Microsoft® SQL Server™ tables based on the bit patterns defined for each character. Binary sort order is case-sensitive, that is lowercase precedes uppercase, and accent-sensitive. This is the fastest sorting order.
If this option is not selected, SQL Server follows sorting and comparison rules as defined in dictionaries for the associated language or alphabet.

Case-sensitive

Specifies that SQL Server distinguish between uppercase and lowercase letters.
If not selected, SQL Server considers the uppercase and lowercase versions of letters to be equal. SQL Server does not define whether lowercase letters sort lower or higher in relation to uppercase letters when Case-sensitive is not selected.

Accent-sensitive

Specifies that SQL Server distinguish between accented and unaccented characters. For example, ‘a’ is not equal to ‘á’.
If not selected, SQL Server considers the accented and unaccented versions of letters to be equal.

Kana-sensitive

Specifies that SQL Server distinguish between the two types of Japanese kana characters: Hiragana and Katakana.
If not selected, SQL Server considers Hiragana and Katakana characters to be equal.

Width-sensitive

Specifies that SQL Server distinguish between a single-byte character (half-width) and the same character when represented as a double-byte character (full-width).
If not selected, SQL Server considers the single-byte and double-byte representation of the same character to be equal.

 

1.        What is the STUFF Function and how does it differ from the REPLACE function?
STUFF – Deletes a specified length of characters and inserts another set of characters at a specified starting point.
SELECT STUFF(‘abcdef’, 2, 3, ‘ijklmn’)
GO
Here is the result set:
---------

aijklmnef

REPLACE – Replaces all occurrences of the second given string expression in the first string expression with a third expression.
SELECT REPLACE(‘abcdefghicde’,’cde’,’xxx’)
GO

Here is the result set:
————
abxxxfghixxx

2        What does it mean to have quoted_identifier on? What are the implications of having it off?
When SET QUOTED_IDENTIFIER is OFF (default), literal strings in expressions can be delimited by single or double quotation marks.
When SET QUOTED_IDENTIFIER is ON, all strings delimited by double quotation marks are interpreted as object identifiers. Therefore, quoted identifiers do not have to follow the Transact-SQL rules for identifiers.
SET QUOTED_IDENTIFIER must be ON when creating or manipulating indexes on computed columns or indexed views. If SET QUOTED_IDENTIFIER is OFF, CREATE, UPDATE, INSERT, and DELETE statements on tables with indexes on computed columns or indexed views will fail.
The SQL Server ODBC driver and Microsoft OLE DB Provider for SQL Server automatically set QUOTED_IDENTIFIER to ON when connecting.
When a stored procedure is created, the SET QUOTED_IDENTIFIER and SET ANSI_NULLS settings are captured and used for subsequent invocations of that stored procedure. When executed inside a stored procedure, the setting of SET QUOTED_IDENTIFIER is not changed.
SET QUOTED_IDENTIFIER OFF
GO
— Attempt to create a table with a reserved keyword as a name
— should fail.
CREATE TABLE "select" ("identity" int IDENTITY, "order" int)
GO

SET QUOTED_IDENTIFIER ON
GO
— Will succeed.
CREATE TABLE "select" ("identity" int IDENTITY, "order" int)
GO

3.        What is the purpose of UPDATE STATISTICS?
Updates information about the distribution of key values for one or more statistics groups (collections) in the specified table or indexed view.

4.        What is a tuple?
A tuple is an instance of data within a relational database.

5.        sp_configure commands?
Displays or changes global configuration settings for the current server.

6.     What is the basic functions for master, msdb, tempdb databases?
Microsoft® SQL Server 2000 systems have four system databases:

·         master – The master database records all of the system level information for a SQL Server system. It records all login accounts and all system configuration settings. master is the database that records the existence of all other databases, including the location of the database files.

·         tempdbtempdb holds all temporary tables and temporary stored procedures. It also fills any other temporary storage needs such as work tables generated by SQL Server. tempdb is re-created every time SQL Server is started so the system starts with a clean copy of the database.
By default, tempdb autogrows as needed while SQL Server is running. If the size defined for tempdb is small, part of your system processing load may be taken up with autogrowing tempdb to the size needed to support your workload each time to restart SQL Server. You can avoid this overhead by using ALTER DATABASE to increase the size of tempdb.

·         model – The model database is used as the template for all databases created on a system. When a CREATE DATABASE statement is issued, the first part of the database is created by copying in the contents of the model database, then the remainder of the new database is filled with empty pages. Because tempdb is created every time SQL Server is started, the model database must always exist on a SQL Server system.

·         msdb – The msdb database is used by SQL Server Agent for scheduling alerts and jobs, and recording operators.

7.     What are sequence diagrams? What you will get out of this sequence diagrams?
Sequence diagrams document the interactions between classes to achieve a result, such as a use case. Because UML is designed for object-oriented programming, these communications between classes are known as messages. The sequence diagram lists objects horizontally, and time vertically, and models these messages over time.

8.     What are the new features of SQL 2000 than SQL 7? What are the new datatypes in sql?

·         XML Support – The relational database engine can return data as Extensible Markup Language (XML) documents. Additionally, XML can also be used to insert, update, and delete values in the database. (for xml raw – to retrieve output as xml type)

·         User-Defined Functions – The programmability of Transact-SQL can be extended by creating your own Transact-SQL functions. A user-defined function can return either a scalar value or a table.

·         Indexed Views – Indexed views can significantly improve the performance of an application where queries frequently perform certain joins or aggregations. An indexed view allows indexes to be created on views, where the result set of the view is stored and indexed in the database.

·         New Data Types – SQL Server 2000 introduces three new data types. bigint is an 8-byte integer type. sql_variant is a type that allows the storage of data values of different data types. table is a type that allows applications to store results temporarily for later use. It is supported for variables, and as the return type for user-defined functions.

·         INSTEAD OF and AFTER Triggers – INSTEAD OF triggers are executed instead of the triggering action (for example, INSERT, UPDATE, DELETE). They can also be defined on views, in which case they greatly extend the types of updates a view can support. AFTER triggers fire after the triggering action. SQL Server 2000 introduces the ability to specify which AFTER triggers fire first and last.

·         Multiple Instances of SQL Server – SQL Server 2000 supports running multiple instances of the relational database engine on the same computer. Each computer can run one instance of the relational database engine from SQL Server version 6.5 or 7.0, along with one or more instances of the database engine from SQL Server 2000. Each instance has its own set of system and user databases.

·         Index Enhancements – You can now create indexes on computed columns. You can specify whether indexes are built in ascending or descending order, and if the database engine should use parallel scanning and sorting during index creation.

9.     How do we open SQL Server in single user mode?
We can accomplish this in any of the three ways given below :-

 .         From Command Prompt :-
sqlservr -m

a.        From Startup Options :-
Go to SQL Server Properties by right-clicking on the Server name in the
Enterprise
manager.
Under the ‘General’ tab, click on ‘Startup Parameters’.
Enter a value of -m in the Parameter.

b.       From Registry :-
Go to HKEY_LOCAL_MACHINESoftwareMicrosoftMSSQLServerMSSQLServerParameters.
Add new string value.
Specify the ‘Name’ as SQLArg(n) & ‘Data’ as -m.
Where n is the argument number in the list of arguments.

10.     What is Log Shipping?
In Microsoft® SQL Server™ 2000 Enterprise Edition, you can use log shipping to feed transaction logs from one database to another on a constant basis. Continually backing up the transaction logs from a source database and then copying and restoring the logs to a destination database keeps the destination database synchronized with the source database. This allows you to have a backup server and also provides a way to offload query processing from the main computer (the source server) to read-only destination servers.

 

19.     How can I convert data in a Microsoft Access table into XML format?
The following applications can help you convert Access data into XML format: Access 2002, ADO 2.5, and SQLXML. Access 2002 (part of Microsoft Office XP) enables you to query or save a table in XML format. You might be able to automate this process. ADO 2.5 and later enables you to open the data into a recordset, then persist the recordset in XML format, as the following code shows:

rs.Save "c:rs.xml", adPersistXML
You can use linked servers to add the Access database to your SQL Server 2000 database so you can run queries from within SQL Server to retrieve data. Then, through HTTP, you can use the SQLXML technology to extract the Access data in the XML format you want.

20.     @@IDENTITY ?
Ans: Returns the last-inserted identity value.

 

Categories: Uncategorized

Understanding WS-Policy

July 10, 2006 Leave a comment
Categories: Great Links

Agile and Fixed Bid projects

July 10, 2006 Leave a comment
I have been adding a lot of book(blog)marks recently.
I donno when i am really going to read all these, but here we go – Another one
I vaguely remember discussiing this with Prakash on one of his presentations.
 
Categories: Great Links

Using Active Record As A Rule Engine

July 10, 2006 Leave a comment
Manu, if you read this, let me know if this is good enough.
 
Categories: Great Links

A(n intelligent) Regular Expression tool

July 10, 2006 Leave a comment
Promising tool, especially if you work with regular expressions
Categories: Great Links

Type Mocks – .NET Mock Framework

July 10, 2006 Leave a comment
Interesting, have to check this out in future
Categories: Great Links

Guidance Explorer

July 4, 2006 Leave a comment
This guidance stuff, looks like a major section of P&P group is focussing on it.
 
"Guidance Explorer is a tool to find and use relevant patterns & practices guidance. Guidance Explorer installs with a guidance library including performance and security topics for .NET and ASP.NET applications. The guidance library contains checklists and guidelines covering design, implementation and deployment topics. The tool and the library will evolve over time to include additional types of guidance. "