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

Remove TopDealMaster from your PC

Ah Yes. Another online shopping helper. We all need help shopping online, right? Wrong!. TopDealMaster is another piece of bogus softwaer the promises to help you find the best deals online. All it manages to do is bloat your computer with useless code and open you up to further issues. If you … [Read More...]

Why You Need to Regularly Defragment Your Hard Drive

Your computer's hard disk of is one of the most vital parts of your machine. It needs to operate reliably and quickly for your computer to function well. For this to happen, we need to routinely perform some fundamental maintenance. Hard disk defragmentation is frequently performed by computer … [Read More...]

Serial Ports

National Semiconductor has made the UART chips which have driven the PC's serial port ever since the emergence of IBM's first PC. The original PC serial interface used the INS8250-B UART chip. This could receive and transmit data … [Read More...]

Revolutionize Your Internet Experience with Orbi 960 – The Ultimate WiFi System

In a world where seamless connectivity is essential, slow and unreliable internet connections are a major problem. Whether you are running a business, … [Read More...]

Do You Need a VPN When Trading Cryptocurrency?

There’s no doubt that the biggest global industries in 2023 are tech-driven, while there remains a significant crossover between many of these … [Read More...]

Goodbye Bitcoin: the 3 alternative cryptocurrencies that have great upside potential, according to experts

Bitcoin has been a very lucrative investment for people that got into it early. One report from The Motley Fool pointed out that $10 of bitcoin … [Read More...]

Self-driving cars face their Achilles’ heel and may be targets of hackers

The market for self-driving cars is booming. Customers spent $22.22 billion on these autonomous vehicles in 2021 and they will likely spend more in … [Read More...]

How to avoid scams with bitcoin and other cryptocurrencies

Cryptocurrencies got a bad reputation when scams multiplied like ants on a piece of cake. Even today many people associate bitcoin and other … [Read More...]

WHAT IS CLOUD COMPUTING AND WHAT ARE ITS MAIN BENEFITS?

Users are Increasingly using cloud computing to store their information, which is replacing local storage. The business digitization process goes … [Read More...]

Guides

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

Recent Posts

Navegaki.com.br Removal

Navagaki.com.br is a browser hijacker. The .br in the domain name is for domain names that are registered in Brazil. However, that does not mean it … [Read More...]

Testing the External DV Converter

To open Movie Maker, click Start > Programs > Accessories > Windows Movie Maker. Select Capture from video device to launch the Video … [Read More...]

Windows Virtual Security

Windows Virtual Security Welcome to another of our virus removal guides. This article will go over how to remove Windows Virtual Security. … [Read More...]

[footer_backtotop]

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