The key to abstraction is to identify a block of code (within an algorithm) that is somewhat self contained and related. This process, once again, requires some experience. There are methods to evaluate how self contained is a block of code based on the usage of variables. We will revisit this topic in the module that discusses subroutines.
As an example, sometimes we come up with algorithm
3 first, then decide that it is too much
to read. Then, we see a self contained block of code as
algorithm 2, and extract that out of the
main algorithm. Once we extract the self contained block of code, we
replace it with a one sentence description ``find a prime factor
of
''. We also end up with a second algorithm as algorithm
2. The main algorithm, then, becomes
algorithm 1, which is considerably easier
to read than algorithm 3.