February 8, 2005

Spruce Up Your Built-in Arrays

++ pundits recommend that you replace built-in arrays with st::vector across the board. Sometimes however, built-in arrays are unavoidable due to their unsurpassed efficiency or because your app must interact with external software e.g., a relational database or an XML schema. In the following sections I will present two techniques

Tracking Elapsed Time

This C++ class tracks elapsed time. The mark() method is called at the point of interest, after which there are methods to retrieve the elapsed time between points, total time, or average time. Implemented using the C++ template, it accepts different tick classes for getting the time at the marked

Call a Function or Subroutine with Its String Name Using the Invoke Method

VB6 introduced the CallByName function which allows you to call a function or subroutine using the subroutine or function name stored as a string value. While this function still works in ASP.NET, you do have another option: you can use the Invoke method of the MethodInfo class. This class is

Obtain the Correct Identity Column Value for a Newly Inserted Row

Both select scope_identity and select @@identity return the identity column value of a newly inserted row. However, @@identity is not reliable because it works in a session level. So, suppose stored procedure sp1 contains an insert statement, and after the insert statement, there is a call to another stored procedure,

Enable the Pass By Reference Parameter in WebSphere

In WebLogic 6.1, the default state for the Pass By Reference parameter is true. This is not so in IBM’s WebSphere. To enable the Pass By Reference parameter in WebSphere, use the admin console of IBM’s server: Open the admin console in WebSphere. To view the administrative console page, click

Use Local Classes to Implement Nested Functions in C++

C++ does not support the nested functions. However, you can use local classes to simulate the effects of nested functions. Take the scenario given below: int get_1 (int y){ int i = 9; int get_2(int j) { return j + i; } i+=y; return get_2(9);} Using local classes, you’d do