Shane Duffy

Archive for the ‘Vs2005’ Category

What the Heck is a Regular Expression Anyway?

I’m sure you are familiar with the use of “wildcard” characters for pattern matching. For example, if you want to find all the Microsoft Word files in a Windows directory, you search for “*.doc“, knowing that the asterisk is interpreted as a wildcard that can match any sequence of characters. Regular expressions are just an elaborate extension of this capability.

In writing programs or web pages that manipulate text, it is frequently necessary to locate strings that match complex patterns. Regular expressions were invented to describe such patterns. Thus, a regular expression is just a shorthand code for a pattern. For example, the pattern “\w+” is a concise way to say “match any non-null strings of alphanumeric characters”. The .NET framework provides a powerful class library that makes it easy to include regular expressions in your applications. With this library, you can readily search and replace text, decode complex headers, parse languages, or validate text.

Some Simple Examples

Searching for Elvis

Suppose you spend all your free time scanning documents looking for evidence that Elvis is still alive. You could search with the following regular expression:

1. elvis Find elvis

This is a perfectly valid regular expression that searches for an exact sequence of characters. In .NET, you can easily set options to ignore the case of characters, so this expression will match “Elvis”, “ELVIS”, or “eLvIs”. Unfortunately, it will also match the last five letters of the word “pelvis”. We can improve the expression as follows:

2. \belvis\b Find elvis as a whole word

Now things are getting a little more interesting. The “\b” is a special code that means, “match the position at the beginning or end of any word”. This expression will only match complete words spelled “elvis” with any combination of lower case or capital letters.

Suppose you want to find all lines in which the word “elvis” is followed by the word “alive.” The period or dot “.” is a special code that matches any character other than a newline. The asterisk “*” means repeat the previous term as many times as necessary to guarantee a match. Thus, “.*” means “match any number of characters other than newline”. It is now a simple matter to build an expression that means “search for the word ‘elvis’ followed on the same line by the word ‘alive’.”

3. \belvis\b.*\balive\b Find text with “elvis” followed by “alive”

With just a few special characters we are beginning to build powerful regular expressions and they are already becoming hard for we humans to read.

Let’s try another example.

Determining the Validity of Phone Numbers

Suppose your web page collects a customer’s seven-digit phone number and you want to verify that the phone number is in the correct format, “xxx-xxxx”, where each “x” is a digit. The following expression will search through text looking for such a string:

4. \b\d\d\d-\d\d\d\d Find seven-digit phone number

Each “\d” means “match any single digit”. The “-” has no special meaning and is interpreted literally, matching a hyphen. To avoid the annoying repetition, we can use a shorthand notation that means the same thing:

5. \b\d{3}-\d{4} Find seven-digit phone number a better way

The “{3}” following the “\d” means “repeat the preceding character three times”.

Read the rest of this entry »

Advertisements

.NET developers that want to adopt more agile development methodologies, while still towing the line with their project management offices, may soon begin to tap into templates available with Visual Studio 2005 Team System.
Among options available are Microsoft Solutions Framework (MSF) for Agile Software Development, which ships with Visual Studio 2005 Team System, and Scrum for Team System from U.K.-based Conchango.

 The Conchango software is a plug-in and available as a free download.
Among a host of other Scrum products available today are tools from Rally, VersionOne, TargetProcess and others.

Influenced by the tenets of Extreme Programming (XP), MSF for Agile is a hybrid process that is context-based, and includes practices Microsoft itself uses to build software. The template is intended as a starting point, according to Steve Elston, product unit manager.
“The reality is most organizations want to customize their development process almost immediately,” Elston said. MSF for Agile comprises “accepted industry practices around agile and iterative development, combined with what Microsoft has had for a long time, with the Microsoft Solutions Framework.” It’s a mechanism to “get more agile, yet still collect data the project management office needs from above.”

It fits the pattern Elston said is emerging at large enterprises—development teams at the grass roots level adopting agile practices, while the project management office remains responsible for broad oversight.
“More CIOs are interested in hearing about agile,” said Clementino Mendonca, Microsoft Project Planner. “Three or four years ago [they thought] it was scary—[agile] equaled lack of discipline and documentation. MSF Agile, like XP and other agile methodologies, is very disciplined. You use the results you have in the best way possible; you avoid doing stuff that’s not necessary. [And] it makes it easier for higher-ups to get the reporting information they need, while giving freedom to the team to self-organize.”

The need to capture project data information has been one barrier for companies trying to adopt agile methodologies, Mendonca said. With MSF for Agile and Visual Studio Team System, “data capture is not something you have to think about, but it’s done under covers by the tool.”

In addition to the agile template, Visual Studio Team System also includes MSF for CMMI Process Improvement for organizations that prefer a more formal process. Both processes are customizable, and Visual Studio Team System provides a methodology template to enact the processes. This methodology template contains work items, security settings, process guidance, process reports, source check-in policies, Microsoft Project templates, document templates, and a project portal/Windows SharePoint Services site template configured to support the MSF processes, according to the company.
Visual Studio developers who prefer the Scrum methodology can download Scrum for Team System from Conchango, which was developed in collaboration with Scrum co-creator Ken Schwaber and the Microsoft Technology Centre in the U.K.
Conchango started to conceive Scrum for Team System when Microsoft was building Visual Studio 2005 Team Foundation Server. “The idea is people make their own methodology and stick it in, which I thought was a great idea. Now you can use Scrum out of the box,” said Colin Bird, chief technology officer at Conchango.

Conchango recently released version 1.2, and Bird said there have been more than 4,000 downloads. He said the company will likely look to roll out a commercial enterprise version.

“We’re not a product company, but we thought it was a good idea to build it anyway and consume it internally; the Scrum world is very collaborative so we thought we’d do our bit for it. But we are looking at where agile is going, and it’s getting bigger and being used on far bigger projects, so I suspect we will come out with enterprise version as a costed option.”

Microsoft, too, plans added features for both the agile and CMMI templates going forward, Elston said. “We’re very aware there are a number of features to support agile, like continuous integration, which is a key agile practice, and we know we don’t have great support for that.” The next generation of the template should provide that, he said. Other agile practices under consideration for future support are test-driven development, refactoring and iteration planning, he said.
As agile practices such as these have become more accepted, agile practitioners are no longer considered to be “renegades,” said Bird. “I’ve seen it change dramatically over three and a half years. When we started we were definitely renegades,” he said. “Most companies said, ‘It wouldn’t work here.’ Over the last few years most people are getting their minds around agile. There’s a certain cynicism you encounter, but most organizations need to improve the way they develop software. There’s also the [move to be] agile as an organization.”

Introduction

The purpose of this article is to define a set of ideal practices for an agile software development project. I encourage you to leave comments about this article using the comments box at the bottom of this page. Please note that the practices listed are the practices that I believe are essential to a good agile development project; they do not necessarily have anything to do with being agile. I have tried to list the practices in descending order of importance.

Practice 1: Aggressive refactoring

In my opinion, refactoring is the most overlooked skill for a software developer. A well refactored application has a much higher value to the project sponsor than a poorly refactored application. The most common sign of code in need of refactoring is excessively long methods. I try to keep methods to less than 100 lines. Other common code smells are misleading or meaningless variable names, and code duplication. Static code analysis tools, such as FxCop, can provide a useful measure of code quality.

Practice 2: Testing

Firstly, there should be some developer testing. All the code that is written should be testable and should have tests written for it. It is acceptable to modify your program to facilitate good testing. I believe that the traditional testing terms; unit tests, integration tests and system tests have become outdated. Instead, I prefer the terms developer tests, functional tests and non-functional tests. Non-functional tests are things like performance testing, functional tests are tests that the customer cares about like use case tests or business transaction tests, and developer tests are everything else that the developer needs to test to prove to herself that the code is correct.

We should automate as much testing as possible and run it as part of continuous integration. If code coverage analysis is included in the automated testing it provides a nice indication of the health of the system at any point of time.

Practice 3: Automated build and deployment

The project should have an automated build, an automated deployment and ideally automated testing. In the optimal situation, a developer can click a button and the build process will build the latest source, deploy, test and report on the result. Automating these processes not only saves time but also eliminates a huge number of bugs and time wasters.

Practice 4: Continuous integration

If a project has automated build, deployment and testing then continuous integration is really just a matter of automating the kick-off of that build, deploy test cycle. Every checkin should result in a new build and test, on a separate build server. The results of this should be reported to every team member and it should be an established team practice to immediately fix the build. A working build should be everyone’s top priority. People should not be made to feel bad if they break the build, as this decreases their courage.

Practice 5: Source control

A source control system should be used to store all project artifacts including: code, non-code documentation, build scripts, database schema and data scripts, and tests. The code should not be checked into the build until it compiles and passes its tests.

Practice 6: Communication plan

There should be a defined, direct communication channel between the developers and the customers. This can be (best to worst): on demand face-to-face communication, daily or weekly face-face communication, contact phone numbers, instant messaging, email mailing list, intermediary (BA or PM). These communication channels can and should be combined.

Practice 7: Task tracking

There should be a defined technique for recording and prioritizing development tasks and bugs. The system should make it possible to assign responsibility for tasks to individuals. If tasks are tracked against estimates then the estimate should be performed by the person who will do the task.

Practice 8: Self documenting code

Code comments should be subjected to the same quality requirements as the code itself. Everything possible should be done to ensure that no other technical documentation is required. When non-code technical documentation is required it should be subject to the following restrictions: referenced from the code, always up-to-date (change when the code changes), only one version per baseline, stored in source control.

Practice 9: Peer review

There must be some form of peer review, such as code review of fellow programmers. If the developers are subjected to performance reviews then the peer reviews they do should be an input to that process. This helps to avoid the temptation to approve everything to avoid confrontation. Make sure that the reviews are for quality, not just for correctness.

Practice 10: Work-in-progress

A working version of the latest iteration should always be available for customer feedback. The advantage of this is that customers see very quickly when something has been developed contrary to what they had in mind. Shortening this feedback loop decreases the cost of change.

Practice 11: Feedback mechanism

There should be a defined mechanism for project team members, including the customer, to provide feedback on the project’s processes. My suggestion is to hold a short meeting at the end of each iteration.

 

Article by

Liam McLennan

Our team has been playing around with trying to speed up the responsiveness. Here’s a few things we’ve tried that have worked at least most of the time:

  • Close the Toolbox tab – Even with just the tab closed, VS2005 still seems to use resources to keep it up to date. By removing it from your workspace, the project pane and other windows appear much more responsive.
  • Turn Off Animated Windows – When VS2005 gets sluggish, expanding and hiding tabs can appear horrendously slow as the screen repaints. Turning this option off helped a little bit. Uncheck the box found under Tools >> Options >> Environment >> General >> Animate Environment
  • Turn off the VS2005 File Navigator – With resharper installed, you don’t need VS2005 to update the list of methods and fields at the top of the file (CTRL-F12 does this nicely). I’ve hardly even noticed the small panel that sits at the top of the file you’re editing but apparently it takes quite a lot of effort for VS2005 to keep it up to date. Disable the Navigation Bar checkbox under Tools … Options … Text Editor … All Languages … Display.
  • Disable Startup Page – Wondered why VS2005 seemed sluggish on start up? It’s probably because it’s trying to download something from the Internet by default. Turn off the main startup page and the “live” content by unchecking the box found under Tools >> Options >> Environment >> General >> Startup > “Download content every”. I’d also change the “At Startup” option to “Show Empty Environment”.
  • Install Cool Commands – When you use Track Active Item in the Explorer pane, collapsing projects to run tests of various kinds can be hard. Cool Commands has some helpful things like Collapse All Projects so you don’t have to do it yourself when running tests.

Wanna start to work on ASP.net Atlas-based application?
The first thing you need to do is to install the ASP.NET codename “Atlas” package and unpack the package into folder on your computer.

The next thing is to add the Atlas Control Toolkit into your Visual Studio’s toolbar. Here are the steps you can do:
1. Right click on the toolbar and select “Add Tab”
2. Name the new tab as “Atlas Control Toolkit”
3. Right click on the new tab area
4. Select “Choose Items”
5. Click “Browse”
6. Navigate to the folder where you installed the “Atlas” Control Toolkit package. In the folder SampleWebSite\Bin, select “AtlasControlToolkit.dll”
7. Click OK.
8. Click OK again to close the Choose Items Dialog.
9. Now, you can use the sample Atlas control

You have to install the “Atlas Control Extender” to build extenders and controls. You can go to the folder where you installed the “Atlas” Control Toolkit package. Under the folder called “AtlasControlExtender”  double-click AtlasControlExtender.vsi to install it.

Creating Task List Comments in your projects can ensure you to complete the important and esential tasks. This feature can be used to indicate a variety of work to be done at the location marked

The Task List displays comments embedded in your project code that begin with the comment marker for your development language, followed by a default task token such as TODO, HACK, or UNDONE, or a custom comment token.

The number of comments that appear in the Task List changes, depending on the type of project you are working on.
With Visual Basic projects, the Task List displays all of the comments in the project.
With Visual C# and Visual J# projects, the Task List displays only the comments that are found in the files currently opened for edit.
With Visual C++ projects, the Task List displays only the comments that are found in the file currently active in the editor.

To add a comment to the Task List
1. Open a source code file for editing in the Code Editor.

2. Begin a comment on a line of code you want to mark with <marker><token>, where <marker> is the comment marker for your development language, and <token> is the name of a recognized Task List comment token, such as TODO, HACK, or UNDONE, or a custom comment token.

By default, the task window is not visible, so the first thing you must do is make the task list visible. As with most things in Visual Studio, you can achieve this with either a keyboard shortcutt (Ctrl+Alt+K) or by going to View | Other Windows | Task List.
Vs 2005 Comments

As with other Task List entries, you can double-click any comment entry to display the file indicated in the Code Editor and jump to the line of code marked.

Example of TODO Comment:
// TODO: Add references to specific resources here

Caching is a very useful way for you to retain pages or data across HTTP requests, so that you can reuse them without the recreating them.

In ASP.net 2.0, it makes you easier to implement data caching. SQL cache dependencies are one of ASP.net 2.0 coolest features, which allows you to create dependencies between cached items and database entities. This enables cached query results to be automatically evicted from the cache if the underlying data changed. This feature applies to SQL Server 7, 2000 and 2005.

SQL cache dependencies are more powerful when paired with SQL Server 2005
– you can set the cache dependencies are more granular

– this is not rely on polling but on query notifications from SQL Server 2005
– this require no preparation of the database

Here are the steps on how to enable the SQL cache dependency on a table.

1. Enable notifications using SQL registration tool
To enable SQL cache dependency, first you have to register the database, tables by using the Sql registration tool (C:\Windows\Microsoft.NET\Framework\v2.0.50727)
At the command prompt, type
aspnet_regsql -S [servername] -E -d [databasename] -ed -et -t [tablename]
-S = Server
-E = TrustedConnection
-d = Database
-ed = Enable caching at database

-et = Enable caching at table
-t = table

other options, -u = username, -p = password

After you run the statement, you hit refresh at your database.
You will notice there is an extra table created to store the cache data and a trigger created for the particular table. When there is changes on the table, the trigger will be fired up and write the changes to the cache table.

2. Register the notification in the Web Configuration
Enable the sql cache dependency at the web configuration file and set the poll time.
<system.web>
<
caching>
<
sqlCacheDependency enabled=true pollTime=2000>
<
databases>
<
add name=conn connectionStringName=conn/>
</
databases>
</
sqlCacheDependency>
</
caching>
</
system.web>

The poll time is specifies how often the application checks to see whether the data has changed.

3. Define SQL Dependency
There are two options to define the SQL dependency
– You can specify on the OutputCache directive
<%@ OutputCache Duration=”10″ VaryByParam=”*”
SqlDependency=”[sqldependencyname]:[tablename]” %>

– or, specify directly on a datasource control
<asp:SqlDataSource EnableCaching=”true” CacheDuration=”Infinite”
SqlCacheDependency=”[sqldependencyname]:[tablename]” />

After you have defined the SQL dependency, any changes that made to the database will be reflected on your web pages immediately though you have set the cache duration on the page.
This can make sure that you users always get the latest data from the server.

4. Notification-based cache invalidation
If you are using SQL Server 2005, you can use the Notification-based cache invalidation.
Unlike polling based validation, no <sqlCacheDependency> needs to be registered in your application’s configuration. Furthermore, no special configuration using the aspnet_regsql.exe tool is needed.

A notification based dependency is configured on the OutputCache directive using the string CommandNotification.
<%@ OutputCache Duration=”10″ VaryByParam=”*” SqlDependency=”CommandNotification %>
This value indicates to ASP.NET that a notification based dependency should be created for the page or datasource control.

System.Data.SqlClient.SqlDependency.Start() method must be called before the first SQL query is executed. This method could be placed in Application_Start() event in global.asax file.

void Application_Start(object sender, EventArgs e)
{
System.Data.SqlClient.SqlDependency.Start(ConfigurationManager.ConnectionStrings[“conn”].ConnectionString);
}

This option is much more efficient as there is no pollung going on but the ASP.net acts as client, only if there is changes, ASP.net will get notified.

You may use SQL profiler to monitor the perfomance of your database to compare before and after you apply this SQL cache dependency.


Subscribe to this blog now!

Top Clicks

  • None
November 2018
M T W T F S S
« Feb    
 1234
567891011
12131415161718
19202122232425
2627282930  
Advertisements