Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

When is a Subclass a Subclass

When programming, or solving any sort of problem for that matter, abstraction plays a key role in the decision-making process. It allows you to remove irrelevant details in order to understand the bigger picture.

For example, if you were constructing a program to inventory cars for sale at a used car lot, it would not make much sense to design a unique class for each separate car, especially if there are many vehicles in the lot. Instead, you would create a single "Car" class and personalize it for each vehicle.

Abstraction plays a key role in object-oriented programming. As the designer, you decide which characteristics are (and which are not) important as you define classes. In the context of the used car lot example, you could consider separate subclasses of the Car class for each make of car.

Ordering classes hierarchically can save you time and effort. For instance, a Corolla and a Camry are individual models of cars, but they both inherit certain characteristics from their shared make, Toyota.

However, hierarchies present their own challenges. Just because you can construct hierarchies, it does not necessarily mean that it is useful to do so. Consider the Unified Modeling Language (UML) class diagram below, which contains a set of subclasses for the superclass Car.

In this case, creating separate subclasses of Car is more trouble that it is worth, because the inventory program probably does not have to treat different models of cars in different ways. Therefore, it is probably more appropriate simply to designate the make of the car in a field of the class, as illustrated in the UML class diagram below.

The larger question at play is this: "What characteristic of an object is significant enough to warrant a subclass rather than simply data in a field?"

Think about an application in your field of expertise and the classes that you would define for that application.

Describes the application you choose and the class within that application.

Identify one or two key distinctions within that class that would prompt you to create subclasses instead of fields within the main class.

Explain your reasoning, giving specific examples of objects in each of the classes and subclasses you discuss, and draw a UML class diagram to support your claim.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93125549

Have any Question?


Related Questions in Computer Engineering

Question suppose that your uncle is a real estate agent and

Question : Suppose that your uncle is a real estate agent and he decided to have a web-site to list his available real estate properties. And use a laptop computer to show clients these properties. What hardware is neede ...

What is a domain name in the context of internet what is

What is a domain name in the context of Internet? What is the procedure to get a domain name and link it to an Internet Protocol (IP) address? Use an example.

A street vendor is asking people to play a simple game you

A street vendor is asking people to play a simple game. You roll a pair of dice. If the sum on the dice is 10 or higher, you win $10. If you roll a pair of 1's, you win $59. Otherwise you lose $5. If the random variable ...

Question suppose we have a packet switched network in which

Question : Suppose we have a packet switched network in which two stations A and B are always separated by four intermediate nodes/switches, i.e., the two are 5 hops apart. Suppose station A wishes to transmit 1 MB (1024 ...

You are running a memory-intensive multimedia application

You are running a memory-intensive multimedia application on your computer, which has 1 GB RAM installed. You observe that the computer momentarily stops responding when you switch between two multimedia applications. 1. ...

The chancellor of a university has commissioned a team to

The Chancellor of a university has commissioned a team to collect data on students' GPAs (M = 3.0; SD = 0.5) and the amount of time they spend bar hopping every week (measured in minutes: M = 720; SD = 240). They find a ...

On the spot courier services grew and changed over the

On the Spot courier services grew and changed over the years. At first, Bill received requests for package pickups on his mobile phone, recorded that information in a log, and would then drive around to retrieve all the ...

What is the solution for chapter 15 3e for java programming

What is the solution for chapter 15 3e for java programming 8th edition Create a JFrame that holds fjive buttons with the names of five different fonts. Include a sexth button that the user can click to make a font large ...

Question specify design implement im c a class for a card

Question : Specify, design implement im c++ a class for a card in a deck of playing cards. The object should contain methods for setting and retrieving the suit and rank of the card. Make sure to separate your work on s ...

Restaurant management database project the restaurant

Restaurant Management Database Project : The restaurant maintains the catalog for the list of food and beverage items that it provides. Apart from providing food facility at their own premises, the restaurant takes order ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As