Friday, August 28, 2009
Fun flow diagram
I have found a very funny flow diagram on xkcs. In this diagram non-computer people gets some instructions what do to when they getting an error on the pc BEFORE calling 'computer experts'.
Tuesday, August 25, 2009
.Root in Source Safe
You are running into a feature referred to as 'Solution Root' added
to VS2003 (and carried forward into VS2005). You can disable this behavior
via the following registry entry:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\SourceControl\DoNotCreateSolutionRootFolderInSourceControl
Builder versus Factory pattern
Difference Between Builder pattern and Factory pattern
The factory pattern defers the choice of what concrete type of object to make until run time. E.g. going to a restaurant to order the special of the day. The waiter is the interface to the factory that takes the abstractor generic message "Get me the special of the day!" and returns the concrete product (i.e. Hawaiian or Spicy pizza)
The builder pattern encapsulates the logic of how to put together a complex object so that the client just requests a configuration and the builder directs the logic of building it. E.g The main contractor (builder) in building a house knows, given a floor plan, how to execute the sequence of operations (i.e. by delegating to subcontractors) needed to build the complex object. If that logic was not encapsulated in a builder, then the buyers would have to organize the subcontracting themselves ("Dear, shouldn't we have asked for the foundation to be laid before the roofers showed up?")
The factory is concerned with what is made, the builder with how it is made. Design patterns points out that Abstract factory is similar to builder in that it too may construct complex objects. The primary difference is that the Builder pattern focuses on constructing a complex object step by step. Abstract factory's emphasis is on families of product objects (either simple or complex). Builder returns the product as the final step, but as far as the Abstract Factory is concerned, the product gets returned immediately.
_Blank variant
<a onclick="window.open(this.href,'_blank');return false;" href="http://some_oother_site.com">Some Other Site</a>
TemplateSourceDirectory invisible
new public virtual string TemplateSourceDirectory
{
get
{
return Page.TemplateSourceDirectory;
}
}
Now the property is invisible for other classes.
Set time-out-time
Time out exceptions. How can the 'time-out-time' be set in a WCF service, web service or for (SQL) database.
Monday, August 24, 2009
SQL injection prevention
How to prevent your application from SQL Injection.
Thursday, August 20, 2009
Not showing a login page
SEO: Viewstate on top
In Place Editing
On Misfit Geek there is a nice startup tutorial about Inplace editing.
Redirect Session Expiration
I have not yet used this, but it seems nice to integrate this in a webapplication which uses form authentication.
more info
Wednesday, August 19, 2009
Serialization in ASP.NET (2)
Simple example for serializing and deserializing
Web Site or Web Application
- a web application project
- a web site project (introduced in VS2005)
Some links with information about this discussion
- ASP.NET Resources - Web Site vs Web Application Project (WAP)
- ASP.NET Web Site Layout
- asp.net Web Site versus Web Application Project
- ASP.NET Website vs Web Application project
- Understanding Page Inheritance in ASP.NET 2.0 - Rick Strahl's Web Log
- Web Site or Web Application - Blog
- Website versus Web Application - Durban, South Africa
But the conclusion of most of these sites is: decide it by yourself!
Convert Website to Webapplication
here some instructions for doiing this.
Parameters queries in Access
Tabs in Jquery
I have sent a comment with the questing how to navigate directly to a specific tab? Example of navigate directly to a specific tab
Only IE7 in IE8
<meta http-equiv="X-UA-Compatible" content="IE=7" />
Monday, August 17, 2009
Escaping xml data
Sunday, August 2, 2009
String.Empty vs empty quotes vs String.Length
The usage of String.Empty is more efficient that the usage of empty quotes.
When using empty quotes an object is created and this produces more assembly code on the execution stack and for string.Empty is NO object created.
The usage of String.Length == 0 is the best. Now there is a numeric compare applied instead of a string compararision, and numeric compare is quicker.
Only what if the string has the value null? So use string.IsNullOrEmpty method
More info: C# Shiznit, Vikram's Blog
Throw; versus Throw e;
In Coding Standards is the differents between throw and throw e explained.
What is the difference?
The difference is that 'throw;' the original stack trace persists and 'throw ex' truncates the stack trace after the method where the 'throw ex;' is called.
When using 'throw;'?
When in the try{...} a method is called then you must use 'throw;' to take care that you have the original stack trace.
Example:
// Bad!
catch(Exception ex)
{
Log(ex);
throw ex;
}
// Good!
catch(Exception)
{
Log(ex);
throw;
}
Another alternative is to create a new Exception and pass the current exception as inner exception. The stack trace is shown correctly (complete)
Example:
// Bad!
catch(Exception ex)
{
Log(ex);
throw ex;
}
// Good!
catch(Exception)
{
Log(ex);
Throw new NotImplementedException(“some extra information”, ex);
}
See for more information Fabrice's weblog, Signs on the Sand, Joteke's Blog
String.Compare or String.ToLower
// Bad!
Example: (ToLower() creates a temp string)
int id = -1;
string name = "lance hunt";
for(int i=0; i < customerList.Count; i++)
{
if(customerList[i].Name.ToLower() == name)
{
id = customerList[i].ID;
}
}
// Good! (but not for all cultures)
int id = -1;
string name = "lance hunt";
for(int i=0; i < customerList.Count; i++)
{
// The “ignoreCase = true” argument performs a
// case-insensitive compare without new allocation.
if(String.Compare(customerList[i].Name, name, true)== 0)
{
id = customerList[i].ID;
}
}
// Good! (now also for all cultures)
int id = -1;
string name = "lance hunt";
for (int i = 0; i < customerList.Count; i++)
{
// The StringComparison.OrdinalIgnoreCase argument performs a
// case-insensitive compare without new allocation and for several cultures.
if (String.Compare(customerList[i].Name, name, StringComparison.OrdinalIgnoreCase) == 0)
{
id = customerList[i].ID;
}
}
Een leuke referentie is de zogenaamde Turkey Test.