Questions tagged [overriding]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer

Should I use method overloading or method overriding when creating converter service

In a Java Spring API, I'm implementing GeoJson Conversion Service to convert different types to geojson, I have GeoJsonConversionService interface, and one implementation is ...
zyydoosh's user avatar
  • 103
2 votes
1 answer

How can I enforce that decorator pattern is complete at compile time?

I have a C++ class (Class D) that is a decorator of another class (Class B). Class D inherits from B and also requires an instance of B to construct that it keeps track of. Class D overrides all ...
Alexis Winters's user avatar
4 votes
4 answers

How name public method that relays to abstract methods of its children (c#)

I've run into the following situation multiple times, and in every case have struggled with the naming. I want a class to force its children to implement a method, but I want the parent class to be ...
Adam B's user avatar
  • 1,565
1 vote
5 answers

Is this a proper use of overriding according to LSP?

I have a abstract class named MotorizedVehicle that contains an implemented gas- and brake-function. I want to make a Truck class that extends this class and uses gas exactly in the same way as ...
Felix Jönsson's user avatar
0 votes
4 answers

C# refactoring with inheritance

I have two classes which contains almost same method. How can I refactor this with inheriting one class by other class. class A{ public void run(){ // task 1 // task 2 // task 3 } ...
Buddhika Chathuranga's user avatar
2 votes
1 answer

UML - Changing the visibility of operations when overriding them

I am trying to find out if it is allowed in the UML to change the visibility (access modifier) of an operation when overriding it. For example, in Java it is possible to increase the visibility of an ...
xoric's user avatar
  • 51
-1 votes
2 answers

Should we override all method overloads

Usually method overloads delegate their parameters to the more detailed overloads with default values. here is an example A(x) => A(x, null); A(x, y) => A(x, y, null); A(x, y, z) => ...; ...
M.kazem Akhgary's user avatar
1 vote
1 answer

Should you allow user to override normal behavior

This is more of a subjective question and i don't expect a perfect anwser. I have different behavior/rules in my system. for example : I have a behavior in my system that allows users to register to ...
Francis Groleau's user avatar
4 votes
3 answers

Is Java's @Override annotation still good practice in these modern times?

When the @Override annotation was introduced in Java 1.5, which feels like back in the days when the dinosaurs roamed the Earth, it was a good idea at the time because, amongst other advantages, it ...
DodgyCodeException's user avatar
0 votes
3 answers

Overriding methods with stricter signature

I'm programming in Java and have the following problem: I would like to do collision detection. For that, I need different types of BoundingBoxes. For the sake of example, let's say that I have ...
PawkyPenguin's user avatar
3 votes
1 answer

To inherit or to override?

Imagine that I am writing a game where tanks fight with each other. A generic Tank class is created and has the method fire() which fires a cannon, looks like this Tank::fire() { /* fires a cannon */ ...
Sunny Pun's user avatar
  • 139
-1 votes
1 answer

How should I represent an object whose instances share the same set of member function identifiers, but those identifiers specify different behaviors?

I'm attempting to develop an open-source Python module for modeling task networks for discrete event simulation. The most fundamental component is the task object, which includes various data such as ...
mcman's user avatar
  • 1
3 votes
2 answers

How to overwrite function in a sub class that has unique functionality in the middle of the function compared to the parent

sorry if the title is a bit messy but I wasn't sure how to form my question. So I have some classes that I've used for a project that I'm looking to making more general so that I can reuse them for ...
Jesper Evertsson's user avatar
0 votes
2 answers

Question on members in derived classes (new vs override)

I'm working through the Head First Design Patterns book and am currently on the Decorator Pattern chapter. Since the book examples are written in Java, I'm adapting the, to C# as I go. This example ...
Jim's user avatar
  • 1,997
5 votes
1 answer

Can I add to a built-in function?

I want be to be able to re-write the code of an existing PHP function in an abstract manner. Here is an example: scandir() scans a directory for files and folders, and returns the relative paths '.' ...
Platinum Fire's user avatar
32 votes
5 answers

Is overriding concrete methods a code smell?

Is it true that overriding concrete methods is a code smell? Because I think if you need to override concrete methods: public class A{ public void a(){ } } public class B extends A{ @...
ggrr's user avatar
  • 5,725