23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

• Divide-<strong>and</strong>-conquer (Section 11.1.1)<br />

• Prune-<strong>and</strong>-search, also known as decrease-<strong>and</strong>-conquer (Section 11.7.1)<br />

• Brute force (Section 12.2.1)<br />

• The greedy method (Section 12.4.2)<br />

• Dynamic programm<strong>in</strong>g (Section 12.5.2).<br />

Likewise, some of the software eng<strong>in</strong>eer<strong>in</strong>g design patterns we discuss <strong>in</strong>clude:<br />

• Position (Section 6.2.2)<br />

• Adapter (Section 6.1.2)<br />

• Iterator (Section 6.3)<br />

• Template method (Sections 7.3.7, 11.6, <strong>and</strong> 13.3.2)<br />

• Composition (Section 8.1.2)<br />

• Comparator (Section 8.1.2)<br />

• Decorator (Section 13.3.1).<br />

Rather than expla<strong>in</strong> each of these concepts here, however, we <strong>in</strong>troduce them<br />

throughout the text as noted above. For each pattern, be it for algorithm eng<strong>in</strong>eer<strong>in</strong>g<br />

or software eng<strong>in</strong>eer<strong>in</strong>g, we expla<strong>in</strong> its general use <strong>and</strong> we illustrate it with at least<br />

one concrete example.<br />

2.2 Inheritance <strong>and</strong> Polymorphism<br />

To take advantage of hierarchical relationships, which are common <strong>in</strong> software<br />

projects, the object-oriented design approach provides ways of reus<strong>in</strong>g code.<br />

2.2.1 Inheritance<br />

The object-oriented paradigm provides a modular <strong>and</strong> hierarchical organiz<strong>in</strong>g<br />

structure for reus<strong>in</strong>g code, through a technique called <strong>in</strong>heritance. This technique<br />

allows the design of general classes that can be specialized to more particular<br />

classes, with the specialized classes reus<strong>in</strong>g the code from the general class. The<br />

general class, which is also known as a base class or superclass, can def<strong>in</strong>e<br />

st<strong>and</strong>ard <strong>in</strong>stance variables <strong>and</strong> methods that apply <strong>in</strong> a multitude of situations. A<br />

class that specializes, or extends, or <strong>in</strong>herits from, a superclass need not give new<br />

implementations for the general methods, for it <strong>in</strong>herits them. It should only def<strong>in</strong>e<br />

those methods that are specialized for this particular subclass.<br />

96

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

Saved successfully!

Ooh no, something went wrong!