Tuesday, February 05, 2008

101 Design Patterns & Tips for Developers

Full guide for developer how to create your application in the using   a "design patterns", that include next parts:

  • Creational Patterns
  • Structural Patterns
  • Behavioral Patterns
  • Composing Methods of Refactoring
  • Moving Features Between Objects
  • Organizing Data
  • Simplifying Conditional Expressions
  • Making Method Calls Simpler
  • Dealing with Generalization
  • Big Refactorings

Click here to read.

Monday, January 28, 2008

The Chart free generation for Web Application from Google

Google Provided addition tool for Web developers  - The Google Chart API.

You can create a charts in very simple way - build necessary URL and will receive chart in one of 5 types (Line, Bar, Pie, Venn or Scatter).

A simple "pie" for example:

URL = "http://chart.apis.google.com/chart?
cht=p3&chco=4C8ED6&chs=250x120&
chl=Sun|Mon|Tue|Wed|Thu|Fri|Sat&chd=s:ABCDEFG"

and a result:

 

 

In your control next chart parameters: Data, Type, Colors, Labels, Style, Character mappings and several optional parameters.

To Home Page click HERE

Sunday, January 20, 2008

Find all tables, which includes column name

Get all table names for a specific column name

SELECT sysobj.name as Table_Name
FROM sysobjects sysobj
INNER JOIN syscolumns syscol
ON sysobj.id= syscol.id
WHERE syscol.name = 'COLUMN_NAME_FOR_SEARCH'



-------------------------------------------

Get all columns and table names for a 'like column_name' query

SELECT syscol.[name] as Column_Name,
sysobj.name as Table_Name
FROM sysobjects sysobj
INNER JOIN syscolumns syscol
ON sysobj.id=syscol.id
WHERE syscol.name like '%COLUMN_NAME%'
kick it on DotNetKicks.com
 

Thursday, January 17, 2008

Example & Tutorial of Rhino Mocks

In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to test the behavior of a car during an accident.

 Wikipedia 

To full guide in code examples about Rhino Mocks Click Here

Full guide how to configuring VS 2008 for debugging .NET Framework Source Code

Click here to read a article.

Thursday, January 10, 2008

SQL Server 2005, Clean your Database Records & reset Identity Columns, all in 6 lines

Well, I had a small issue regarding writing a script to clean a database we have and reset its identity columns in all tables. Although the database wasn't huge one (less than 100 tables) I had to trace relations to be able to delete child table's records before parent's ones because of the foreign key constraints. The solution is disable the foreign keys and delete records with no fear of any errors then enables the constraints again.
Well, I found a solution to disable all constraints without the need to go on each table and disable it manually. and I was happy to know that I can use this solution in deleting all records from all tables. Not only this I was able to use the same solution to reset identity columns in all tables.
The solution was to use this built in stored procedure sp_MSforeachtable. For help about this proc search for it in Books online or use this sp_helptext sp_MSForeachtable.
Now back to my 6 lines, bellow is how I re-zeroed my Database:

/*Disable Constraints & Triggers*/
exec sp_MSforeachtable
'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
exec sp_MSforeachtable
'ALTER TABLE ? DISABLE TRIGGER ALL'

/*Perform delete operation on all table for cleanup*/
exec sp_MSforeachtable 'DELETE ?'

/*Enable Constraints & Triggers again*/
exec sp_MSforeachtable
'ALTER TABLE ? CHECK CONSTRAINT ALL'
exec sp_MSforeachtable
'ALTER TABLE ? ENABLE TRIGGER ALL'

/*Reset Identity on tables with identity column*/
exec sp_MSforeachtable
'IF OBJECTPROPERTY(OBJECT_ID(''?''),
'
'TableHasIdentity'') = 1
BEGIN DBCC CHECKIDENT ('
'?'',RESEED,0) END'




 


Via Moses on DotNetSlackers

Wednesday, January 09, 2008

How to check email works with no SMTP

<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory
pickupDirectoryLocation="c:\Test\" />
</smtp>
</mailSettings>
</system.net>


 
Via .Net Tip of The Day

Monday, January 07, 2008

How to extract URLs (href property) from HTML

protected ArrayList GetUrl(string text)
{
ArrayList listURL = new ArrayList();
Regex r =
new Regex("href\\s*=\\s*(?:(?:\\\
"
(?<url>[^\\\"]*)\\\")|
(?<url>[^\\s]* ))"
);
MatchCollection mathColl = r.Matches(text);

foreach (Match math in mathColl)
{
foreach (Group gr in math.Groups)
{
listURL.Add(gr.Value);
}
}
return listURL;
}

Sunday, December 23, 2007

What is the difference between URL and URI?

A URL is the address of some resource on the web, which means that normally you type the address into a browser and you get something back. There are other type of resources than web pages, but that's the easiest conceptually. The browser goes out somewhere on the internet and accesses something.

A URI is just a unique string that uniquely identifies something, commonly a namespace. Sometimes they look like a URL that you could type into the address bar of your web browser, but it doesn't have to point to any physical resource on the web.

URI is the more generic term, and a URL is a particular type of URI in that a URL has to uniquely identify some resource on the web.

Via .Net Tip of The Day

Thursday, November 22, 2007

Ajax control toolkit updated for Visual Studio 2008

Ajax control toolkit has been updated and released to version version 3.5.11119.0

AjaxControlToolkit-Framework3.5.zip is the full release package with complete source code to all controls, the test framework, VSI, and more.

AjaxControlToolkit-Framework3.5-NoSource.zip contains only the sample web site and VSI and is for people who don't need or want the source code for the controls.

Download link

kick it on DotNetKicks.com

Wednesday, November 21, 2007

Visual Studio 2008 and .NET Framework 3.5 Training Kit

The Visual Studio 2008 and .NET Framework 3.5 Training Kit includes presentations, hands-on labs, and demos. This content is designed to help you learn how to utilize the Visual Studio 2008 features and a variety of framework technologies including: LINQ, C# 3.0, Visual Basic 9, WCF, WF, WPF, ASP.NET AJAX, VSTO, CardSpace, SilverLight, Mobile and Application Lifecycle Management.

Download Page

kick it on DotNetKicks.com

Monday, November 19, 2007

Visual C# 2008 Keyboard Shortcuts Reference Poster

Microsoft present keybinding reference poster for Visual C# in Visual Studio 2008 

Download page

kick it on DotNetKicks.com

Thursday, November 15, 2007

Add automatic updates to your application

This article explain  step-by-step how to add automatic update capabilities to application quickly and easily.

Click here

kick it on DotNetKicks.com

Wednesday, November 14, 2007

How to add ComboBox to PropertyGrid

Create new class which inherit StringCoverter, and 3 methods:

internal class List2PropertyConverter : StringConverter
{
public override bool
GetStandardValuesSupported(
ITypeDescriptorContext context)
{
//True - means show a Combobox
//and False for show a Modal
return true;
}

public override bool
GetStandardValuesExclusive(
ITypeDescriptorContext context)
{
//False - a option to edit values
//and True - set values to state readonly
return true;
}

public override StandardValuesCollection
GetStandardValues(
ITypeDescriptorContext context)
{
return new StandardValuesCollection(
new string[] {"test1", "test2", "..."});
}
}




Add variable and encapsulate it:
 private string testValue;
[Browsable(true)]
[Category("Category name")]
[TypeConverter(typeof(List2PropertyConverter))]
public string TestValues
{
get { return testValue; }
set { testValue = value; }
}




PropertyGrid has 4 attributes for a manage properties:


[Browsable(bool)] - Visible/Hide property

[ReadOnly(bool)] - Editing (true/false)

[Category(string)] - Group of properties

[Description(string)] - Description of the property

kick it on DotNetKicks.com

Regards,

Sunday, November 11, 2007

CAPTCHA Kinda Spam Prevention in ASP.NET

Spammers really bug me.

I've been working on this on-going sports related portal project (that probably will NEVER go live :)

I love of hobby community sites degrade quickly because they lack the moderation resources to keep the user submitted content quality high and I've been thinking about this problem.

I thought I would share some interesting links that I found on the subject.

 

by Joe Stagner

kick it on DotNetKicks.com

Template Method Design Pattern vs. Functional Programming

Simple and obvious example how to realize Design Patterns. A example based on Hot Drinks and presented design of the application with explanations.

Click here

kick it on DotNetKicks.com

Thursday, November 08, 2007

ADInsight - new utility by Microsoft

ADInsight is an LDAP (Light-weight Directory Access Protocol) real-time monitoring tool aimed at troubleshooting Active Directory client applications. Use its detailed tracing of Active Directory client-server communications to solve Windows authentication, Exchange, DNS, and other problems.

Homepage

Download (720kb)

kick it on DotNetKicks.com

BGInfo - display PC information on the desktop

How many times have you walked up to a system in your office and needed to click through several diagnostic windows to remind yourself of important aspects of its configuration, such as its name, IP address, or operating system version If you manage multiple computers you probably need BGInfo. It automatically displays relevant information about a Windows computer on the desktop's background, such as the computer name, IP address, service pack version, and more. You can edit any field as well as the font and background colors, and can place it in your startup folder so that it runs every boot, or even configure it to display as the background for the logon screen.

HomePage

Download

kick it on DotNetKicks.com

Calling delegates using BeginInvoke, Invoke, DynamicInvoke and delegate

I wanted to write about delegates this month. There are different ways in which you can invoke delegates to get either a synchronous or an asynchronous behavior. But from what I noticed, the delegate model provides you very less control when you invoke it asynchronously. The caller cannot easily abort or terminate the operation.

If you want to execute a delegate asynchronously and still want to have good control from the caller then invoke it explicitly from a thread. The sample below demonstrates multiple ways you can invoke a delegate and each has its own features with it. Till I wrote this, I didn’t realize that there are 6 ways to invoke a delegate and I am sure there are a few more that I am missing here. It was also interesting that when you execute a delegate on a thread then it cannot return a value as the caller of the thread is gone when the thread returns. If you want to pass parameters to the delegate in the thread you can use the ParameterizedThread option which is very useful.

 

Click here to continue...

kick it on DotNetKicks.com