Wednesday, May 18, 2005

The Best .NET Products of 2005

Editors Choice Awards
ASP.NET 2.0 (Microsoft)
SQL Server 2005 Express Edition (Microsoft)

Bug & Feature Tracking
Readers Choice Award
SourceGear Vault (SourceGear)

Readers Choice Merit Awards
DevTrack (TechExcel)
IBM Rational ClearQuest (IBM Rational)

Charting & Multimedia
Readers Choice Award
Chart FX for .NET (Software FX)

Readers Choice Merit Award
WinChart (Infragistics)

Component Suites for .NET—Desktop and Web
Readers Choice Award
NetAdvantage (Infragistics)

Readers Choice Merit Award
ComponentOne Studio for .NET (ComponentOne)

Data Editing, Reporting, & Analysis Tools
Readers Choice Award
Crystal Reports (Business Objects)

Readers Choice Merit Award
ActiveReports for .NET (Data Dynamics)

Data, Network, & Web Connectivity
Readers Choice Award
IP*Works! (/n software)

Readers Choice Merit Award
Xceed Data Manipulation Suite (Xceed Software)

Development Tools
Readers Choice Award
VMware Workstation (VMware)

Readers Choice Merit Awards
CodeRush for Visual Studio .NET (Developer Express)
SlickEdit (SlickEdit)

Grid Components—Web Forms
Readers Choice Award
ComponentOne WebGrid for ASP.NET (ComponentOne)

Readers Choice Merit Award
WebGrid (Infragistics)

Grid Components—Win Forms
Readers Choice Award
WinGrid (Infragistics)

Readers Choice Merit Award
ComponentOne FlexGrid for .NET (ComponentOne)

Help Authoring
Readers Choice Award
RoboHelp (Macromedia)

Readers Choice Merit Award
ComponentOne Doc-To-Help (ComponentOne)

Imaging & Graphics
Readers Choice Award
LEADTOOLS Document Imaging Suite SDK (LEAD Technologies)

Readers Choice Merit Awards
GPS ToolKit.NET (Scientific Component)
ImagXpress (Pegasus Imaging)

Installation, Setup, & Deployment Tools
Readers Choice Award
InstallShield (Macrovision)

Readers Choice Merit Award
Wise Installation System (Wise Solutions)
ADVERTISEMENT

Instructor-Led Training
Readers Choice Award
AppDev

Middleware & Server-Based Tools
Readers Choice Award
Crystal Reports Server (Business Objects)

Readers Choice Merit Award
StarTeam (Borland)

Mobility Tools & Frameworks
Readers Choice Award
IP*Works! .NET Compact Framework Edition (/n software)

Readers Choice Merit Award
ComponentOne Studio for Mobile Devices (ComponentOne)

PDF Tools
Readers Choice Award
activePDF (activePDF)

Readers Choice Merit Award
DynamicPDF Generator for .NET (ceTe Software)

Performance, Profiling, & Debugging Tools
Readers Choice Award
DevPartner Studio (Compuware)

Readers Choice Merit Award
ANTS Profiler (Red Gate Software)

Security & Copy Protection
Readers Choice Award
DevPartner SecurityChecker (Compuware)

Readers Choice Merit Award
Dotfuscator (PreEmptive Solutions)

Software Design, Frameworks, & Modeling Tools
Readers Choice Award
IBM Rational Rose XDE Developer for Visual Studio (IBM Rational)

Readers Choice Merit Award
Visual UML (Visual Object Modelers)

UI Components—Web Forms
Readers Choice Award
ComponentOne WebMenus and WebBars for ASP.NET (ComponentOne)

Readers Choice Merit Award
WebEditor (Infragistics)

UI Components—Win Forms
Readers Choice Award
WinToolBars (Infragistics)

Readers Choice Merit Award
ComponentOne Input for .NET (ComponentOne)

Web Design & Development Tools
Readers Choice Award
Studio MX (Macromedia)

Readers Choice Merit Award
ComponentOne Studio for ASP.NET (ComponentOne)

Web Hosting
Readers Choice Awards
1&1
DiscountASP.NET

Friday, May 13, 2005

XInclude ver1.0

The World Wide Web Consortium has announced the release of XML Inclusions (XInclude) Version 1.0 as a final W3C Recommendation. Produced by members of the W3C XML Core Working Group, XInclude "provides a generic method for merging XML documents into a single composite document. Using existing XML constructs (elements, attributes and URI references), XInclude contributes to efficient content management at the enterprise level."

The W3C announcement describes XInclude 1.0 as useful "in environments without DTD (Document Type Definition) support, which are more common since the adoption of XML schemas. Unlike the mechanism used in DTDs, i.e., XML external entities, XInclude gives the content author a fallback mechanism in cases where the external document cannot be retrieved, for whatever reason. XInclude allows an application to leverage the syntax in existing XML constructs... and allows an author to choose how to include another XML document in new composite content, either as markup or text. In addition, no XML entity declarations, which were required in the older method when using DTDs, are required for XInclude."

TERM OF THE DAY: htaccess

TERM OF THE DAY: htaccess
A Web server configuration file that contains commands known by the server that tell the server how to behave in certain instances. Some of the most common uses of an htaccess file include the capability to restrict access to certain files or directories on the Internet (or intranet) through password protection.

Additionally htaccess is used to automatically redirect users, ban or allow certain IP addresses access to the server, and to call a custom designed 404 error Web rather than the standard error 404 file that usually appears in your browser.

Apache Web servers, and other NCSA compliant Web servers can use htaccess.

BPEL FAQs

Why BPEL?
A significant, industry-shaping event occurred on June 9, 2002 for web services technology. On that day, a coalition consisting of industry heavyweights IBM, Microsoft, OpenStorm and others released the Business Process Execution Language for Web Services (BPEL4WS) specification. BPEL is a 'service oriented language' that places integration and interoperability as a first order concern.


Business Value

BPEL4WS is a specification to standardize integration logic and process automation between Web Services. Process automation software is not new. However, a platform-neutral, standards-based approach using Web Services is new.

BPEL4WS is one of several new technologies and standards that have been released for Web Services. First generation Web Services enabled simple point-to-point integration using technologies like SOAP, WSDL, and UDDI. Newer technologies and standards are harnessing Web Services to create true enterprise-class business solutions that can encapsulate complex business logic while providing reliability, security and control.

The ability to deliver these enterprise capabilities while remaining platform-neutral and standards-based has caught the attention of software vendors and corporate customers alike. Of obvious interest are the huge costs savings and broad interoperability benefits that these technologies promise. Corporate strategists and enterprise architects are also enticed by the vastly improved agility and flexibility provided, enabling rapid development of new business processes and business models to capitalize on opportunities.


BPEL Foundations

BPEL4WS represents a convergence of language features from IBM's Web Service Flow Language (WSFL), who's control flow language is almost identical to IBM's MQ Series workflow language, and Microsoft's XLANG, which is used by Microsoft's BizTalk product. Both WSFL and XLANG are superseded by the BPEL4WS specification, with a range of new products leveraging the new specification under development.

In the spring of 2003, the BPEL 1.1 specification was formally submitted to the OASIS standards body. This move further ensured BPEL as the de-facto standard for web service orchestration and that the specification can be implemented on a royalty-free basis. OpenStorm was pleased to be a co-submitter of the BPEL 1.1 specification to OASIS.


Frequently Asked Questions

What is Web Service Orchestration (WSO)?

Web Service Orchestration is a category of software that facilitates application integration using web service standards. Previously, systems were integrated using proprietary solutions by vendors like Tibco, SeeBeyond, Vitria, Web Methods and others. Each vendor created their own adaptors and their own “integration logic”. These proprietary integration mechanisms have been replaced by specification-driven standards allowing customers to avoid vendor lock-in. The recent standardization of BPEL4WS has enabled a new breed of standard, interoperable integration platforms.

What is BPEL4WS?

BPEL4WS, also known as BPEL (rhymes with ripple), is an acronym for, “Business Process Execution Language for Web Services”. BPEL is the standard used to describe interactions between applications. BPEL is an XML based dialect that has strong semantics for describing message flows, asynchronous and parallel communications, and interaction with web services while leveraging the current set of XML and web service standards. BPEL is the successor to Microsoft’s XLang, which is used in BizTalk, and to IBM’s WSFL. Both XLang and WSFL will be phased out.

What kind of commands might I find in BPEL?

BPEL has commands for process flow control including While, Sequence, Pick, and Flow. It also has variables and faults. The ability to invoke web services is core, as well as the ability to listen for incoming messages from web services. Features for compensation handling, error/fault handling and event handling are built in. It contains most of the concepts found in simple scripting languages, but has a strong emphasis on working with XML, web services and long running processes.

What is an Orchestration?

An orchestration is a script that identifies partners, roles and logic to connect them all together. The orchestration script is often called a “schedule” or a process.

Why do I need to Orchestrate my web services?

Web Services have ‘contracts’ that define their capability and identify how to call them. This presents an opportunity to pipe one service into another, creating a chain of services that perform a greater function. BPEL allows one to chain together services to create an ‘aggregate service’ or to chain services together in order to manage the steps of a business process. This enables one to quickly connect a set of services in a loosely coupled, yet controlled and managed environment. As an organization matures in its use of BPEL, the orchestration scripts begin to become one of the most important artifacts. The scripts become the definition for how Web Services are connected. Orchestration scripts become a first-order artifact to identify ‘integration logic’.

Is Orchestration a type of SOI?

Yes, orchestration is a type of Web Service Based Integration. It is currently the favored means of connecting participants using open standards.

What is a Service Oriented Architecture (SOA)?

A service-oriented architecture is an architectural guideline that emphasizes communications that are:

  Message based – use of messages like SOAP with XML Schema
  Contract-based – use of interface definition languages like WSDL
  Protocol-based – use of complementary protocols like WS-I profiles

BPEL is a major participant in an SOA. In many ways, it acts as the brain of the loosely coupled system, making it all work together.

Thursday, May 12, 2005

.NET Web Services FAQs #1

Does ASP.NET support server-side includes?

Yes. Server-side includes work the same in ASP.NET as they do in ASP.



What platforms do .NET XML Web Services run on?

Currently, they're supported on Windows 2000 and Windows XP. ASP.NET integrates with Internet Information Server (IIS) and thus requires that IIS be installed. It runs on server and non-server editions of Windows 2000 and XP as long as IIS is installed.


Can two different programming languages be mixed in a single ASMX file?

No.

What is code-behind?

Code-behind allows you to associate Web Service source code written in a CLR compliant language (such as C# or VB.NET) as compiled in a separate file (typically *.asmx.cs or *.asmx.vb). You would otherwise typically find the executable code directly inserted into the .asmx file.


What event handlers can I include in Global.asax?

* Application_Start
* Application_End
* Application_AcquireRequestState
* Application_AuthenticateRequest
* Application_AuthorizeRequest
* Application_BeginRequest
* Application_Disposed
* Application_EndRequest
* Application_Error
* Application_PostRequestHandlerExecute
* Application_PreRequestHandlerExecute
* Application_PreSendRequestContent
* Application_PreSendRequestHeaders
* Application_ReleaseRequestState
* Application_ResolveRequestCache
* Application_UpdateRequestCache
* Session_Start
* Session_End

You can optionally include "On" in any of method names. For example, you can name a BeginRequest event handler Application_BeginRequest or Application_OnBeginRequest.

You can also include event handlers in Global.asax for events fired by custom HTTP modules.

Note that not all of the event handlers make sense for Web Services (they're designed for ASP.NET applications in general, whereas .NET XML Web Services are specialized instances of an ASP.NET app). For example, the Application_AuthenticateRequest and Application_AuthorizeRequest events are designed to be used with ASP.NET Forms authentication.



What namespaces are imported by default in ASMX files?

The following namespaces are imported by default. Other namespaces must be imported manually.

* System
* System.Collections
* System.ComponentModel
* System.Data
* System.Diagnostics
* System.Web
* System.Web.Services


What are ASHX files?

ASHX files contain HTTP handlers-software modules that handle raw HTTP requests received by ASP.NET. The following code institutes a simple ASP.NET HTTP handler:

<%@ WebHandler Language="C#" Class="Hello" %>

using System.Web;

public class Hello : IHttpHandler
{

public void ProcessRequest (HttpContext context)
{
string name = context.Request["Name"];
context.Response.Write ("Hello, " name);
{

public bool IsReusable
{
get { return true; }
}
}


If this code is placed in an ASHX file named Hello.ashx and requested using the URL http://.../hello.ashx?Name=Cindy, it returns "Hello, Cindy" in the HTTP response. ASHX files provide developers with a convenient way to deploy HTTP handlers without customizing Machine.config or Web.config. ASHX files can also employ code-behind just like ASPX and ASMX files.



If I want to charge for a Web service, how do I know who's calling it?

While there are probably many possible use models, the three most likely are service agreement, subscription, and per-use.

With a service agreement, you and your clients sign agreements indicating the terms of the service. These terms vary widely, as you might imagine.

Subscriptions allow your clients to access the Web Service for a given period of time or for a set number of invocations. Assuming their account remains in good standing, you continue to allow them to access your Web Service.

Per-use, of course, is billed each time the client uses the Web Service.

The key to all of these use models is authentication. You simply must know with whom it is you're dealing (or in the case of per-use, you'll want to authenticate their payment method, such as validating a credit card number with the account holder's name). Therefore, it isn't uncommon for you to require the client authenticate prior to the use of billable Web Services. That is, you provide a "login" method, or you require the client provide login-style information with the use of each Web Service. The login method would return some sort of authentication token (akin to a session token with traditional ASP.NET), and the client would then return that token to you when a billable Web Service was accessed. Conversely, they could provide their authentication information with each use (username and password, for example).

One design facet to consider is where this information is located within your SOAP packet. Using the login method and authentication token as an example, the token might be passed into a protected Web Service through either a SOAP Header or as an input parameter to the Web Service method itself. Both have benefits and drawbacks.

The benefit of placing an authentication token as a method parameter is that the client doesn't need to deal with SOAP Headers. They simply pass the token into the method, typically as a Base64-encoded string of opaque bytes. The drawback is that the authentication token isn't really a necessary input parameter if it weren't for the requirement the client authenticate. That is, the authentication token is "out of band" information to the method, or "orthogonal." For example, if you provided a Web Service that calculated the sin of a given angle, the authentication token as an input string has no significance to the sin function. This leads to oddly-factored methods that could possibly look and feel like spaghetti.

You can counter this by requiring the client to place the authentication token in a SOAP Header. SOAP Headers were specifically designed to convey such orthogonal information (this token, a transactional ID, and so forth), and they're the perfect place to stuff this ugly, Base64-encoded string. The drawback is you then require the client to deal with the creation and use of the SOAP Header, thereby increasing the code they need to write to use your Web Service as well as increasing the "pain in the...typing hand" factor.


How do I require a SOAP Header when designing my Web Service?

.NET is rich with classes and Web Service support, and SOAP Headers are but another example. Following up with the authentication theme... The first thing to do is create a class that will represent the header:

public class AuthToken : SoapHeader
{
protected string m_strAuthToken;
public AuthToken ()
{
m_strAuthToken = "";
}

public string Token
{
get { return m_strAuthToken; }
set { m_strAuthToken = value; }
}
}


As it happens, SOAP Headers within the .NET Framework are actually implemented as attributes of the Web Method. Therefore, within your Web Service class you'll create an instance of the header class that may be referenced by each interested Web Method:

public class Service1 : System.Web.Services.WebService
{
public AuthToken m_authToken;

...

[WebMethod]
[SoapHeader("m_authToken",Direction=SoapHeaderDirection.In)]
public string MyBillableWebMethod()
{
m_authToken.DidUnderstand = true; // else SoapFault!
if ( !Authenticate(m_authToken.Token) )
{
return "";
}
// Continue processing...
...
}

}


Note that we needed to inform .NET that we, in fact, did understand the SOAP header or .NET will throw the requisite SOAP Fault (if we didn't do this, to .NET's way of thinking SOAP's mustUnderstand constraint wasn't met). You will also need to provide an implementation for Authenticate() to actually validate the authentication token.


How do I provide information to the Web Service when the information is required as a SOAP Header?

The key here is the Web Service proxy you created using wsdl.exe or through Visual Studio .NET's Add Web Reference menu option. If you happen to download a WSDL file for a Web Service that requires a SOAP header, .NET will create a SoapHeader class in the proxy source file. Using the previous example:

public class Service1 : System.Web.Services.Protocols.SoapHttpClientProtocol {
public AuthToken AuthTokenValue;

...

[System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/", IsNullable=false)]
public class AuthToken : SoapHeader {
public string Token;
}
}


In this case, when you create an instance of the proxy in your main application file, you'll also create an instance of the AuthToken class and assign the string:

Service1 objSvc = new Service1();

// Create the header itself. This header will go to the
// Web Service for processing
objSvc.AuthTokenValue = new AuthToken();
objSvc.AuthTokenValue.Token = ;

// Call the Web Service

string strResult = objSvc.MyBillableWebMethod();


.NET will make sure the SOAP Header is created and filled with the authentication token's value (for this example).

ASP.NET FAQs # 1

What platforms does ASP.NET run on?

Currently, it's supported on Windows 2000 and Windows XP. ASP.NET integrates with Internet Information Server (IIS) and thus requires that IIS be installed. It runs on server and non-server editions of Windows 2000 and XP as long as IIS is installed. Microsoft originally planned to support ASP.NET on Windows NT 4.0, but had to reconsider due to time and technical constraints.

Can two different programming languages be mixed in a single ASPX file?

No. ASP.NET uses parsers to strip the code from ASPX files and copy it to temporary files containing derived Page classes, and a given parser understands only one language.

Why can't I put <%@ Page Language="C " %> at the top of an ASPX file and write my server-side scripts in C ?

Because the parsers ASP.NET uses to extract code from ASPX files only understand C#, Visual Basic.NET, and JScript.NET. However, if you use code-behind to get your code out of the ASPX file and into a separately compiled source code file. You can write server-side scripts in any language supported by a .NET compiler.

Can I use code-behind with Global.asax files?

Yes. Here's a simple Global.asax file that doesn't use code-behind:

<%@ Import Namespace="System.Data" %>




Here's the equivalent file written to use code-behind:

<%@ Application Inherits="MyApp" %>


And here's the MyApp class that it references:

using System.Web;
using System.Data;

public class MyApp : HttpApplication
{
public void Application_Start ()
{
DataSet ds = new DataSet ();
ds.ReadXml ("GlobalData.xml");
Application["GlobalData"] = ds;
}
}


So that ASP.NET can find the MyApp class, compile it into a DLL (csc /t:library filename.cs) and place it in the application root's bin subdirectory.

Can you override method="post" in a
tag by writing ?
Yes.

Can an ASPX file contain more than one form marked runat="server"?
No.

Is it possible to see the code that ASP.NET generates from an ASPX file?

Yes. Enable debugging by including a <%@ Page Debug="true" %> directive in the ASPX file or a statement in Web.config. Then look for the generated CS or VB file in a subdirectory underneath \%SystemRoot%\Microsoft.NET\Framework\v1.0.nnnn\Temporary ASP.NET Files.


Does ASP.NET support server-side object tags?

Yes. The following tag creates an instance of a custom type named ShoppingCart and assigns it session scope (that is, it creates a unique ShoppingCart instance for each and every session created on the server):



Managed types created this way are identified by class name. Unmanaged types (COM classes) are identified by CLSID or ProgID.



How do I comment out statements in ASPX files?

<%--

--%>

Can I use custom .NET data types in a Web form?

Yes. Place the DLL containing the type in the application root's bin directory and ASP.NET will automatically load the DLL when the type is referenced.

Tips # 1

Tip 1 :
Use The Call Stack Window To Set Breakpoints
If you are buried way down deep in your application during a debugging session and you want to quickly go back up the call stack, open the Call Stack window, highlight the function you want to return to and hit your breakpoint key (F9 by default). The Visual C debugger allows you to set breakpoints in the Call Stack window.

Tip 2 :
The Undocumented Pointer Array Expansion Format Code
If a pointer to an array only expands to a single item, the undocumented numerical format specifier will force the expansion. For example, if you have a LPDWORD pointer, pVals, that points to an array of 10 items, you can display all ten by entering "pVals,10" in the watch window. The number after the comma tells the watch window how many items to display.

Tip 3 :
Get Rid of the MSDEV Splash Screen When Using Just in Time Debugging
1. Run REGEDIT and open the key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug.2. Change the Debugger key from "\msdev.exe -p %ld -e %ld" to "\msdev.exe -nologo -p %ld -e %ld".

Tip 4 :
Populate DataSets with XML Files
Want to populate an ADO.NET DataSet with data from an XML file? It's easy; here's how:

DataSet ds = new DataSet ();
ds.ReadXml (new FileStream ("Credentials.xml", FileMode.Open, FileAccess.Read));

This example passes the XML file's file name (Credentials.xml) to FileStream's constructor, and then passes the resultant FileStream to the DataSet's ReadXml method. What's really cool is that the DataSet will infer a schema from the contents of the XML file and structure itself accordingly. You can even modify the data and write it back out with WriteXml.

Tip 5 :
Building Stand-Alone ATL COM Servers
If you use ATL to build COM servers, you should know that there are two steps required to build a truly stand-alone ATL COM server--that is, one that has no DLL dependencies.
Step 1 is to choose Release Min Dependency as your build type.
Step 2 is to make sure that the preprocessor symbol _ATL_STATIC_REGISTRY is defined. The latter statically links your server to the ATL component registrar and allows it to self-register on machines that don't have Atl.dll installed on them. _ATL_STATIC_REGISTRY is defined by default for Release Min Dependency builds in Visual C 6.0, but not in 5.0.

Tip 6 :
Fix ATL COM Classes That Won't Register
Have you ever written a COM server with the Active Template Library (ATL) and discovered that one or more of the COM classes inside it doesn't register when the server self-registers? If so, check the server's object map for a missing OBJECT_ENTRY statement. A bug in Visual C sometimes prevents ATL COM classes added with the ATL Object Wizard from being added to the object map, and if it's not in the object map, then it won't register.

Tip 7 :
Path Name Parsing Made Easy with Regex
Remember how painful it was in the old days to write code that split a path name into its component parts? If you're writing .NET code, splitting path names is easy thanks to a handy little class named Regex that's one of many thousands of classes in the .NET Framework Class Library. Here's an example:

Regex regex = new Regex (@"\\");
string[] parts = regex.Split (@"C:\Inetpub\wwwroot\AshiSystems");
foreach (string part in parts)
Console.WriteLine (part);

Run this code in a console app and it will display the individual substrings that make up the path name.

Tip 7 :
Move ASP.NET Session State to an External Process
One of the many features that makes ASP.NET better than ASP is the way it manages session state. By default, ASP.NET session state is stored in the same process as ASP.NET applications. But a simple configuration change lets you move session state to an external "state server" process that will survive IIS restarts. You can even run the state server on a separate machine, in which case session state will survive even if the machine hosting the ASP.NET application goes down completely. For beta testers running recent (post-Beta 1) builds of ASP.NET, here's how to make the configuration change:
1) Create a text file named Web.config. Add the following text to it and copy the file to the directory where your ASP.NET application resides:



mode="stateserver"
stateConnectionString="tcpip=localhost:42424"
/>



2) Open a command prompt window and type NET START ASPNET_STATE to start the state server. Your application should now run as before, but if it uses session state, that state in now created in an external process named Aspnet_state.exe.
You can prove that session state stored this way is more robust by starting and stopping IIS. Any data you tucked into session state before IIS was restarted will still be there after the restart. For even greater robustness, you can change "localhost" to an IP address to move session state to a remote machine.


Tip 7 :
Send E-Mail From .NET Applications
Want to send an e-mail message from a .NET app? It's easy using the MailMessage and SmtpMail classes found in the System.Web.Mail namespace. Here's an example written in C#:

using System.Web.Mail;
.
.
.
MailMessage message = new MailMessage ();
message.From = "webmaster@AshiSystems.com";
message.To = "luckywinner@somewhere.com";
message.Subject = "You Win!";
message.Body = "You have won the state lottery! To claim your prize, do a handstand on one hand and "
"count backwards from 1,000,000 to 1";
SmtpMail.Send (message);

Note that this code is valid for Beta 2 of the .NET Framework SDK, but not for Beta 1. Also, you must include a reference to the System.Web.dll assembly when you compile.

Tip 8 :
Use StringBuilder to Build Strings Efficiently
It's easy to build strings on the fly using C# and other .NET programming languages. The following code fragment builds a string that counts from 1 to 99:

string s = "";
for (int j=1; j<=99; j++) {
s += j.ToString ();
s += ", ";
}

This code works, but it's slow. Why? Because in .NET, strings are instances of System.String, and System.Strings are immutable. Each time you use the = operator to append text to a string, a new string is created and text is copied from the old string to the new. To build strings on the fly and to do so efficiently, use the .NET Framework Class Library's StringBuilder class, which is found in the System.Text namespace. The following code fragment produces the same string as the code above, but does so in less than half the time:

StringBuilder sb = new StringBuilder ();
for (int j=1; j<=99; j++) {
sb.Append (j.ToString ());
sb.Append (", ");
}
string s = sb.ToString ();

For an additional performance boost, you can override a StringBuilder's default capacity (enough to hold only 16 characters)
and preallocate the memory required to build the new string by passing an integer value specifying the StringBuilder's capacity to StringBuilder's constructor.

Monday, May 09, 2005

Test Driven Development Articles and Tutorials

I expect that we could invest what is in effect a week of training in just teaching unit testing techniques and tools. At the end of the week some coverage of TDD, the benefits, approaches, and how the unit testing fits in could be delivered. I skimmed through a Unit Testing Patterns description that someone sent a link to recently. If their were 12 patterns, and an hour was spent discussing the unit testing pattern and another was spent performing a lab to apply the pattern then 24 out of the 40 hours would be consumed. Here is a list of the patterns described in that one article:

Pass/Fail Patterns
  • The Simple-Test Pattern

  • The Code-Path Pattern

  • The Parameter-Range Pattern

  • Data Driven Test Patterns
  • The Simple-Test-Data Pattern

  • The Data-Transformation-Test Pattern

  • Data Transaction Patterns
  • The Simple-Data-I/O Pattern

  • The Constraint-Data Pattern

  • The Rollback Pattern

  • Collection Management Patterns
  • The Collection-Order Pattern

  • The Enumeration Pattern

  • The Collection-Constraint Pattern

  • The Collection-Indexing Pattern

  • Performance Patterns
  • The Performance-Test Pattern

  • Process Patterns
  • The Process-Sequence Pattern

  • The Process-State Pattern

  • The Process-Rule Pattern

  • Simulation Patterns
  • Mock-Object Pattern

  • The Service-Simulation Pattern

  • The Bit-Error-Simulation Pattern

  • The Component-Simulation Pattern

  • Multithreading Patterns
  • The Signalled Pattern

  • The Deadlock-Resolution Pattern

  • Stress-Test Patterns
  • The Bulk-Data-Stress-Test Pattern

  • The Resource-Stress-Test Pattern

  • The Loading-Test Pattern

  • Presentation Layer Patterns
  • The View-State Test Pattern

  • The Model-State Test Pattern