14.01.2020 Views

ABAP_to_the_Future

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Eliminating Dependencies 3.1

3.1 Eliminating Dependencies

In the US show “Jeopardy!,” the contesta nt’s answer must be in the form of a

question.

GAME SHOW HOST: Something that stops you dead in your tracks when you

want to write a test.

CONTESTANT: What is a dependency?

The contestant is correct. But to go into a little more detail, a dependency is what

you have when you want to do a test for your productive code but you can’t—

because the productive code reads from the database or writes to the database or

accesses some external system or sends an email or needs some input from a user

or one of a million other things you cannot or do not want to do in the development

environment.

As an example, consider a monolithic SAP program that schedules feeding time at

the zoo and makes sure all the animals get the right amount and type of food.

Everything works fine. The keepers have somesort of mobile device that they can

query to see what animals need feeding next, and there is some sort of feedback

they have to give after feeding the animal s. They want to keep track of the food

inventory, and so on; none of the details are important for this example.

All is well until one day they get two pandas on loan from China, and the programmer

has to make some changes to accommodate their specific panda-type

needs (e.g., bamboo shoots) without mess ing up all the othe r animals. The programmer

can do a unit test on the panda-specific changes he has made, but how

can he be sure that an unforeseen side effect will not starve the lions, causing

them to break out and eat all the birds and all the monkeys before breaking into

the insect house and crushing and eating the beehive?

Normally, there’s no way to do it. There are just to o many dependencies. The

program needs to read the system time, read the configuration details on what

animal gets fed when, read and write inventory levels, send messages to the zookeepers,

receive and proces s input from those same zookeepers, interface with

assorted external systems, and so on.

However, you really don’t want to risk th e existing system breaking and leading

the lions to dine on finch, chimps, and mushy bees, so how can we enable tests?

139

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!