Questions tagged [overriding]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
25 views

How to override a flag from a jar in the application using it?

At my workplace, there are lot of Java/Spring/Spring-Boot based applications which has a common jar added as maven dependency. This common jar is always used as a SNAPSHOT dependency and I am not ...
user avatar
  • 119
2 votes
1 answer
153 views

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 ...
user avatar
4 votes
4 answers
401 views

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 ...
user avatar
  • 1,476
1 vote
5 answers
218 views

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 ...
user avatar
0 votes
4 answers
323 views

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 } ...
user avatar
2 votes
1 answer
1k views

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 ...
user avatar
  • 51
-1 votes
2 answers
115 views

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) => ...; ...
user avatar
1 vote
1 answer
108 views

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 ...
user avatar
3 votes
3 answers
1k views

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 ...
user avatar
0 votes
3 answers
546 views

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 ...
user avatar
3 votes
1 answer
213 views

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 */ ...
user avatar
  • 139
-1 votes
1 answer
107 views

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 ...
user avatar
  • 1
3 votes
2 answers
972 views

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 ...
user avatar
0 votes
2 answers
219 views

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 ...
user avatar
  • 1,997
5 votes
1 answer
345 views

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 '.' ...
user avatar
32 votes
5 answers
10k views

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{ @...
user avatar
  • 5,705