April 16, 2007
A shallow copy of an object copies all of the member field values. This works well if the fields are values, but may not be what you want for fields that point to dynamically allocated memory. The pointer will be copied. but the memory it points to will not be copied — the field in both the original object and the copy will then point to the same dynamically allocated memory, which is not usually what you want. The default copy constructor and assignment operator make shallow copies.A deep copy copies all fields, and makes copies of dynamically allocated memory pointed to by the fields. To make a deep copy, you must write a copy constructor and overload the assignment operator, otherwise the copy will point to the original, with disasterous consequences.
Deep copies need …
If an object has pointers to dynamically allocated memory, and the dynamically allocated memory needs to be copied when the original object is copied, then a deep copy is required.
A class that requires deep copies generally needs:
Borrowed from this site.
Filed under:
C++ by admin
April 12, 2007
I use MySQL a lot and when designing queries, I use the EXPLAIN keyword to help optimize performance. This can be done at any MySQL command prompt. However, it is not so easy in Oracle I am finding out. One drawback is that you need to use the SQL Plus client, as other Oracle command prompts do not work.
Tested against Oracle 10.2g.
Here is a chart of how to analyze Oracle queries, starting with how to set the proper permissions, and detailing the options when executing the trace. I am including this table here so I do not have to count on the site I got it from to stay active.
| How to use Autotrace in Oracle SQL Plus |
| Create Plan Table |
SQL> @?/rdbms/admin/catplan.sql |
| Create PLUSTRACE Role |
SQL> @?/sqlplus/admin/plustrce.sql |
| Grant PLUSTRACE Role |
GRANT plustrace TO <user_name>; |
SQL> grant
plustrace TO uwclass; |
| |
| Syntax |
SET AUTOT[RACE] {OFF | ON | TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]] |
| Trace and Run |
SQL> set autotrace on
SQL> SELECT * FROM dual;
|
| Trace Only |
SQL> set autotrace traceonly
SQL> SELECT * FROM dual; |
| Trace and Explain |
SQL> set autotrace traceonly explain
SQL> SELECT * FROM dual; |
| Trace and Statistics |
SQL> set autotrace traceonly statistics
SQL> SELECT * FROM dual; |
| Stop Tracing |
SET AUTOTRACE OFF |
| SQL> set autotrace off |
Info “borrowed” from: http://www.psoug.org/reference/autotrace.html
For MS SQL Server equivalent information, do a search on “Query Execution Plan”.
April 12, 2007
In case anyone else is having this problem and cannot find a solution:
I just created a new unit testing project with Visual Studio, using C#. The skeleton program it creates looks simple enough. The skeleton code that was generated for me has these 4 namespace includes:
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Without changing anything in the code or project, I attempted to build it, I got these errors:
error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?)
This is weird since a skeleton project should just build. I searched online for these errors and found NO ONE posting the same problem. Hoping to just simply be able to add a reference to the project, I looked for any DLL files on my system named “Microsoft.VisualStudio.TestTools.UnitTesting.dll” or similar and found nothing. I looked in the built-in list of .Net namespaces and could not find it either.
Solution:
Searching for less similar named references, I happened to stumble upon the correct reference. It is a built-in .Net namespace reference, just not named “Microsoft.VisualStudio.TestTools.UnitTesting”, but rather: “Microsoft.VisualStudio.QualityTools.UnitTestFramework”. To add this to your unit test project, go to “Add Reference” and it should be listed under the .Net tab in the mix of other namespaces. When I added this to the references, the code compiled just fine, without modifying the namespace includes or anything.
As far as I know, unit testing is only available in Visual Studio 2005 Team Suite edition, but I have read it is also in Visual Studio 2005 for Team Testers edition.