<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-2438996170392830548</atom:id><lastBuildDate>Thu, 21 Apr 2011 18:27:11 +0000</lastBuildDate><category>VB.Net</category><category>Microsoft</category><category>3-tier</category><category>SQL</category><category>Dot Net</category><category>Database</category><category>Stored Procedure</category><category>Software Design</category><category>Application</category><category>Programming</category><category>Operator</category><title>Programmer Land</title><description>Sharing programming tips, tutorials, articles</description><link>http://programmerland.blogspot.com/</link><managingEditor>noreply@blogger.com (Kevin Wong)</managingEditor><generator>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/ProgrammerLand" /><feedburner:info uri="programmerland" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2438996170392830548.post-6474577058193882960</guid><pubDate>Tue, 27 May 2008 17:09:00 +0000</pubDate><atom:updated>2008-05-27T10:11:42.106-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Application</category><category domain="http://www.blogger.com/atom/ns#">3-tier</category><category domain="http://www.blogger.com/atom/ns#">Software Design</category><title>What is 3-tier application?</title><description>A 3-tier application is an &lt;a href="http://searchsoftwarequality.techtarget.com/sDefinition/0,,sid92_gci211585,00.html" class="inline"&gt;&lt;/a&gt;application program that is organized into three major parts, each of which is distributed to a different place or places in a network.  The three parts are: &lt;ul&gt;&lt;li&gt;The workstation or presentation interface &lt;/li&gt;&lt;li&gt;The business logic&lt;/li&gt;&lt;li&gt;The database and programming related to managing it&lt;/li&gt;&lt;/ul&gt; &lt;p&gt; In a typical 3-tier application, the application user's workstation contains the programming that provides the graphical user interface (GUI) and application-specific entry forms or interactive windows. (Some data that is local or unique for the workstation user is also kept on the local hard disk.) &lt;/p&gt;&lt;p&gt; Business logic is located on a local area network (LAN) server or other shared computer. The business logic acts as the server for client requests from workstations. In turn, it determines what data is needed (and where it is located) and acts as a client in relation to a third tier of programming that might be located on a mainframe &lt;a href="http://searchdatacenter.techtarget.com/sDefinition/0,,sid80_gci212516,00.html" class="inline"&gt;&lt;/a&gt;computer. &lt;/p&gt;&lt;p&gt; The third tier includes the database and a program to manage read and write access to it. While the organization of an application can be more complicated than this, the 3-tier view is a convenient way to think about the parts in a large-scale program. &lt;/p&gt;&lt;p&gt; A 3-tier application uses the client/server computing model. With three tiers or parts, each part can be developed concurrently by different team of programmers coding in different languages from the other tier developers. Because the programming for a tier can be changed or relocated without affecting the other tiers, the 3-tier model makes it easier for an enterprise or software packager to continually evolve an application as new needs and opportunities arise. Existing applications or critical parts can be permanently or temporarily retained and encapsulated within the new tier of which it becomes a component. &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2438996170392830548-6474577058193882960?l=programmerland.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/ProgrammerLand/~3/qNPF5vdgG8g/what-is-3-tier-application.html</link><author>noreply@blogger.com (Kevin Wong)</author><thr:total>0</thr:total><feedburner:origLink>http://programmerland.blogspot.com/2008/05/what-is-3-tier-application.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2438996170392830548.post-5652827343237098999</guid><pubDate>Tue, 27 May 2008 17:04:00 +0000</pubDate><atom:updated>2008-05-27T10:07:38.283-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Stored Procedure</category><category domain="http://www.blogger.com/atom/ns#">Database</category><category domain="http://www.blogger.com/atom/ns#">SQL</category><title>Stored Procedures Optimization Tips</title><description>&lt;span&gt;&lt;span style="font-family:Verdana;font-size:85%;"&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Use stored procedures instead of heavy-duty queries.&lt;/b&gt;&lt;br /&gt;This can reduce network traffic, because your client will send to server only stored procedure name (perhaps with some parameters) instead of large heavy-duty queries text. Stored procedures can be used to enhance security and conceal underlying data objects also. For example, you can give the users permission to execute the stored procedure to work with the restricted set of the columns and data.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;center&gt;*****&lt;/center&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Include the SET NOCOUNT ON statement into your stored procedures to stop the message indicating the number of rows affected by a Transact-SQL statement.&lt;/b&gt;&lt;br /&gt;This can reduce network traffic, because your client will not receive the message indicating the number of rows affected by a Transact-SQL statement.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;center&gt;*****&lt;/center&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Call stored procedure using its fully qualified name.&lt;/b&gt;&lt;br /&gt;The complete name of an object consists of four identifiers: the server name, database name, owner name, and object name. An object name that specifies all four parts is known as a fully qualified name. Using fully qualified names eliminates any confusion about which stored procedure you want to run and can boost performance because SQL Server has a better chance to reuse the stored procedures execution plans if they were executed using fully qualified names.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;center&gt;*****&lt;/center&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Consider returning the integer value as an RETURN statement instead of an integer value as part of a recordset.&lt;/b&gt;&lt;br /&gt;The RETURN statement exits unconditionally from a stored procedure, so the statements following RETURN are not executed. Though the RETURN statement is generally used for error checking, you can use this statement to return an integer value for any other reason. Using RETURN statement can boost performance because SQL Server will not create a recordset.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;center&gt;*****&lt;/center&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Don't use the prefix "sp_" in the stored procedure name if you need to create a stored procedure to run in a database other than the master database.&lt;/b&gt;&lt;br /&gt;The prefix "sp_" is used in the system stored procedures names. Microsoft does not recommend to use the prefix "sp_" in the user-created stored procedure name, because SQL Server always looks for a stored procedure beginning with "sp_" in the following order: the master database, the stored procedure based on the fully qualified name provided, the stored procedure using dbo as the owner, if one is not specified. So, when you have the stored procedure with the prefix "sp_" in the database other than master, the master database is always checked first, and if the user-created stored procedure has the same name as a system stored procedure, the user-created stored procedure will never be executed.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;center&gt;*****&lt;/center&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Use the sp_executesql stored procedure instead of the EXECUTE statement.&lt;/b&gt;&lt;br /&gt;The sp_executesql stored procedure supports parameters. So, using the sp_executesql stored procedure instead of the EXECUTE statement improve readability of your code when there are many parameters are used. When you use the sp_executesql stored procedure to executes a Transact-SQL statements that will be reused many times, the SQL Server query optimizer will reuse the execution plan it generates for the first execution when the change in parameter values to the statement is the only variation.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;center&gt;*****&lt;/center&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Use sp_executesql stored procedure instead of temporary stored procedures.&lt;/b&gt;&lt;br /&gt;Microsoft recommends to use the temporary stored procedures when connecting to earlier versions of SQL Server that do not support the reuse of execution plans. Applications connecting to SQL Server 7.0 or SQL Server 2000 should use the sp_executesql system stored procedure instead of temporary stored procedures to have a better chance to reuse the execution plans.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;center&gt;*****&lt;/center&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;If you have a very large stored procedure, try to break down this stored procedure into several sub-procedures, and call them from a controlling stored procedure.&lt;/b&gt;&lt;br /&gt;The stored procedure will be recompiled when any structural changes were made to a table or view referenced by the stored procedure (for example, ALTER TABLE statement), or when a large number of INSERTS, UPDATES or DELETES are made to a table referenced by a stored procedure. So, if you break down a very large stored procedure into several sub-procedures, you get chance that only a single sub-procedure will be recompiled, but other sub-procedures will not.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;center&gt;*****&lt;/center&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Try to avoid using temporary tables inside your stored procedure.&lt;/b&gt;&lt;br /&gt;Using temporary tables inside stored procedure reduces the chance to reuse the execution plan.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;center&gt;*****&lt;/center&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Try to avoid using DDL (Data Definition Language) statements inside your stored procedure.&lt;/b&gt;&lt;br /&gt;Using DDL statements inside stored procedure reduces the chance to reuse the execution plan.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;center&gt;*****&lt;/center&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Add the WITH RECOMPILE option to the CREATE PROCEDURE statement if you know that your query will vary each time it is run from the stored procedure.&lt;/b&gt;&lt;br /&gt;The WITH RECOMPILE option prevents reusing the stored procedure execution plan, so SQL Server does not cache a plan for this procedure and the procedure is recompiled at run time. Using the WITH RECOMPILE option can boost performance if your query will vary each time it is run from the stored procedure because in this case the wrong execution plan will not be used.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt; &lt;center&gt;*****&lt;/center&gt;&lt;br /&gt;&lt;li&gt;&lt;b&gt;Use SQL Server Profiler to determine which stored procedures has been recompiled too often.&lt;/b&gt;&lt;br /&gt;To check the stored procedure has been recompiled, run SQL Server Profiler and choose to trace the event in the "Stored Procedures" category called "SP:Recompile". You can also trace the event "SP:StmtStarting" to see at what point in the procedure it is being recompiled. When you identify these stored procedures, you can take some correction actions to reduce or eliminate the excessive recompilations.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;*****&lt;/center&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2438996170392830548-5652827343237098999?l=programmerland.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/ProgrammerLand/~3/MceDFvOot7k/stored-procedures-optimization-tips.html</link><author>noreply@blogger.com (Kevin Wong)</author><thr:total>0</thr:total><feedburner:origLink>http://programmerland.blogspot.com/2008/05/stored-procedures-optimization-tips.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-2438996170392830548.post-3242004633842066802</guid><pubDate>Sun, 25 May 2008 15:11:00 +0000</pubDate><atom:updated>2008-05-27T10:08:17.220-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Programming</category><category domain="http://www.blogger.com/atom/ns#">VB.Net</category><category domain="http://www.blogger.com/atom/ns#">Dot Net</category><category domain="http://www.blogger.com/atom/ns#">Microsoft</category><category domain="http://www.blogger.com/atom/ns#">Operator</category><title>VB .NET New Logical Operators AndAlso and OrElse</title><description>&lt;span&gt;&lt;span style=";font-family:verdana,geneva,helvetica;font-size:85%;"  &gt;VB .NET features two new logical operators that help make your programming ... well ... more logical. The new operators are &lt;span style="color: rgb(0, 0, 192);"&gt;&lt;b&gt;AndAlso&lt;/b&gt;&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 192);"&gt;&lt;b&gt;OrElse&lt;/b&gt;&lt;/span&gt; and they generally replace the VB 6 operators &lt;span style="color: rgb(0, 0, 192);"&gt;And&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 192);"&gt;Or&lt;/span&gt; (but they do much more!).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=";font-family:verdana,geneva,helvetica;font-size:85%;"  &gt;&lt;p&gt;The old VB 6 &lt;span style="color: rgb(0, 0, 192);"&gt;And&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 192);"&gt;Or&lt;/span&gt; are still present in VB .NET. If you decide that they're what you need your program, go ahead and use them. They work the same way they used to work.&lt;/p&gt;  &lt;p&gt;But &lt;span style="color: rgb(0, 0, 192);"&gt;AndAlso&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 192);"&gt;OrElse&lt;/span&gt; have some properties that enhance your code in ways that VB 6 can't match. They offer advantages in two general categories:  &lt;/p&gt;&lt;ul&gt;&lt;li&gt;You can avoid executing part of a logical expression to avoid problems.&lt;/li&gt;&lt;li&gt;You can optimize code by not executing any more of a compound expression than required.&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;  &lt;p&gt;&lt;span style=";font-family:verdana,geneva,helvetica;font-size:85%;"  &gt;&lt;span style="color: rgb(0, 0, 192);"&gt;AndAlso&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 192);"&gt;OrElse&lt;/span&gt; are pretty much like &lt;span style="color: rgb(0, 0, 192);"&gt;And&lt;/span&gt; and &lt;span style="color: rgb(0, 0, 192);"&gt;Or&lt;/span&gt; except that they will "short circuit" an expression once the outcome is guaranteed. Suppose you're coding a test of a calculation result like this:&lt;/span&gt;&lt;/p&gt;  &lt;pre&gt;&lt;span style=";font-family:verdana,geneva,helvetica;font-size:85%;"  &gt;&lt;span style="color: rgb(0, 0, 192);font-size:85%;" &gt;If a &lt;&gt;&lt;/span&gt;&lt;/pre&gt;  &lt;p&gt;&lt;span style=";font-family:verdana,geneva,helvetica;font-size:85%;"  &gt;If the variables in the block have these values:&lt;/span&gt;&lt;/p&gt;  &lt;pre&gt;&lt;span style=";font-family:verdana,geneva,helvetica;font-size:85%;"  &gt;&lt;span style="color: rgb(0, 0, 192);font-size:85%;" &gt;Value1 = 1&lt;br /&gt;Value2 = 1&lt;br /&gt;Value3 = 0&lt;br /&gt;a = 1&lt;br /&gt;b = 1&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;  &lt;p&gt;&lt;span style=";font-family:verdana,geneva,helvetica;font-size:85%;"  &gt;The &lt;span style="color: rgb(0, 0, 192);"&gt;If&lt;/span&gt; expression generates a "divide by zero" error in VB 6 because &lt;span style="color: rgb(0, 0, 192);"&gt;Value3&lt;/span&gt; is zero. It could be that the cases that result in &lt;span style="color: rgb(0, 0, 192);"&gt;Value3&lt;/span&gt; being zero are very rare and only occur when you're enjoying a vacation a thousand miles away so you can be called back to fix the program in an emergency mode. (Hey! It happens!)&lt;/span&gt;&lt;/p&gt;  &lt;p&gt;&lt;span style=";font-family:verdana,geneva,helvetica;font-size:85%;"  &gt;Let's recode the program as a .NET program using &lt;span style="color: rgb(0, 0, 192);"&gt;AndAlso&lt;/span&gt; and see what happens.&lt;/span&gt;&lt;/p&gt;  &lt;pre&gt;&lt;span style=";font-family:verdana,geneva,helvetica;font-size:85%;"  &gt;&lt;span style="color: rgb(0, 0, 192);font-size:85%;" &gt;Dim Value1 As Integer&lt;br /&gt;Dim Value2 As Integer&lt;br /&gt;Dim Value3 As Integer&lt;br /&gt;Dim a As Integer&lt;br /&gt;Dim b As Integer&lt;br /&gt;Value1 = 1&lt;br /&gt;Value2 = 1&lt;br /&gt;Value3 = 0&lt;br /&gt;a = 1&lt;br /&gt;b = 1&lt;br /&gt;If a &gt; Value1 AndAlso b &gt; (Value2 / Value3) Then&lt;br /&gt;  ' {body of If block}&lt;br /&gt;End If&lt;br /&gt;MsgBox("Hey! It works!")&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;  &lt;p&gt;&lt;span style=";font-family:verdana,geneva,helvetica;font-size:85%;"  &gt;First, of course, we have to declare our variables with VB .NET. Then after changing &lt;span style="color: rgb(0, 0, 192);"&gt;And&lt;/span&gt; to &lt;span style="color: rgb(0, 0, 192);"&gt;AndAlso&lt;/span&gt;, the program works! One reason is that the last part of the compound &lt;span style="color: rgb(0, 0, 192);"&gt;If&lt;/span&gt; condition - &lt;span style="color: rgb(0, 0, 192);"&gt;(value 2 / value3)&lt;/span&gt; - is never actually executed. When you use &lt;span style="color: rgb(0, 0, 192);"&gt;AndAlso&lt;/span&gt;, VB .NET knows that the expression can't succeed once it is determined that the first part of the condition - &lt;span style="color: rgb(0, 0, 192);"&gt;a&lt;/span&gt; is not greater than &lt;span style="color: rgb(0, 0, 192);"&gt;Value1&lt;/span&gt; - is false.  So VB .NET stops evaluating the expression right there.&lt;/span&gt;&lt;/p&gt;&lt;span style=";font-family:verdana,geneva,helvetica;font-size:85%;"  &gt;   &lt;p&gt;Knowledgeable .NET'ers will point out that VB .NET supports a value for infinity - which is what the result of division by zero actually is in mathematical terms - so the expression would work anyway. Very true! But consider this example where our program tests a value obtained directly from the user:&lt;/p&gt;  &lt;pre&gt;&lt;span style="color: rgb(0, 0, 192);font-size:100%;" &gt;Dim Value1 As Integer&lt;br /&gt;Dim a As Integer&lt;br /&gt;Dim b As String&lt;br /&gt;Value1 = 1&lt;br /&gt;a = 1&lt;br /&gt;b = 1&lt;br /&gt;If a &gt; Value1 AndAlso b = Console.ReadLine() Then&lt;br /&gt;  ' {body of If block}&lt;br /&gt;End If&lt;br /&gt;MsgBox("Hey! It works!")&lt;/span&gt;&lt;/pre&gt;  &lt;p&gt;In VB 6 (or if you use &lt;span style="color: rgb(0, 0, 192);"&gt;And&lt;/span&gt; in VB .NET), the program will ask for input every time. If you want the second test to be executed  every time, use &lt;span style="color: rgb(0, 0, 192);"&gt;And&lt;/span&gt;. If that's not what you want, use &lt;span style="color: rgb(0, 0, 192);"&gt;AndAlso&lt;/span&gt;.&lt;/p&gt;  &lt;p&gt;This analysis suggests how you can add some efficiency to your code by arranging a compound logical expression correctly. If you place the expression that is most likely to be false in the leftmost position when using &lt;span style="color: rgb(0, 0, 192);"&gt;AndAlso&lt;/span&gt;, you can prevent execution cycles from being used to evaluate the rightmost expression. In a single test, it wouldn't make enough difference to be worth even thinking about. But if your test is inside a loop of some kind and is executed zillions of times, it could make a big difference.&lt;/p&gt;  &lt;p&gt;The &lt;span style="color: rgb(0, 0, 192);"&gt;OrElse&lt;/span&gt; operator has similar differences compared with the VB 6 &lt;span style="color: rgb(0, 0, 192);"&gt;Or&lt;/span&gt; operator. Knowing about these two new VB .NET logical operators can help you avoid very subtle errors or achieve subtle efficiencies.&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2438996170392830548-3242004633842066802?l=programmerland.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://feedproxy.google.com/~r/ProgrammerLand/~3/nFPYex-bVBM/vb-net-new-logical-operators-andalso.html</link><author>noreply@blogger.com (Kevin Wong)</author><thr:total>0</thr:total><feedburner:origLink>http://programmerland.blogspot.com/2008/05/vb-net-new-logical-operators-andalso.html</feedburner:origLink></item></channel></rss>

