Monday 15 July 2013

Debug and Release

Debug and Release
The system.Diagnostics namespace contains the Debug and
Trace classes that include shared methods.

The diffetrnce between these two classes is in the way
Trace and Debug statements are treated at the of creating a
release bulid.

Trace statements are included by default when the program
is compiled in to release build,where as debug statements
are not.The Debug class is used for debugging,however, the
Trace class is used for testing and optimization even after
an application is compiled and released.

Trace works in both debug as well as release mode. The main advantage of using trace over debug is to do performance analysis which can not be done by debug. Trace runs on a different thread thus it does not impact the main code thread.
Note: - There is also a fundamental difference in thinking when we want to use trace and when want to debug. Tracing is a process about getting information regarding program's execution. On the other hand debugging is about finding errors in the code.

What is the difference between Finalize() and Dispose()


Finalize () is called by Garbage Collector implicitly to free unmanaged resources. The garbage collector calls this method at some point after there are no longer valid references to the object. There are some resources like windows handles, database connections which cannot be collected by the garbage collector. Therefore the programmer needs to call Dispose() method of IDisposable interface.
Dispose () of IDisposable interface is called by the programmer to explicitly release resources when they are no longer being used. Dispose () can be called even if other references to the object are alive.


Finalize(): The Finalize destructor is a special method that is called from the class to which it belongs or from the derived class. The Finalize() destructor is called after the last reference to an object is released from the memory. The .Net Framework automatically runs the Finalize() destructor to destroy objects in the memory. However, it is important to remember that the Finalize() destructor may not execute immediately when an object loses scope. It is called by CLR using reference-tracing garbage collection, the CLR periodically check for objects that are not used by the application. When such an object is found, the Finalize() destructor is called automatically and the garbage collector of the CLR release the object from the memory.

Dispose(): The Dispose() method is called to release a resource, such as database connection, as soon as the object using such a resource is no longer in use. Unlike the Finalize() destructor, the Dispose() method is not called automatically and you must explicitly call it from a client application when an object is no longer needed. The IDisposable interface contains the Dispose() method. Therefore , to call the Dispose() method, the class must implement the IDisposable interface.

Grid and Flow Layout
Grid Layout provides absolute positioning for controls placed on the page. Developers that have their roots in rich-client development environments like Visual Basic will find it easier to develop their pages using absolute positioning, because they can place items exactly where they want them. On the other hand, Flow Layout positions items down the page like traditional HTML. Experienced Web developers favor this approach because it results in pages that are compatible with a wider range of browsers.

If you look in to the HTML code created by absolute positioning you can notice lot of DIV tags. While in Flow layout, you can see more of using HTML table to position elements, which is compatible with wide range of browsers.

Grid Layout puts a lot of absolute positioning code into your HTML so you can drag and drop controls onto your page exactly where you want them.  Flow Layout does not give you positioning code; you will need to use CSS to style your pages.  While at first it sounds like Grid Layout would be the better way to go, realize that with Grid Layout you have a rigidly designed web page, targeted to one screen resolution, with the layout code embedded in the HTML markup.  With Flow Layout you are not targeting your page to a specific screen resolution or browser; your are instead writing lightweight markup and CSS provides the styling.

No comments:

Post a Comment