pctechguide.com

  • Home
  • Guides
  • Tutorials
  • Articles
  • Reviews
  • Glossary
  • Contact

Object Oriented Programming 4

In object oriented (OO) programming, class inheritance is the process of deriving new classes from existing classes. It’s a technique that was developed, at least in part, to enable the better reuse of existing code, but it can have its downsides too. It can lead to complications in the design of software, and headaches with code management. However, inheritance is a requisite of OO programming, and most problems with using it come from a lack of preparation at the analysis and design stage. Assuming that you’re familiar with the OO class, we’ll now take a look at this powerful programming method that, when properly employed, helps enable the production of secure, maintainable and reusable software.

The basic principle of class inheritance is pretty straight-forward. When using a language that supports inheritance, the idea is to start with a base class that has minimal functionality. This base class is then used as a starting point to build new classes that require extended or slightly different functionality. The base class is sometimes called the super class, and the classes built from it are called derived classes. In most OO languages a derived class can have more than one base class, and this is called multiple inheritance. If a derived class needs to modify methods of a base class, it can do this using the OO practice of polymorphism.

An object oriented design for a large project may have many layers of inheritance. The structure of inheritance is referred to (interchangeably) as the class hierarchy, the class tree, or the class lattice. It requires a lot of thought to put together a good class hierarchy, as this is the area of OO design that causes the most complications, for some of the following reasons.

  • With large class trees the encapsulation of code can begin to break down. A class low down the tree may have code spread through several classes going back deep into the tree structure.
  • Forced use of inheritance for its own sake can lead to badly constructed inheritance trees and overuse of polymorphism. This results in bulky objects with a lot of redundancy, inefficient code and designs that are hard to understand.
  • Programmers will find it difficult to be completely aware of all functionality provided in a deep class inheritance tree. Over time, the danger is that functionality will be duplicated, so periodic audits of the class structure, and possibly reorganisations, may be required.

Clearly, then, when using OO programming and inheritance, getting the design of the project right is paramount. Work on a thorough system analysis is essential, because late modifications to a class hierarchy can be very time consuming.

Next we’ll take a look at an example of class hierarchy design. We’ll be designing a maze game, creating an OO design, but we’re not going to select a programming language at this stage. We’ll see how we can analyse the problem from an OO perspective, and produce a workable OO design solution that can be translated into implementation code.

  • Object Oriented Programming 2
  • Object Oriented Programming 3
  • Object Oriented Programming 4
  • Object Oriented Programming 5
  • Object Oriented Programming 6
  • Object Oriented Programming 7
  • Object Oriented Programming 8

Filed Under: Object Oriented Programming

Latest Articles

Pentium P5 microarchitecture – superscalar and 64 bit data

First introduced in 1993, the Pentium was the successor to Intel's 486 line of CPUs and the defining processor of the fifth generation. The original Pentium microprocessor had the internal code name P5, and was a pipelined in-order superscalar microprocessor, produced using a 0.8 µm … [Read More...]

Site Navigation

There are several methods of navigating the site, including the main menu, side menu, and a crumb trail. There are also context menus and previous/next links within guides, articles and tutorials, and finally a site map giving an overall site image. There were a number of principle aims … [Read More...]

ADSL Setup

Having networked your PC and installed the ADSL equipment, you need now to set up the Internet Protocol (IP) configuration to enable your PC to access the broadband Internet service. The steps involved will be described in the context of a basic ADSL modem/router, as used by BT in 2000, when ADSL … [Read More...]

Everything You Need to Know About Sourcing Circuit Boards From U.S. Suppliers

In This Article This article includes: Why Source PCBs From the United States?How to Get a Quote From a U.S.-Based PCB ManufacturerThe Top U.S. … [Read More...]

Top Taplio Alternatives in 2025 : Why MagicPost Leads for LinkedIn Posting ?

LinkedIn has become a strong platform for professionals, creators, and businesses to establish authority, grow networks, and elicit engagement. Simple … [Read More...]

Shocking Cybercrime Statistics for 2025

People all over the world are becoming more concerned about cybercrime than ever. We have recently collected some statistics on this topic and … [Read More...]

Gaming Laptop Security Guide: Protecting Your High-End Hardware Investment in 2025

Since Jacob took over PC Tech Guide, we’ve looked at how tech intersects with personal well-being and digital safety. Gaming laptops are now … [Read More...]

20 Cool Creative Commons Photographs About the Future of AI

AI technology is starting to have a huge impact on our lives. The market value for AI is estimated to have been worth $279.22 billion in 2024 and it … [Read More...]

13 Impressive Stats on the Future of AI

AI technology is starting to become much more important in our everyday lives. Many businesses are using it as well. While he has created a lot of … [Read More...]

Guides

  • Computer Communications
  • Mobile Computing
  • PC Components
  • PC Data Storage
  • PC Input-Output
  • PC Multimedia
  • Processors (CPUs)

Recent Posts

Bit-Depth Printers

When a scanner converts something into digital form, it looks at the image pixel by pixel and records what it sees. That part … [Read More...]

Stellar Phoenix SQL Recovery Review

Stellar Phoenix SQL Recovery Stellar SQL Recovery can rebuild/repair the SQL tables. There aren't very many product choices when it comes to SQL … [Read More...]

11 alternatives to Movie Maker for editing videos in Windows 10

We bring you a short list with the top 11 alternatives to Movie Maker so you can edit your videos in Windows 10. Even today, we all remember with … [Read More...]

[footer_backtotop]

Copyright © 2026 About | Privacy | Contact Information | Wrtie For Us | Disclaimer | Copyright License | Authors