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

Keep Track of Product Serial Numbers

It's always a good idea to document serial numbers of the high priced gadgets in your home or business. If your place burns down, gets damaged in a storm or is broken into, having that information is useful. It is good for many reasons. It can help for tax purposes if you have equipment you need to … [Read More...]

FusionPlayer

The whole premise of FusionPlayer is that it will let you create media play lists using videos on the computer and videos from the Internet. That is its hook and the incentive to install the program. The truth is, however, this is a PUP (potentially unwanted program)that is nothing more than a … [Read More...]

Rango Protection 2014 – Antispyware 2014

Rango XP Protection 2014 is known as malware. This is a fake antivirus client that get's installed normally through a trojan virus. In most cases the trojan is bundled with other software programs that are free around the internet. Once you download and install the program the trojan then goes out … [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...]

Graphic Designers on Reddit Share their Views of AI

There are clearly a lot of positive things about AI. However, it is not a good thing for everyone. One of the things that many people are worried … [Read More...]

Redditors Talk About the Impact of AI on Freelance Writers

AI technology has had a huge impact on our lives. A 2023 survey by Pew Research found that 56% of people use AI at least once a day or once a week. … [Read More...]

11 Most Popular Books on Perl Programming

Perl is not the most popular programming language. It has only one million users, compared to 12 million that use Python. However, it has a lot of … [Read More...]

Guides

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

Recent Posts

6 Tips for Social Media Success in the New year

Social media continues to grow in leaps and bounds. With every passing year, we learn new things about what works and what fails. One thing that is … [Read More...]

Driver Reviver Review

Driver Reviver is a very easy to use Drivers update program. It is capable of updating outdated drivers on your computer as well as missing … [Read More...]

9 Steps to Understanding the Mobile App Development Process

Are you considering getting on the mobile app development market? That can be a wise move. The market for mobile apps is expected to exceed $407 … [Read More...]

[footer_backtotop]

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