Questions tagged [overriding]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
1answer
97 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 ...
0
votes
2answers
89 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) => ...; ...
1
vote
1answer
99 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 ...
2
votes
2answers
369 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 ...
0
votes
3answers
302 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 ...
3
votes
1answer
202 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 */ ...
29
votes
5answers
8k 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{ @...
-1
votes
1answer
97 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 ...
3
votes
2answers
570 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 ...
5
votes
1answer
335 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 '.' ...
0
votes
2answers
134 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 ...