Tuesday, October 21, 2003


Source: Vincent Massol Think Tank

Let's imagine you wish to perform unit test for code that calls the database. Let's also imagine that you want to test in integration, i.e. verify that the SQL query does actually goes to the database and returns database data.

The traditional approach is to:

  1. Preload static data before the test suite runs
  2. Load specific test related data in the database before each test. A variation is to restore the modified data at the end of the test

There are several disadvantages to point 2:

  • Finding out the specific data that needs to be set up for the test is time-consuming and you often need to know the full database schema (and not only the domain you're working on). This is especially true for big projects
  • There are referential integrity concerns that forces you to set up again data for a lot of other tables that the ones you are concerned with as they are linked through keys

One solution that our project team discussed yesterday is about using transaction rollbacks. It would work as follows:

  • Before the test suite starts, load the database with full data (this is done only once and usually takes a good 5 minutes for complex projets)
  • Before the test starts, start a transaction (in JUnit's setUp() method for example)
  • run the test
  • rollback the transaction to restore the database data in a pristine state

I was suprised to see no mention of this on the articles mentioning database unit testing (http://www.dallaway.com/acad/dbunit.html, http://www.dbunit.org/bestpractices.html). The reason may be that there are some glitches with this technique that make it impossible to use in practice... I'd like to know what you think? Have you done this before?

Notes:

  • The code under tests should not create a new transaction as nested transactions are usually not supported
[Vincent Massol Think Tank]
5:46:52 PM    trackback []     Articulate [] 

Source: Ming the Mechanic

 If you're trying deliberately to think creatively, to come up with new ideas, having a set of stimulating tricks can help. It is quite possible to stimulate lateral thinking in fairly mechanical ways. Lateral thinking is where, instead of following the usual step-by-step logical paths of thinking, you sort of jump to the side and come up with something entirely unexpected. Ed de Bono is one of the champions of lateral thinking.

An effective and well-known way of provoking lateral thinking is to introduce a random element. For example, while closing your eyes, open up a dictionary and point somewhere on the page, and see what word it is. And then pretend that it has something to do with your problem at hand, and try to figure out how. And some percentage of the time, you'll actually come up with surprisingly good ideas. If you have no problem or idea to start with, you can pick up two words by that method, and then pretend that they relate to each other, and sometime you might actually invent something new.

Arthur Koestler talked about "bisociation" which is the theory that new ideas arise from the combination of two previously separate ideas. I.e. you combine some things in a way that hadn't been imagined before, and to your surprise you realize they actually fit, and a new idea, or a new invention, might come from it. One can practice this simply by taking random words, items or subjects, and exploring what happens if they're combined.

If you do have an idea or problem or invention you're exploring, which looks promising, or which presents an obstacle, there are many things one can do with it to look for creative ways of making it work. Supposedly victorian engineers would work designs for new machines through a checklist of ways it could me done differently, mechanically speaking, and new, better ways might emerge. Some of the same tricks can be applied to most new ideas, even if they aren't exactly about a mechanical invention.

Magnify it; Reduce it.
Reverse it; Spin it; Re-orientate it.
Turn it inside out.
Heat it up; Cool it down.
Move it forward; Roll it backward.
Raise it; Lower it.
Move it left; Move it right.
Project it; Inject it.
Squeeze it; Expand it.
Replicate it; Decimate it; Weed it out.
Make it portable; Make it importable.
Speed it up; Slow it down.
Age it; Rejuvenate it.
Transpose to the past or the future.
Change from analog to digital.
Implement it in hardware or software.
Be it; Do it; Have it.
Take it apart; Put it together
Make it heavier, lighter.
Centralize it; De-centralize it.
Grow it; Design it
Focus on it; Make it peripheral.
Explode it; Implode it.
Wear it, live in it, sit on it, transport it, eat it.
Color it, add sound, touch it.
Take on its identity, what does it feel like, what does it want to do?
Split it in complementary parts, or put it together with its counterparts.
If this exists, what else would exist?
Make it transparent, clear, fuzzy, opaque.
Energize it; Tap its energy.
Make it 1-, 2-, 3-, or 4-dimensional.
Make it have two states (on/off), or have infinite grades.
Put in water, underground, in the air, or in space.
Pressurize it; put it in vacuum.
Make it weightless; increase the gravity.

In other words, play with the new idea or the problem at hand. Stretch it, bend it, turn it upside down, inside out, in any way you can think of. And you might realize that what didn't work on a large scale might work on a small scale, and what didn't work one way might work the opposite way.

Also, when you play with actual perceptions, you're making things more real. Purely abstract ideas have less chance of materializing than if you can actually see them, feel them, hear them, smell them, taste them.

See an old article by Keith Hudson that inspired this article here. [Ming the Mechanic]


2:21:12 PM    trackback []     Articulate [] 

Source: Wes' Puzzling Blog

Have you ever edited a result set in Enterprise Manager and wished that there was a way to set a field to null? Your in luck because there is a way.

If you are in the field you want to set null you just hit CTRL-0 and leave the field and magically the field has a null value, of course you can only do this on fields that are actually nullable.

Maybe I'm the only person that didn't know about this but I posted this just incase someone else can benefit from this.

[Wes' Puzzling Blog]
8:58:16 AM    trackback []     Articulate []