227

Should we refer to "replacing an implementation" as overwriting or overriding? Is it language-specific?

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Kent Nguyen
  • 3,042
  • 2
  • 20
  • 15
  • Without any context this question is too broad – parapura rajkumar Dec 28 '11 at 03:34
  • 7
    It's been overriding in every book and language I've been involved in. – Joe Dec 28 '11 at 03:35
  • 1
    I know it's a broad context but that's exactly what I meant to ask, in a very general context of programming. From the responses seems like Override is the commonly used word, though Overwrite has its specific used as well. – Kent Nguyen Dec 28 '11 at 09:07
  • A more involved discussion exists in English.SE: http://english.stackexchange.com/questions/88400/when-to-use-override-and-overwrite. –  Nov 15 '12 at 17:54
  • The explaination [here][1] might useful though it is not about terminology [1]: http://english.stackexchange.com/questions/88400/when-to-use-override-and-overwrite – A Man Dec 12 '14 at 03:00
  • I'm voting to close this question as off-topic because it has nothing to do with programming, it's more a language specific question. It was already asked at SE for English Language & Usage: https://english.stackexchange.com/questions/88400/when-to-use-override-and-overwrite – Philipp Kief Dec 03 '19 at 08:39

6 Answers6

271

If you're replacing one implementation completely with another, it's "overwriting" or more commonly "replacing". If you're replacing an implementation with another for some specific cases, it's "overriding".

To "overwrite" something is to put something else in its place, destroying the thing overwritten. To "override" something is to cause something else to operate instead of it without harming or changing the thing overridden.

Kerem
  • 11,377
  • 5
  • 59
  • 58
David Schwartz
  • 179,497
  • 17
  • 214
  • 278
  • 5
    I disagree. I believe the term "override" can always be used to mean you are replacing an implementation; it shouldn't matter how often or in what manner. – Brian Rogers Dec 28 '11 at 03:51
  • I've never heard it used that way, but it doesn't seem wrong to use it that way either. – David Schwartz Dec 28 '11 at 03:56
  • 57
    a quick search on dictionary.com confirms this: *overwrite* - Destroy (data) or the data in (a file) by entering new data in its place. *override* - Use one's authority to reject or cancel (a decision, view, etc.) – allicarn Nov 15 '12 at 19:50
  • I agree with this answer given. Both terms are often confused in particular in the context of object-oriented programming. The answer given above her matches my correct understanding of the usage of those terms in that context. I also added my own answer below, specific to that context. – Kim Mens Jan 14 '23 at 18:22
37

The common used word is Override and it's not language-specific as you can also read from wikipedia: http://en.wikipedia.org/wiki/Method_overriding

Aurelio De Rosa
  • 21,856
  • 8
  • 48
  • 71
25

Both are generic terminologies Override is the prevention of some previous action or decision and on the other hand Overwrite refers to something being written over something previously written.

in simple words,

Actions and decisions are overriden.

Information is overwritten.

mumair
  • 2,768
  • 30
  • 39
19

This is my understanding of what the differences of Overriding and Overwriting are, in terms of a real-world example:

Assume that you have an automobile manufacturing company. You are famous and happy with your customers since they always trust you and purchase your products.

To proceed with your business, you have, basically, 2 options in hand:

  1. All the things come through and you know that you step in the right path. So you want to not only keep the previous models but also keep enhancing them. Though, how come? Probably by adding some new features to the existing models! Now new models have all the features PLUS newly enhanced features.

  2. You know that the way you went through was sort of wrong! what an awful approach!! You notice quickly that the company should change the entire technology, otherwise it'll be undergoing harsh situations (like bankruptcy or so...)

After all, in terms of programming, the first approach refers to Overriding since you add some new BEHAVIORS to your cars while keeping the prior behaviors which the car had, whereas the second approach refers to Overwriting since you want to change the behavior(s) entirely, and develop new features from scratch.

Hope this helps you out.

inverted_index
  • 2,329
  • 21
  • 40
1

I think if given some context, it would be so much eaiser to understand and distinguish.

From APUE §10.17:

POSIX.1 also specifies that abort overrides the blocking or ignoring of the signal(SIGABRT) by the process.

From Bing Dictionary:

override sth: to use your authority to reject sb's decision, order, etc.

Here override means it "ignores" something by its higher authority. abort does not replace the signal mask of the process, it just "ignore" the constraint with higher authority.

So I think override and overwrite are totally 2 different words. overwrite should be the word for replacing the old content.

Rick
  • 7,007
  • 2
  • 49
  • 79
1

The terms overriding and overwriting are often (conf)used in the context of object-oriented programming. (The fact that these words when pronounced in English by non-native speakers they sound similar adds to this confusion.) In object-oriented programming, thanks to the mechanism of inheritance, it is possible for subclasses to re-implement methods that were already implemented in a parent class. This is a powerful mechanism that enables fine-grained code and design reuse, because it allows to define subclasses that are special cases of the parent classes of which they inherit, with slightly specialised behaviour.

The difference between (method) overriding and (method) overwriting lies in how a method of a subclass re-implements the original method that was implemented in the class from which it inherits.

We talk about method overwriting if the already existing method gets remplaced by a completely new implementation which is not connected to the original implementation (often implementing an alternative, but independent, implementation of a similar functionality).

We talk about method overriding if the method defined in the subclass specialises the original implementation of the method to a special case, but in an incremental way, by making use of a super call. The effect of the super call is to execute the behaviour as defined by the original method, but in addition to that the method in the subclass can add additional instructions to specialise that behaviour.

Kim Mens
  • 325
  • 1
  • 13