Presentation is loading. Please wait.

Presentation is loading. Please wait.

INTRODUCTION TO INHERITANCE Mimi Opkins CECS277. An Anology  Let’s look at an analogy between the work of an architect and the work of a programmer.

Similar presentations


Presentation on theme: "INTRODUCTION TO INHERITANCE Mimi Opkins CECS277. An Anology  Let’s look at an analogy between the work of an architect and the work of a programmer."— Presentation transcript:

1 INTRODUCTION TO INHERITANCE Mimi Opkins CECS277

2 An Anology  Let’s look at an analogy between the work of an architect and the work of a programmer.  The way that an architect handles the complexity of a large building design sheds some light on how we can organize our own programming work.  This analogy lets us consider the same concepts but without the distraction of Java syntax and semantics.

3 Basics  The architect begins by considering the overall requirements for a building: square footage, number of occupants, types of usage, size of the building lot, height limits, and so on.  After making some initial decisions, the architect faces a basic aspect of any design: The building is composed of floors.  In many buildings, the floors all have common characteristics: the same size and shape; the same number and locations for elevator shafts, stairways, and utility trunks; and so on.  The architect could begin by designing a basic empty floor with all of these common elements in place. Once she installs this plan in the library of her computer aided design (CAD) program, she can then use it repeatedly as the starting point for designing each floor of the building.

4 Basic Empty Floor

5 Types of Objects  The architect may further decide that the building has two main types of floors: office floors and mechanical equipment floors.  The office floors might be of two types: executive office space and standard office space.  Starting from the basic empty floor design, the architect adds components such as lavatories and hallways to make an empty office floor.  She can then add offices and conference rooms to the empty space. Each of the four types of floor is thus derived from the basic empty floor and added to the library.  Drawing the entire building then becomes simply a matter of creating an instance of one of these four floor plans for each story.

6 Mechanical Floor

7 Empty Office Floor

8 Designing Components  The architect uses the same process to design the components that make up the floors.  She might design a basic type of office, with a door, windows, lights, heating, wiring, and so forth, and then derive several types of offices from that one design.  From a given type of office, such as secretarial, she might further refine the design into subtypes such as general secretarial, secretary/receptionist, and executive secretary.

9 Inheriting (Hierarchy of Design)  Creating hierarchies of designs simplifies the architect’s job.  She begins each hierarchy with the most general form of a building component, such as the basic empty floor, and then derives new designs by adding details to the more general forms.  The new designs inherit all of the characteristics of the general form, saving the architect from having to redraw those pieces they share in common.

10 Floor Hierarchy

11 Overriding  In some cases she replaces existing parts of a design, as when she substitutes a wider door for a reception area than appears in the basic secretarial office.  The replacement part overrides what was originally specified in the more general form.  In addition to the components of individual floors, the architect can specify characteristics that are common to all floors, such as a color scheme.  Each floor will then inherit these general properties.

12 Executive Office Floor

13 Standard Office Floor


Download ppt "INTRODUCTION TO INHERITANCE Mimi Opkins CECS277. An Anology  Let’s look at an analogy between the work of an architect and the work of a programmer."

Similar presentations


Ads by Google