Answers for Day 20

IOTA^_^    

Sams Teach Yourself ASP.NET in 21 Days, Second Edition
By Chris Payne
Table of Contents
Appendix A.  Answers to Quiz Questions


Quiz

1:

Will the following code snippet work?

 try    objCmd.Connection.Open    objReader = objCmd.ExecuteReader end try 
A1:

No. There's no catch statement.

2:

True or False: The finally statement is required in a try...catch block.

A1:

False.

3:

What is the trace tool, and how do you enable it at the page level? At the application level?

A1:

The trace tool gives your applications statistical and debugging capabilities by printing information to a log.

To enable it at the page level, add Trace="true" to the page directive. To enable it at the application level, add <trace enabled="true"/> to web.config.

4:

What's the difference between Trace.Write and Trace.Warn?

A1:

They're exactly the same, except that Trace.Warn outputs information in red.

5:

True or False: Trace.Write and Trace.Warn print information in the client display.

A1:

False. They only print to the trace log.

6:

What are symbol files?

A1:

Symbol files tell a debugger how to map executing instructions to lines in an uncompiled source file.

7:

True or False: Attaching a debugger to an application is a perfectly safe procedure and doesn't interrupt program usage.

A1:

False. The debugger incurs a lot of overhead and blocks users from the debugged application.

8:

What's a breakpoint, and what is it used for?

A1:

A breakpoint is a point in your application where execution is halted. You can use breakpoints to determine where errors occur in your code.

Exercises

1:

Use the trace tool to compare performance times in your application. Determine if disabling viewstate results in faster execution times, what the difference is between using an OleDbDataReader versus a DataSet, and if comments affect execution times at all.

A1:

Viewstate test:

Average total execution time when using an OleDbDataReader, returning 12 rows, viewstate enabled (5 tries): .1236036 seconds

Average total execution time when using an OleDbDataReader, returning 12 rows, viewstate disabled (5 tries): .0931142 seconds

Result: ~33% increase in execution times with viewstate enabled

Data test:

Average total execution time when using an OleDbDataReader, returning 12 rows (5 tries): .1295954 seconds

Average total execution time when using a DataSet, returning 12 rows (5 tries): .15766 seconds

Result: ~22% increase in execution times when using a DataSet.

Comments test:

Average total execution time when using 20 lines of comments, 80 characters each (5 tries): .1004834 seconds

Average total execution time when using 0 lines of comments (5 tries): .1082878 seconds

Result: ~.08% increase in execution times without using comments. Not statistically significant!

2:

Explore the CLR debugger and step through the execution of several pages. Use the Watch window to watch your variables as your application progresses. Try purposely introducing some errors and see what happens in the debugger.

A1:

Try exploring the Tools, Options menu. The Debugging tab allows you to customize the way the debugger works. The Debug menu provides several different ways to execute your application, such as different stepping methods, running to cursors, and executing without debugging. Try debugging some compiled business objects created in earlier lessons. Run them from within ASP.NET pages, and watch the output in the debugger.


    IOTA^_^    
    Top


    Sams Teach Yourself ASP. NET in 21 Days
    Sams Teach Yourself ASP.NET in 21 Days (2nd Edition)
    ISBN: 0672324458
    EAN: 2147483647
    Year: 2003
    Pages: 307
    Authors: Chris Payne

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net