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

Advantages and disadvantages of using Perl in web programming

Web pages are designed using programming codes and a number of technologies as tools to achieve the desired objectives. An example of the above described, are the pages of animations in which you use resources such as HTML5 or OpenGL programming language, among others. However, there are simple to … [Read More...]

Website Technical Audit: What Should Be Checked on the Website?

If you want your company’s website to perform effectively, you need to do a website technical audit. It will improve the customer's experience and help get more conversions and leads. When people face poor interaction with your website, they become frustrated and will never come to you again. Broken … [Read More...]

Factors to Consider When Resizing an Image

There are many things that you have to think about when you plan on changing the size of an image. You don't want to make arbitrary decisions, because selecting the correct size is very important. Here are some things that you have to take into consideration. Dimension and size constraints of … [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

Handheld Organizer origins

The term handheld computer has been applied to a wide range of portable electronic devices over the years. Its origins can reasonably be traced … [Read More...]

(no title)

Interesting tidbit about app indexing for both Apple and Google. Google already has put into motion ways of indexing an app which may prove to be a … [Read More...]

Android’s Quick Draining Apps – What To Do

Android devices are like our best friends. With endless gaming and networking,  your phone or tablet can really make your life easier. However, there … [Read More...]

[footer_backtotop]

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