Archive for May, 2009

30th May 2009

Objectville – New Restaurant In Town

Hi again,

After thinking for quite a while for what to post in the blog, I thought its not bad to go in Kathy’s way. :) If you didn’t ever try then just have one eye on any book of Kathy Sierra or you can say synonym of Kathy is “Head First” books. Just google out any of the “Head First” book and you will surely get “never read before” books.

So I finally decided that I will open one restaurant Objectville soon. But to make Objectville rock in the town, we will be serving very few fastfood only in the initial stage, however, we want to go long way so we need system with strong architecture. But we don’t even want to increase complexity of the system unnecessarily by just piling up different patterns without thinking whether its needed.

Read More >>

Posted by Posted by vishal.shukla under Filed under Code, design Comments No Comments »

29th May 2009

Basic Testing Methodology & Testing Type

 

Basic Testing Methodology

  • Unit Testing—The programmers conduct unit testing during the development phase. Programmers can test their specific functionality individually or with other units. However, unit testing is designed to test small pieces of functionality rather than the system as a whole. This allows the programmers to conduct the first round of testing to eliminate bugs before they reach the testing staff.
  • Integration Testing—Incremental integration testing involves continuous testing of an application as new functionality is added. This requires that aspects of an application’s functionality be able to work separately before all parts of the application are completed. Full integration testing tests combined parts of an application to determine if they function together correctly.
  • System Testing—The system is tested as a complete, integrated system. System testing first occurs in the development environment but eventually is conducted in the production environment. Dedicated testers, project managers, or other key project staff performs system testing. Functionality and performance testing are designed to catch bugs in the system, unexpected results, or other ways in which the system does not meet the stated requirements. The testers create detailed scenarios to test the strength and limits of the system, trying to break it if possible. Editorial reviews not only correct typographical and grammatical errors, but also improve the system’s overall usability by ensuring that on-screen language is clear and helpful to users. Accessibility reviews ensure that the system is accessible to users with disabilities.
  • Acceptance Testing—The software is assessed against the requirements defined in the system requirements document. The user or client conducts the testing in the production environment. Successful acceptance testing is required before submitting to the client for approval.

Software Testing Types:

  • Black box testing – Internal system design is not considered in this type of testing. Tests are based on requirements and functionality.
  • White box testing – This testing is based on knowledge of the internal logic of an application’s code. Also known as Glass box Testing. Internal software and code working should be known for this type of testing. Tests are based on coverage of code statements, branches, paths, conditions.
  • Unit testing – Testing of individual software components or modules. Typically done by the programmer and not by testers, as it requires detailed knowledge of the internal program design and code. May require developing test driver modules or test harnesses.
  • Incremental integration testing – Bottom up approach for testing i.e continuous testing of an application as new functionality is added; Application functionality and modules should be independent enough to test separately done by programmers or by testers.
  • Integration testing – Testing of integrated modules to verify combined functionality after integration. Modules are typically code modules, individual applications, client and server applications on a network, etc. This type of testing is especially relevant to client/server and distributed systems.
  • Functional testing – This type of testing ignores the internal parts and focus on the output is as per requirement or not. Black-box type testing geared to functional requirements of an application.
  • System testing – Entire system is tested as per the requirements. Black-box type testing that is based on overall requirements specifications, covers all combined parts of a system.
  • End-to-end testing – Similar to system testing, involves testing of a complete application environment in a situation that mimics real-world use, such as interacting with a database, using network communications, or interacting with other hardware, applications, or systems if appropriate.
  • Sanity testing - Testing to determine if a new software version is performing well enough to accept it for a major testing effort. If application is crashing for initial use then system is not stable enough for further testing and build or application is assigned to fix.
  • Regression testing – Testing the application as a whole for the modification in any module or functionality. Difficult to cover all the system in regression testing so typically automation tools are used for these testing types.
  • Acceptance testing -Normally this type of testing is done to verify if system meets the customer specified requirements. User or customer do this testing to determine whether to accept application.
  • Load testing – Its a performance testing to check system behavior under load. Testing an application under heavy loads, such as testing of a web site under a range of loads to determine at what point the system’s response time degrades or fails.
  • Stress testing – System is stressed beyond its specifications to check how and when it fails. Performed under heavy load like putting large number beyond storage capacity, complex database queries, continuous input to system or database load.
  • Performance testing – Term often used interchangeably with ’stress’ and ‘load’ testing. To check whether system meets performance requirements. Used different performance and load tools to do this.
  • Usability testing – User-friendliness check. Application flow is tested, Can new user understand the application easily, Proper help documented whenever user stuck at any point. Basically system navigation is checked in this testing.
  • Install/uninstall testing - Tested for full, partial, or upgrade install/uninstall processes on different operating systems under different hardware, software environment.
  • Recovery testing – Testing how well a system recovers from crashes, hardware failures, or other catastrophic problems.
  • Security testing – Can system be penetrated by any hacking way? Testing how well the system protects against unauthorized internal or external access. Checked if system, database is safe from external attacks.
  • Compatibility testing – Testing how well software performs in a particular hardware/software/operating system/network environment and different combination s of above.
  • Comparison testing – Comparison of product strengths and weaknesses with previous versions or other similar products.
  • Alpha testing – In house virtual user environment can be created for this type of testing. Testing is done at the end of development. Still minor design changes may be made as a result of such testing.
  • Beta testing – Testing typically done by end-users or others. Final testing before releasing application for commercial purpose.

  • Gray Box Testing - Grey box testing is the combination of black box and white box testing. Intention of this testing is to find out defects related to bad design or bad implementation of the system. In gray box testing, test engineer is equipped with the knowledge of system and designs test cases or test data based on system knowledge.
    For example, consider a hypothetical case wherein you have to test a web application. Functionality of this web application is very simple, you just need to enter your personal details like email and field of interest on the web form and submit this form. Server will get this details, and based on the field of interest pick some articles and mail it to the given email. Email validation is happening at the client side using Java Scripts.

Posted by Posted by hardik.gohil under Filed under Uncategorized Comments 1 Comment »

29th May 2009

Page Life Cycle Events

When a web page is sent to the Web Server for processing, it goes through a sequence of steps before it finally gets displayed in the Web Browser.

From Web Browser to IIS

When a POST request is initiated from the client side, the Web Server traps the request and it is usually routed to an .aspx web page. The request is actually routed to the HTTP Pipeline, a chain of managed objects.

After the HTTP Page handler class is identified, the ProcessRequest() method is called which eventually fires the different page events in the life cycle of a web page.

  1. Page_Init
  2. LoadViewState
  3. LoadPostData
  4. Page_Load
  5. RaisePostDataChangedEvent
  6. RaisePostBackEvent
  7. Page_PreRender
  8. SaveViewState
  9. Page_Render
  10. Page_UnLoad

All these events are associated with their respective handlers and you can even override them to customize their default behavior. The following section discusses each of these events in detail.

The Page Life Cycle Events Explained

Page_Init is first event to be triggered in the page life cycle. It is responsible for the initialization activities that are essential to create a page instance. In this phase of the page life cycle, all the server controls of the web page are initialized to their default values. However, it should be noted that the View State for a page is not available at this stage of the page life cycle and a server control of the page cannot access other server controls of the page at this phase.

You can use the Page_Init event to create or re-create the controls that need to be created or re-created dynamically. The following example illustrates how you can override the OnInit() method.

protected override void OnInit(EventArgs e)
{
if (Page != null)
{
Page.Trace.Write (”The OnInit method has been called”);
base.OnInit(e);
Page.RegisterRequiresPostBack(this);
}

}

LoadViewState : “The load view state stage only happens when the page has been posted back.  During this stage the view state data saved from the previous page visit is loaded and recursively populated into the Page’s control hierarchy”. This method restores the View State information of a web page that was last saved using the SaveViewState method. You can override the LoadViewState() method to get an idea on how the viewstate is actually restored.

The following code example illustrates how you can override the LoadViewState() method.

protected override void LoadViewState(Object viewState)
{
Page.Trace.Write (”The LoadViewState method has been called.”);
if (viewState == null)
{
base.LoadViewState(viewState);
}

}

The LoadPostBackData event is fired next that processes the data that was last posted to the server for all the server controls that requires the same. Note that all controls in an ASP.NET web page is identified by a unique id. The runtime now parses the controls to match their unique ids against the Name Value Collection in the View State for the control (that has its View State enabled) and updates the control with the posted data.

The next event that gets fired is the Page_Load event that typically restores the page’s control values.

protected override void OnLoad(EventArgs e)
{

if(!IsPostBack)
{

//Code to bind static data to the controls

}

}

The RaisePostBackData and the RaisePostBackEvent events call their respective handlers if the request was a postback. The RaisePostBackEvent that executes next “notifies the server control that caused the postback that it should handle an incoming postback event.”

Pre_Render event is triggered next and you can perform any update operations that you require prior to saving the View State and rendering of the web page content.

The following code illustrates how you can override the OnPreRender() method.

protected override void OnPreRender (EventArgs e)
{  Page.Trace.Write (”The OnPreRender has been called.”);
//Any custom code
base.OnPreRender(e);
}

SaveViewState that is called next saves the View State for the web page and its controls in the hidden field called __viewstate that is associated with every web page. Note that the SaveViewMethod that is associated with the SaveViewState event returns a null reference if there is no view state associated with the control. Refer to the code snippet below that illustrates how you can override the SaveViewState() method.

protected override object SaveViewState ()
{  Page.Trace.Write (”The SaveViewState method has been called.”);
//Write your custom code here.
return base.SaveViewState();
}

The rendering event is the next stage in the web page life cycle. This actually is not an event. Rather, it is a state of processing where the Page instance executes this method on all the controls of the web page to eventually render the web page content to the web browser at the client or the requestor side.

Page_UnLoad This event is called prior to the disposal of the web page and usually contains the code that is responsible for releasing of resources that were acquired in the earlier stages of the page life cycle. Once this is done, the web browser receives the “HTTP response packet” and the web page is displayed in the web browser

The web browser now receives the HTTP response packet and displays the same in the web page. This concludes the page life cycle of an ASP.NET web page.

Posted by Posted by kalpesh.patel under Filed under Uncategorized Comments 1 Comment »

29th May 2009

Database Compatibility Level

The database compatibility level determines how certain database behaviors work. For instance, in 90 compatibility, you need to use the OUTER JOIN syntax to do an outer join, whereas in earlier compatibility levels, you can use ‘*=’ and ‘=*’. Contrary to popular myth, all of the behavioral differences ARE documented – in the Books Online section for sp_dbcmptlevel – the SP used to set the compatibility level.

Version of SQL Server that can be reverted to can be one of the following:

60 = SQL Server 6.0
65 = SQL Server 6.5
70 = SQL Server 7.0
80 = SQL Server 2000
90 = SQL Server 2005
100 = SQL Server 2008

The compatibly level setting is used by SQL Server to determine how certain new features should be handled

Compatibility level tells SQL Server how to interpret T-SQL commands. When you perform an upgrade from SQL Server 2000 to SQL Server 2005, the upgrade won’t automatically change the compatibility level from 80 to 90. This is because if you need to change the compatibility level then all the SP’s, DTS, functions etc should be migrated to 90 compatibility level since some of the T-SQL statements are removed in 90. You need to manually change the compatibility level after up gradation. As said above query plan changes between compatibility levels

When upgrading databases from an older version of SQL Server using either the backup and restore method or detach and attach method the compatibility level does not automatically change and therefore your databases still act as though they are running using an earlier version of SQL Server.  From an overall standpoint this is not a major problem, but there are certain features that you will not be able to take advantage of unless your database compatibly level is changed.

Identifying Compatibly Level


To check the compatibility level of your databases you can use one of these methods:


You can see the compatibility level of all databases by doing:


sp_helpdb


Or


For particular database


sp_helpdb ‘NHS_TESTING’


Changing Compatibility Level

sp_dbcmptlevel [ [ @dbname = ] name ]
[ , [ @new_cmptlevel = ] version ]

–to change to level 80
dbo.sp_dbcmptlevel @dbname=N’test’, @new_cmptlevel=80

–to change to level 90
dbo.sp_dbcmptlevel @dbname=N’test’, @new_cmptlevel=90

–or
sp_dbcmptlevel ‘test’, ‘80′

sp_dbcmptlevel ‘test’, ‘90′

 

Testing all procs before upgrading to Compatibility Level 90


If you use SQL Server 2005 but your database is still in Compatibility Level 80 (SQL Server 2000), you can use this script to test if any procs or functions won’t work when you upgrade the database.

The script is quite simple. All that it does is to try to recreate a proc with a different name (Temp_TestProc_DeleteMeTemp_TestProc_DeleteMe). If something goes wrong, the script will record the proc name, the code used to create the proc, and the error message. After trying this with all procs in the database, the procs that couldn’t be created will be listed. Those will be the ones that must be fixed before upgrading the database to compatibility level 90.


A word of caution:

1. If the problem is inside of a dynamic SQL code, it won’t be detected.
2. This script is intended to find incompatibility only in procs and functions. You still have to check codes used to create triggers and views.

Script

DECLARE @sql VARCHAR(max),

@Text VARCHAR(max),

@ProcName VARCHAR(200),

@ProcName1 VARCHAR(200)

DECLARE @T TABLE (ProcName VARCHAR(200), sql VARCHAR(max), ErrorMessage VARCHAR(4000))

DECLARE c Cursor FOR

SELECT O.Name, C.Text

FROM sysobjects O

JOIN syscomments C ON o.ID=C.ID

WHERE O.XType IN (’P',’TF’,'FN’)

and C.text IS NOT NULL

ORDER BY O.Name, C.colid

Open C

FETCH NEXT FROM c INTO @ProcName, @Text

SET @sql=@Text

SET @ProcName1=@ProcName

WHILE @@FETCH_STATUS = 0 BEGIN

FETCH NEXT FROM c INTO @ProcName, @Text

IF @@FETCH_STATUS = 0 AND @ProcName1=@ProcName BEGIN

SET @sql=@sql+@Text

END ELSE BEGIN

SET @sql = REPLACE(@sql, @ProcName1, ‘Temp_TestProc_DeleteMe’) — change proc name

IF EXISTS (SELECT * FROM sysobjects WHERE Name=’Temp_TestProc_DeleteMe’ AND XType=’P') EXEC(’DROP PROC Temp_TestProc_DeleteMe’)

IF EXISTS (SELECT * FROM sysobjects WHERE Name=’Temp_TestProc_DeleteMe’ AND XType IN (’TF’,'FN’)) EXEC(’DROP FUNCTION Temp_TestProc_DeleteMe’)

BEGIN TRY

EXEC(@sql) — try to create the proc

END TRY

BEGIN CATCH

INSERT @T values (@ProcName1, @sql, ERROR_MESSAGE()) — record procs that couldn’t be created

END CATCH

print @ProcName1

SET @sql=@Text

SET @ProcName1=@ProcName

END

END

CLOSE c

DEALLOCATE c

IF EXISTS (SELECT * FROM sysobjects WHERE Name=’Temp_TestProc_DeleteMe’ AND XType=’P') EXEC(’DROP PROC Temp_TestProc_DeleteMe’)

IF EXISTS (SELECT * FROM sysobjects WHERE Name=’Temp_TestProc_DeleteMe’ AND XType IN (’TF’,'FN’)) EXEC(’DROP FUNCTION Temp_TestProc_DeleteMe’)

SELECT * FROM @T

Posted by Posted by Brijesh Patel under Filed under SQL Server Comments No Comments »

29th May 2009

Create ZIP file archives on the fly-PHP

In some website there is need of downloading functionality of multiple files. In that case it is headache for PHP developer that how to give option for download multiple file in single click with lower bandwidth. So, the solution is here: just create zip file containing all the files and give one link for download the zip files.

createZip.inc.php is a class which creates zip file from different files stored on various directories on server and output the necessary request response headers to serve the generated ZIP archive for download.

Example Code Snippet:

include_once("createZip.inc.php");
$createZip = new createZip;
$directoryName = "DownloadImages/";

$createZip -> addDirectory($directoryName); // Adding Directory to ZIP file

$file1ToZip = “image1.jpeg”; // filename1 which is to be added in zip
$fileContents=file_get_contents($file1ToZip);
$createZipFile->addFile($fileContents, $directoryName.$file1ToZip);

$file2ToZip = “image2.jpeg”; // filename2 which is to be added in zip
$fileContents=file_get_contents($file2ToZip);
$createZipFile->addFile($fileContents, $directoryName.$fileToZip);

$outputDir = “./”;
$outputFile = $outputDir.”Images.zip”; // Zip file name

$fd = fopen ($outputFile, “wb”); // Temporary Creating file on disk
$out = fwrite ($fd, $createZip -> getZippedfile()); // Writing zip contents to temporary file
fclose ($fd);

$createZip -> forceDownload($outputFile); // stream the generated ZIP archive for download

@unlink($outputFile); // unlink temporary file

Credits goes to Author of the class: “Rochak Chauhan”
Source: http://www.phpclasses.org/browse/package/2322.html

Author:
Vidyadhar Yagnik
PHP Developer: Digicorp Information Systems Pvt. Ltd.
vidyadhar.yagnik@digi-corp.com

Posted by Posted by vidyadhar.yagnik under Filed under Code, php Comments 6 Comments »

29th May 2009

Shorthand css in Margin and Padding Properties

margin1 • In this property’s value takes for four side like top, right, bottom and left with 10px
margin1 • This value takes only from top with 10px
• This value takes only from right with 15px
• This value takes only from bottom with 20px
• This value takes only from left with 25px
margin2 • This value takes from top 10px, right 15px, bottom 20px and left with 25px
margin3 • This value takes from top and bottom with 10px and left and right 25px
margin4 • This value takes top 10px, right and left 25px and bottom 50px
[Note : Same thing we can use it in Padding also]

Posted by Posted by rohit.dubariya under Filed under design Comments No Comments »

29th May 2009

How to create a vector shape from a raster graphic image using Adobe Fireworks.

Creating vector shape from a raster graphic image:

Step 01

Open image in Adobe Fireworks,
Select magic wand tool from tools, click the cloud (or any object and convert it into path).

Incase you want to select more than one object, keep the shift key pressed & selct the objects with the magic wand.

Step 02

Go to the Select menu, convert marque to path.

Step 03

Vector shape (path) is now ready.

Step 04

You can change the colors from the properties (as shown in screenshot)

Posted by Posted by Amol Vinod under Filed under design Comments No Comments »

29th May 2009

Welcome To Object Oriented Era

Introduction :

My name is Vishal Shukla. I completed Bachelor Of Engineering studies in Information Technology from Gujarat University, in June 2008. I am working with Digicorp Information Systems Pvt. Ltd. since December, 2008 as Java Developer.

Its my hobby to tell others about my hobby :) . I love singing, playing musical instruments. Basically I am a Key board player.  I like to play Guitar, Flute also. In sports, I play cricket and table tennis.

Object Oriented  Programming had always been my favorite subject and so eventually I  biased towards Java. Java, OOPs and Design Patterns are my core competency. I have cleared SCJP certification with 93%.  I have worked with technologies like Struts 2.0, Hibernate 3.0, GWT. I am not having almost no experience in software industry compared to other writers in the blog. But I like to share my knowledge with other and I feel comfortable with OOPs concepts and it is my passion to design classes in object oriented way and keeping the code as much manageable as possible.

Why I Am Here:

Post title may seem strange as object oriented era is began since long time. As far as I have seen, software professionals (usually in java) generally love object oriented concepts and design patterns, however, there are really very rear who does truly understand what object orientation is, what patterns are meant for, what it demands in really implementing it and how easy your life becomes if we really use these. Most of the my posts will be towards implementing patterns in practice and how to code with object oriented methodology.

Posted by Posted by vishal.shukla under Filed under design Comments No Comments »

29th May 2009

HMVC Pattern For GUI Of Swing/GWT/Desktop Application

Why Pattern?

When developing client tier of application using html,  there are certain limitations in using patterns because code is going to be in xml so while developing Swing/GWT/Desktop application’s GUI, we have support of Inheritance, Polymorphism and other constructs of language, so in this world, we can play around with patterns, so if we use patterns properly, reusability can make our life easier and it may get worst if not used properly.

HMVC(Hierarhcical Model View Controller) Introduced:

HMVC can be seen as extended version of MVC pattern. We can divide our GUI into different GUI objects some of which will be for navigation purpose (Menubar), some for displaying/editing data(Grid/Tree/Forms) and others may be use for just layouting purpose. So we clearly identify three major aspect of GUI objects.

  1. Layouting – It is taken care by View in HMVC.
  2. Handling user interactions – Its Controller’s responsibility.
  3. Server Interactions And Hold Data Being Displayed – Model handles this.

In HMVC, we assign dedicated Controller and Model for each of these objects. It is not necessary to provide each of the GUI object its own controller and model. To keep it simple, we can give dedicated controllers and models only to all the Pages, Grid, Dynamic Tree and other major navigation areas e.g. ContentPanel.

Read More >>

Posted by Posted by vishal.shukla under Filed under design Comments No Comments »

29th May 2009

Cursor Optimization Tips

Try to avoid using SQL Server cursors, whenever possible.

SQL Server cursors can results in some performance degradation in comparison with select statements. Try to use correlated sub query or derived tables, if you need to perform row-by-row operations.

Do not forget to close SQL Server cursor when its result set is not needed.

To close SQL Server cursor, you can use CLOSE {cursor_name} command. This command releases the cursor result set and frees any cursor locks held on the rows on which the cursor is positioned.

Do not forget to de allocate SQL Server cursor when the data structures comprising the cursor are not needed.

To de allocate SQL Server cursor, you can use DEALLOCATE {cursor_name} command. This command removes a cursor reference and releases the data structures comprising the cursor.

Try to reduce the number of records to process in the cursor.

To reduce the cursor result set, use the WHERE clause in the cursor’s select statement. It can increase cursor performance and reduce SQL Server overhead.

Try to reduce the number of columns to process in the cursor.

Include in the cursor’s select statement only necessary columns. It will reduce the cursor result set. So, the cursor will use fewer resources. It can increase cursor performance and reduce SQL Server overhead.

Use READ ONLY cursors, whenever possible, instead of updatable cursors.

Because using cursors can reduce concurrency and lead to unnecessary locking, try to use READ ONLY cursors, if you do not need to update cursor result set.

Try avoid using insensitive, static and key set cursors, whenever possible.

These types of cursor produce the largest amount of overhead on SQL Server, because they cause a temporary table to be created in TEMPDB, which results in some performance degradation.

Use FAST_FORWARD cursors, whenever possible.

The FAST_FORWARD cursors produce the least amount of overhead on SQL Server, because there are read-only cursors and can only be scrolled from the first to the last row. Use FAST_FORWARD cursor if you do not need to update cursor result set and the FETCH NEXT will be the only used fetch option.

Use FORWARD_ONLY cursors, if you need updatable cursor and the FETCH NEXT will be the only used fetch option.

If you need read-only cursor and the FETCH NEXT will be the only used fetch option, try to use FAST_FORWARD cursor instead of FORWARD_ONLY cursor. By the way, if one of the FAST_FORWARD or FORWARD_ONLY is specified the other cannot be specified.

Posted by Posted by vivek.navadia under Filed under SQL Server Comments No Comments »