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

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Filed Under: Object Oriented Programming

Latest Articles

OLED Flat Panels – Explain oled

Many electronic appliances are at the threshold of a revolution that began with the discovery of polymeric conductors in the 1970s. Polymeric materials, which have historically been classified exclusively as electrical insulators, are now finding varied applications as both conductors and … [Read More...]

Object Oriented Programming 3

Encapsulation From what we've covered so far we can suggest that: A class is an abstract data type made up of a combination of the relevant data and associated methods. Each class not only has specific data members, it also has it's member functions or methods. The methods are the tasks … [Read More...]

Token Ring Networks

In 1984, IBM introduced the 4 Mbit/s Token Ring network. Instead of the normal plug and socket arrangement of male and female gendered connectors, the IBM data connector (IDC) was a sort of hermaphrodite, designed to mate with itself. Although … [Read More...]

Everything You Need to Know About Video Editing Programs

The demand for video marketing services is skyrocketing. In Europe alone, the market for video marketing is projected to be worth $673 million by … [Read More...]

The Impact of Modern Technology on Relationships

Technology has changed dating in tremendous ways. It has gradually become more immersed in the modern quest for intimacy. In 1995, only 2% of … [Read More...]

Benefits of Instagram as a Powerful Marketing Tool for B2B Brands

The ever-growing popularity of the social networking app Instagram makes it a popular channel for businesses to launch their services, advertising, … [Read More...]

6 Simple Ways to Improve Security of Windows Computers

Millions of Windows PC users experience some form of cybercrime every year. According to one study, there were 2,953 reported cyberattacks between … [Read More...]

2021 PC Hardware Releases to Bolster Your Gaming

If you are a PC gamer, then chances are you are looking to upgrade your kit over the coming year. However, a lot of money can go into building the … [Read More...]

New Transfer Feature in Dropbox Enable Sharing files with Third Parties

Dropbox has been a popular P2P sharing platform for many years. They don't announce new features as often as other applications, since they have a … [Read More...]

Guides

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

Recent Posts

Routers

Routing achieved commercial popularity in the mid-1980s - at a time when large-scale internetworking began to replace the … [Read More...]

Bluetooth technology

Named after a tenth-century Danish king, Bluetooth is a specification for a small form-factor, low-cost radio solution … [Read More...]

Remove System Doctor 2014 Virus

System Doctor 2014 is a malware client. That means it's a computer virus. This malware acts like it is a real antivirus client. It shows false error … [Read More...]

[footer_backtotop]

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