October 2006 - Posts

There are many sayings about assumptions and I’ll let you fill in your favorite.  Regarding Systems Integration, the hard lesson I’ve learned is not to assume the other system will properly filter or handle a specific constraint.  For example, Windows systems use a carriage-return-line-feed to mark the end-of-a-line.  However, UNIX systems simply use a line-feed to mark the end-of-a-line.  This is not to say that UNIX systems can’t handle files containing CRLF’s.  It just means that most UNIX Systems just use an LF to mark the end-of-a-line.

 

When writing code to integrate a Windows based system and a UNIX based system that transfers data through a file based feed, noting and handling this simple end-of-line difference can save much time and yes stress.  Having a simple tool like NotePad2 in your arsenal is a great way to inspect your feed at various stages to ensure compatibility between the systems.

 

NotePad2 (http://www.flos-freeware.ch/notepad2.html) is a small, powerful replacement editor for “NotePad” which comes with Microsoft Windows.  This tool is worth a look especially for its ability to show hidden characters such as those marking the end-of-line.

 

To handle the case described above I would recommend implementing a simple scrubber that removes carriage returns (CR's) from the end of each line before sending the file to the UNIX System.  Here is an example scrubber:

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
using System.IO;
using System.Text.RegularExpressions;

public class UnixStripperActivity
{
public static void SripCarriageReturn(string filePath)
{
string output;
FileStream fs = File.OpenRead(filePath);
StreamReader reader = new StreamReader(fs);
string input = reader.ReadToEnd();
reader.Close();
fs.Close();
output = Regex.Replace(input, @"\r", "", RegexOptions.Multiline);
FileStream fsw = File.OpenWrite(filePath);
StreamWriter sw = new StreamWriter(fsw);
sw.Write(output);
sw.Close();
fsw.Close();
}
}

 

1
2
3
4
5
6
7
8
9
10
11
select 
[name] As IndexName,
type_desc,
space_used_in_kb = (page_count * 8.0),
space_used_in_mb = (page_count * 8.0 / 1024.0)
from
sys.indexes I
inner join
sys.dm_db_index_physical_stats(db_id(), object_id('.'), null, null, null) P on I.[object_id] = P.[object_id] and I.[index_id] = P.[index_id]
Order By
  space_used_in_kb desc

1
2
3
4
5
6
SELECT [IssueHistoryID]
,[StafferID]
,[IssueID]
,[Comment]
,[DateCreated]
FROM [IssueVision].[dbo].[IssueHistory]

This Simple query was created from a demo Microsoft Smart Client Application called IssueVision.  To create it I right clicked on IssueHistory table in SQL Server Management Studio 2005.  Notice the commas are all to the left of the column names.  Commonly, I see queries written like this instead:

1
2
3
4
5
6
SELECT [IssueHistoryID],
[StafferID],
[IssueID],
[Comment],
[DateCreated]
FROM [IssueVision].[dbo].[IssueHistory]

The first example with the commas on the left is faster to debug and modify. Notice the only modification I need  to make to comment out a column/line is to place "--" in front of the comma as shown below.

1
2
3
4
5
6
SELECT [IssueHistoryID]
,[StafferID]
,[IssueID]
,[Comment]
--,[DateCreated]
FROM [IssueVision].[dbo].[IssueHistory]

I realize this tip is a subtle point.  Seems a little strange that I'm actually analizing the placement of a comma.  However, I have become quite fond of this style b/c it saves time and helps me to reduce simple syntax mistakes while testing/debugging large sprocs.  Try it with some more complex SQL and see what you think.

Click Once is the most recent and most successful Microsoft web deployment strategy for Smart Client Applications.  The technology is a great way to deploy and/or update .NET 2.0 applications on client machines without the need for an installer. 

I have used the Report Viewer Control included in Visual Studio 2005 to embed reports within our Smart Client.  The control allows me to create professional reports without the use of a third party tools.  Plus I can always scale up to Reporting Services should the need arrise. 

There is a Report Viewer Redistributable available for download.  However, the Redistributable is an MSI and installs all components in the GAC.  This action requires administrator permissions which is frowned upon by our network security team.  The MSI is 1.83 MB and contains several extra files besides the core DLL's.   

We can solve this problem by "hacking" the MSI Redistributable.  The following steps were performed by co-worker John Arcidiacono and myself to successfully solve the challenge described above.

  1. Download Report Viewer Redistributable
  2. Use favorite Zip Utility to extract the MSI.exe to a folder of your choice
  3. Find the file ReportV1.cab in extract folder from step #2
  4. Use favorite Zip Utility to extract ReportV1.cab to a folder of your choice
  5. Open the new folder from step 4 and find 4 files
  6. Rename: FL_Microsoft_ReportViewer_Common_dll_117718_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.Common.dll
  7. Rename: FL_Microsoft_ReportViewer_ProcessingObject_125592_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.ProcessingObjectModel.dll
  8. Rename: FL_Microsoft_ReportViewer_WebForms_dll_117720_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.WebForms.dll
  9. Rename: FL_Microsoft_ReportViewer_WinForms_dll_117722_____X86.3643236F_FC70_11D3_A536_0090278A1BB8 To Microsoft.ReportViewer.WinForms.dll
  10. Copy these dlls to your smart client project and reference them
  11. Now they will be part of the Smart Client's Build Output and Click Once Deployment

The Report Viewer Control available with Visual Studio 2005 is perhaps one of the most powerful and most over looked control.  This control is new to Visual Studio 2005, comes in both Win Forms and ASP.NET versions, and is freely redistributable.  Essentially, the report viewer control allows developers to embed and distribute reports with applications. 

 

Download Report Viewer Redistributable

 

Additional Resources: http://www.gotreportviewer.com/

This Article discusses how to properly organize a new project in source control.  It also talks about integrating unit testing and continous builds.

Tree Surgeon is the utility used in the article to automate the creation of build trees.

IBM's Definition of Web Service: (A Web Service is a Web Application)

Web services are a new breed of Web application. They are self-contained, self-describing, modular applications that can be published, located, and invoked across the Web. Web services perform functions, which can be anything from simple requests to complicated business processes...Once a Web service is deployed, other applications (and other Web services) can discover and invoke the deployed service.

1
2
3
4
5
6
7
8
9
StringWriter sw = new StringWriter();
XmlTextWriter xw = new XmlTextWriter(sw);

// Save Xml Document to Text Writter.
doc.WriteTo(xw);
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();

// Convert Xml Document To Byte Array.
byte[] docAsBytes = encoding.GetBytes(sw.ToString());

http://plas.fit.qut.edu.au/Ruby.NET/ - Compiles Ruby Code to .NET 2.0

http://www.iunknown.com/articles/2006/03/16/third-drop-of-rubyclr - Bridge between Ruby and .NET

http://www.wilcob.com/Wilco/IronRuby.aspx - Ruby Interpreter for .NET

http://www.infoq.com/articles/Netter-on-Rails - Why .NET should care about Ruby on Rails.

ASP.NET 2.0 brought many enhancements aimed at reducing the amount of code developers have to write to perform typical development tasks.  For example, most modern ASP.NET web sites provide user membership and role membership.  We can see these features used in portals and forums.  Forums, such as Community Server use membership and roles to authenticate users and then determine user permissions. 

By default a new ASP.NET 2.0 application will create a SQL Express Database as the data store for the SQL Server Provider based features such as membership and roles.  But using one database for the ASP.NET features and another database for the application code seems messy. The cleaner option is to store all data related to the application in one database. Now I realize a complex application may justify using multiple databases but trying to keep as much application specific data centralized in one database seems simple, clean, and logical. 

To use one database for our new ASP.NET 2.0 site we create a database then use Aspnet_regsql.exe to create the necessary ASP.NET 2.0 provider tables in our database.  The Aspnet_regsql.exe is found at drive:\WINDOWS\Microsoft.NET\Framework\versionNumber.  The tool can be run without any parameters in wizard mode or from a command line with parameters.

See http://msdn2.microsoft.com/en-us/library/x28wfk74.aspx for more information.

The term "Enterprise" is used frequently in professional software development conversations.  Many companies use "Enterprise" to describe products.  For example, Microsoft products using the term "Enterprise," include Windows 2003 Enterprise, SQL Server 2005 Enterprise, or ISA Enterprise.  But what does "Enterprise" really mean in the context of software development projects?

Dictionary.com defines Enterprise as "a project undertaken or to be undertaken, esp. one that is important or difficult or that requires boldness or energy."

"Enterprise" Software Development Projects and "Enterprise" Software Suites aim to solve especially difficult or complex problems of great importance.  Since these are especially difficult problems, solving them will likely aggressively consume resources such as time, money, specialized skills, etc.

Business

Example

Application

Requirements

Small

Family Restaurant

Accounting

  • 1 Physical Checking w/ several system accounts like payroll, office expenses, etc.
  • Credit Card

Large

National Bank

Accounting

  • Customer Accounts
  • Corporate Accounts for Project Funding
  • Pension/Retirement Accounts
  • Mortgages / Loans
  • Investment Accounts
  • Payroll (1000's of employees)
  • Taxes
  • Credit Cards
  • Financial Planning (Billing)
  • Broker (Billing)

Meeting the accounting needs of a small business such a family owed restaurant could easily be done with off-the-shelf accounting software such as Quickbooks or Microsoft Money.  These products could manage a handful of physical bank accounts, inventory and invoicing.  I've also known several small businesses to just use an Excel spreadsheet to mimic a check book register and call it good.

However, meeting the accounting needs of a large business such as a national bank is a large complex problem.  Banks issues one or more accounts to their customers which must be tracked.  Banks make money by loaning money to customers and charging interest.  So these interest payments are deposited into an account belonging to the bank.  Next, a large National Bank is likely to have thousands of employees which suggest separate accounts for payroll, retirement, etc.  It is likely that a National Bank would offer services beyond savings and loan.  For example, a National Bank may offer brokerage services and credit cards.  These services are carefully tracked and reported on the bank's financial statements such as income statement and balance sheet. 

It is clear that a National Bank has much information to keep track of from many sources.  Put another way "Enterprise" Systems tend to manage much information/data from many sources.

In the case of our small business accounting system one Wintel PC could likely store many years worth of accounting information for that business.  However, one Wintel PC would clearly not do the job for our National Bank.  The National Bank has so much information to store which cannot be lost for legal reasons that we need to use redundant backed-up servers.  Furthermore, it is probably safe to assume that a single employee in the accounting department of our National Bank cannot handle the entire accounting workload alone.  As a result the likely infrastructure is an accounting team working together using accounting software installed on servers in a data center.  These services are equipped to handle the volume of transactions and load of many users using the accounting system, all day and everyday as opposed to a small business with one user updating the system when he/she gets time.

A family run restaurant likely has one person managing the accounting records and security isn't likely to be a high concern.  However, the National Bank has a legal responsibility to the bank's stakeholders to maintain the tightest security possible.  Account balances and personal information associated with loans, checking accounts, etc. are confidential and illegal access to this information will sabotage the trust relationship between the bank and stake holders.

Finally, an accounting system is most likely not mission-critical to a family run business.  The accounting system can most likely be a few days behind as long as the owners/manager knows how much money is in the account to keep suppliers and employees paid.  However, if the accounting system crashes at the National Bank it can cost the bank millions of dollars.  For example, invoices/bills may be late for mailing.  Data could become old and corrupt causing a maintenance nightmare.

The term "Enterprise" in the context of software development means:

  • Complex Problems
  • Large amounts of data
  • Mission Critical
  • Strong Security
  • Well Performing

Service-Oriented Architecture is the art of modeling an organization's business processes, as a well-factored portfolio of network-addressable business components.

Reference: Microsoft SOA Definition

A Business Process is a collection of related structural activities that produce something of value to the organization, its stake holders or its customers

Reference: Business Process Definition

A Service Layer defines an application's boundary [Cockburn PloP] and its set of available operations from the perspective of interfacing client layers. It encapsulates the application's business logic, controlling transactions and coordinating responses in the implementation of its operations.

Reference: Martin Fowler Service Layer 

An LOB (line-of-business) application is one of the set of critical computer applications that are vital to running an enterprise, such as accounting, supply chain management, and resource planning applications. LOB applications are usually large programs that contain a number of integrated capabilities and tie into databases and database management systems.

Reference: LOB Definition

There has been much buzz around "Smart Clients" lately.  Large companies are building Smart Client Line of Business Applications. But how are "Smart Clients" different from traditional Thick/Rich Client Applications? 

Reference: MS Smart Client Definition

Smart client isn't a technology, and it isn't any specific architecture. It is a style of application that combines the best of both Windows applications and web applications. What are best aspects of each of these worlds?

Four Smart Client Characteristics

  • It uses local resources and provides a rich user experience
  • It's a connected application that exchanges data on the Internet or an enterprise network
  • Even though it's a connected application, it is offline capable so that it can be used whether or not it is currently connected
  • It has an intelligent deployment and update story, maintaining relatively the same ease of deployment and management as web applications

Smart Client