36

I'm a software engineer. There are many times when I write a good chunk, or even the entirety of, a feature, but opt not to make it actually run in the program for some reason or another. This code is still there, and could theoretically work, but it never will because it's inaccessible.

What's a good one-word term for such code? I want to use it, or a form of it, like this:

"This is ______ code."

"I am going to ______ this code".


Terms I considered (but don't seem to fully-convey the purpose) include:

  • frozen/freeze (implies it causes the program to freeze?)
  • isolated/isolate (implies it can be run in some isolated environment)
  • vitrified/vitrify (implies it's changed to something else and can't change back)
  • fossilized/fossilize (implies it's old and broken and should only be observed. Same problems as vitrified)
  • 12
    Don't use your first example of "frozen". I would interpret "frozen code" to be code that will definitely not be changed in the future. – James Apr 14 '16 at 17:37
  • 2
    @James As a programmer, "frozen" immediately brings to mind horror stories of applications that refuse to run or terminate for hours on end. I would definitely not use that term to describe code that cannot run. – Zibbobz Apr 15 '16 at 14:47
  • 5
    As an aside, there may not be strong consensus on how to name this tactic, because there is widespread consensus that leaving unused code laying around is a bad idea. Reading between the lines, what you are doing might be a first step towards "branch by abstraction." See martinfowler.com/bliki/BranchByAbstraction.html for a longer explanation. I strongly recommend you investigate this or other alternatives if you find yourself "many times" writing code that is not called anywhere. – GrandOpener Apr 15 '16 at 16:53
  • 3
    It would probably be code that is just about to be deleted — oops, no, it is code that has just been deleted in the version control system. I might label it first so it is easier to find again later. One system I worked on had some code deactivated by #ifdef POST_JUNE_DEVELOPMENT. I was never sure whether that was June 94 or June 95, but it never happened (was never activated) and I removed the code in 2010. – Jonathan Leffler Apr 16 '16 at 14:23
  • 2
    Doesn't source control let you go find it later...? – nhgrif Apr 17 '16 at 22:21

24 Answers 24

28

I'm rather thinking of the word unused.

Edit: Unused should be understandable for non technical persons. Other possibilities include unnecessary (you often see this in change logs, as in removed unnecessary lines) or maybe orphaned (although I haven't seen this in a real coding situation. It's rather a translation of a term in my native tongue)

  • 1
    That could certainly work! It's very common so it should be understood by anyone reading it. I'll wait a little while before accepting, though, since I would love to see alternatives. – Ben Leggiero Apr 14 '16 at 15:44
  • 15
    I like orphaned best, because it implies it's adoptable. Saying something is unused or unnecessary also says it's not to be used and safe to remove. – Ben Leggiero Apr 14 '16 at 15:49
  • 2
    +1 for unused or orphaned. "unused" is the most common but doesn't fit the verb case "I am going to unuse this code." The word "inert" would also be a good description for the code, but again not useful as a verb and not in common use. As a side note, search for "Power Peg" in this report sec.gov/litigation/admin/2013/34-70694.pdf – amdn Apr 14 '16 at 21:40
  • I've accepted this answer because I ended up using the term orphaned. However, there are so many other great answers here! I voted-up those I think are best, and I encourage you to do the same so they stay up near/at the top! – Ben Leggiero Apr 18 '16 at 15:22
  • 1
    @BenC.R.Leggiero I don't have the rep to post answers on protected questions. – RoadieRich Apr 19 '16 at 18:39
86

It's called unreachable code.

"Unreachable code" is different from dead code, dead code is code that when executed will result in no change, for example:

x = 5;
/* Dead Code Begin */
x = 6;
x = 5;
/* Dead Code End */

Unreachable code however is code that e.g. in a function that is not referenced anywhere, or code that is after the return clause of a function, this code is present, and theoretically compiled, but can never be "reached" to be executed.

Edit:

Many are claiming that this is not the correct answer and it is not cited anywhere, even though I see wikipedia's distinction is enough, I will quote MISRA C 2012:

Section 8.2 Rule 2.1: A project shall not contain unreachable code

Rationale

Provided that a program does not exhibit any undefined behaviour, unreachable code cannot be executed and cannot have any effect on the program's outputs. The presence of unreachable code may therefore indicate an error in the program's logic.

Then the rule directly after that:

Section 8.2. Rule 2.2: There shall be no dead code

Aplification

Any operation that is executed but whose removal would not affect program behaviour constitutes dead code.

.

.

.

Note: unreachable code is not dead code as it cannot be executed.

And before someone comments that it is saying it is a mistake and not intentional, MISRA exists exactly so that when you break one of its rules you justify why you did that and that it is intentional, otherwise the violation should be removed, but it does not change the definition of what is unreachable and what is dead code.

  • 5
    This is the correct answer. Unreachable code is well understood within Computer Science and programming circles. – theonlygusti Apr 14 '16 at 22:03
  • 19
    @theonlygusti - I don't believe this is the correct answer. Unreachable code would be code that cannot possibly run. But a function that is never used anywhere is an uncalled function, not an unreachable function. – TTT Apr 14 '16 at 22:23
  • 10
    @TTT if it's never called, that code path is unreachable during execution. It might not be as correct as referring to code within an if (false){} block, but it's a fairly common use of the term. – Morgen Apr 15 '16 at 2:20
  • 4
    @PhilSweet then he would use I am going to make this code unreachable, I wanted to give an answer with a technical term that is clearly understood by the computer science/programming circle. – Mystic Odin Apr 15 '16 at 9:49
  • 4
    @TTT the code inside the function is unreachable, the function is unreferenced, I'm a software developer and these are some of the few terms that were not changed in meaning across several domains and companies in which I worked. – Mystic Odin Apr 15 '16 at 9:51
42

Since the code is inaccessible, most compilers will eliminate it through Dead Code Elimination, or DCE. So you can refer to it as dead code, or simply dead.

Nullstone's compendium of compiler optimizations defines dead code as

Code that is unreachable or that does not affect the program (e.g. dead stores) [and] can be eliminated.

Since the code is apparently not going to be run, you can also say it is excluded from the build. So, to complete your sentences:

This is excluded code.

I'm going to exclude this code.

  • 4
    It really depends on what sense "inaccessible" is meant in. If it's that "you can't get here unless you enter this special code that normal usage will never reveal", then it won't be eliminated as dead code. Then it's more like hidden content (or "unexpected liability" :)). – Joshua Taylor Apr 14 '16 at 18:47
  • 2
    Surely a dead code elimination tool cannot actually identify eliminate all dead code. Therefore, just because a DCE tool doesn't identify it, doesn't mean it's not dead code. (And the corollary, just because a tool identifies something as dead code, doesn't prove incontrovertibly that it's dead. A specific example, I have worked on a class that was used for deserializing the response from a third party web service. ReSharper identified some of the properties as "unused" but they were needed to properly parse the response, even though we didn't use the results in our own code.) – stannius Apr 14 '16 at 20:09
  • 2
    @stannius Right, the uncomputable nature of the halting problem means any automated dead code elimination (DCE) algorithm cannot be perfect. A properly implemented dead code elimination will err on the side of caution and produce an approximation which is an underestimate of all the dead code in the application. In other words, there will be cases where some dead code is not eliminated for safety. There's some complex mathematics involved in working this out (based on lattice theory) but the core principle is that an optimisation should never affect observed program behaviour in any context. – Cosmic Ossifrage Apr 14 '16 at 20:17
  • 4
    Note that dead code and unreachable code are two slightly different concepts. – Tobia Tesan Apr 14 '16 at 22:44
  • 4
    @TobiaTesan It depends on the context. "Dead code" is absolutely used to refer to unreachable code in informal contexts. Despite lacking a citation on Wikipedia, this usage is pretty common. – jpmc26 Apr 15 '16 at 2:08
39

RTCA DO-178C - the standard for safety critical code in aircraft - uses the terms "dead code" for code that is never reached in any path through the code. The term "deactivated code" is for code that is deliberately never used in a particular configuration, but could be used in a different mode.

  • 1
    That's also the regular use of "dead code" everywhere I've seen it before; I have no idea where "optimized out is dead code" came from. – Izkata Apr 15 '16 at 15:18
  • 1
    Finally an answer with sources that is not just a personal opinion. Thank you! – Tom Apr 16 '16 at 8:56
31

You might consider disabled or deactivated:

disable: to cause (something) to be unable to work in the normal way
deactivate: to make (something) no longer active or effective
definitions from merriam-webster.com

24

moth-balled

verb (used with object)

  1. to put into storage or reserve; inactivate.

adjective

  1. inactive; unused; stored away:

  • Yup. This is it. – Drew Apr 15 '16 at 0:43
11

When discussing code or functionality that is either in progress or completed but has not been approved or won't be used, we often use the term

shelved

decide not to proceed with (a project or plan), either temporarily or permanently.

This implies that it was not a failure (which would be "trashed") and that it could later be unsheleved and put to use.

example

  • 3
    Some source control systems use the term "shelved" to refer to changes that were put aside and not checked in. Using it in this context (even for those who use systems without such a concept) would probably be confusing. – stannius Apr 14 '16 at 20:05
  • 2
    @stannius Except that if you have shelves, this is exactly where this kind of code should go. – deworde Apr 15 '16 at 10:44
  • @deworde Yes, I think most of us would agree on that. Or a branch. – stannius Apr 15 '16 at 13:28
  • 1
    @stannius git refers to this as a "stash". – Digital Chris Apr 15 '16 at 13:46
9

My view is that such code should not exist in the code base and is a code or process smell.

This is cluttering code. I am going to clutter up the codebase with this code.

  • 2
    Ideally, every piece of code should be used, but these might be features I still plan on implementing, but have just not attached to the UI yet, nor am I currently developing. The key word of the question, here, is purposefully. – Ben Leggiero Apr 14 '16 at 15:50
  • 3
    My experience is that no one ever goes back and purposefully removes or reintegrates such code. YMMV. – Peter K. Apr 14 '16 at 15:54
  • 3
    It has occasionally happened to me where one project is temporarily interrupted and delayed by another higher-priority project, at a point where the code for the former is reachable only from tests, not from the application. While it's true that if I don't get back to it reasonably soon I probably never will, I do sometimes get back to it soon. Then I'd call the code "work in progress", but that doesn't fit the sentences grammatically, and also implies a kind of urgency in getting back to it which the questioner doesn't express :-) – Steve Jessop Apr 14 '16 at 16:35
  • 4
    I don't see how cluttering could ever convey what the OP asked for. This is just a condescending expression that doesn't say anything at all except whether that code complies or not with one's preferred "best practices". – SantiBailors Apr 15 '16 at 9:40
  • 6
    @BenC.R.Leggiero Then that's what branching is for. – deworde Apr 15 '16 at 10:43
5

I would use the word "inactive" since it is possible to use that code, yet it is not actually doing anything, as you have stated.

5

I originally posted this as a comment, but will add a meaningful and expanded answer. As a software engineer myself, I'm using generic term redundant code.

"Redundant code" fits perfectly almost for every case:

  • when part of code is unnecessary,
  • or is not in use,
  • or it's unreachable,
  • or is unreferenced,
  • or is not used in computations,
  • or optimized out by compiler.

Redundant code is generic term, it defines the category of the code. If you need to clarify, why it's redundant, you may use more explicit terms, depending on the context:

  • unused code – part of the code, which is never used in any computations, the logical rules never lead to execution of it, or it can be just commented code;
  • unreachable code – part of the source code which can never be executed because there exists no control flow path to the code from the rest of the program;
  • dead code – has no external effect: e.g., does not change the output produced by a program, result is never used in any other computations, and normally may be optimized out by compiler;
  • legacy code – is source code that relates to a no-longer supported, not-maintained anymore, and could be partially not in use. This definition might be a bit blurry, and these conditions are not necessarily part of the term, it mainly depends on the context of usage;
  • unreferenced code - subtype of dead code, unused code, i'd say.
4

How about auxiliary code (auxiliary/auxiliarize): something that's useful but unused, held in reserve in case it's needed.

(I also like vestigial code, but that's not as good an answer, since it might imply obsoleteness).

3

I would call this feature toggled code. If you read the linked post you may come away with the impression that you must use configuration to toggle features. That's true. Your configuration just happens to be hard coded right now.

You may want to fix that, but even if you don't, I think "toggled off" is a reasonable description of this code.

3

I'd use dormant. As per the verb I'm not sure if there is one for make it dormant otherwise I'd just say that.

ADDED: This term would be a metaphor about something currently inactive but that has the full potential to do things if it gets activated, f.ex. a dormant volcano, or a dormant spy living an apparently normal, unrelated life but that can be activated as a spy in the future.

2

I would use the word hidden:

kept out of sight; concealed.

synonyms: concealed, secret, undercover, invisible, unseen, out of sight, closeted, covert; secluded, tucked away; camouflaged, disguised, masked, cloaked

"This feature has been implemented, but it's currently hidden from users."

  • Hidden code? Nerver heard this term in my life in relation to source code. As well as explanation alike cloaked code or camouflaged is totally out of the competition. Thank you, you have a really good sense of humor, will share this with my colleagues - software developers :-D – Farside Apr 16 '16 at 13:40
  • @Farside To be fair, you'd refer to the feature as hidden. The code itself is just "the code for that hidden feature". – Kevin Workman Apr 16 '16 at 14:25
  • Kevin, to be fair, the question was about source code, not about features, or anything else... sounds like your answer is off-topic... – Farside Apr 16 '16 at 14:59
  • 1
    @Farside If you say so. The OP asked what to call their code. I would call it code for a feature that's hidden from users. Have a good day. – Kevin Workman Apr 16 '16 at 15:05
2

One term is crippled. As in "the freeware version had several functions crippled."

https://en.wikipedia.org/wiki/Crippleware

  • That refers to features removed for licensing reasons, not in a case like this, where the coder has just decided not to integrate them in any release. – underscore_d Apr 18 '16 at 8:11
2

After reading all of the other answers and OP's comments to them, I now have concluded that the code in question is complete, and it just isn't being used anywhere yet. (Imagine a method overload or helper function that no one is calling yet.) Therefore the most sensible option I can think of that other programmers would instantly understand is:

uncalled
or
unreferenced

The thinking here is that after the entry point, all code is potentially called by other code. You have code that is not called by other code anywhere yet. Compared to some other answers I like, this is very similar to unused, with the minor difference that uncalled is more targeted specifically to code, whereas unused is a broader term which can be applied to many things, one of which is code.

Some other terms that were mentioned that I'd like to comment on:

  • orphaned - this is similar, except that it suggests that at one time the code actually was called somewhere, and now it isn't called anymore.
  • shelved - I originally liked this answer the best, because I thought the wrong question was being asked. I thought a better question would be: "What should I do with this code that I don't want to use right now?" But that isn't quite the same thing as "What should I do with this code that I don't want to use right now, but someone else might want to use right now?" In the latter case you don't want to shelve it because someone could legitimately want to use it right away, and I believe that's a better description of the scenario in the question.
1

You could consider suppressed:

to keep in or repress.

to withhold from disclosure or publication.

(Dictionary.com)

That conveys not only that the code is unused, but that it is intentionally prevented from being used.

1

I would use inactive to indicate that it is not being executed in any existing code path.

From your example:

"This is inactive code."

"I am going to activate/deactivate this code".

1

I think the word you are looking for is "sideline" (sidelined).

past tense: sidelined; past participle: sidelined

cause (a player) to be unable to play in a team or game. "an ankle injury has sidelined him for two weeks" remove from the centre of activity or attention;

place in a less influential position. "backbench MPs have been sidelined and excluded from decision-making"

1

There are several good answers here (and a few that, IMHO, are not so good).  A couple of them mention the word "reserve" in passing, but don't propose it as an answer, so I will: reserve or reserved:

transitive verb:

1. to keep back or save for future use, ...
3. to set apart for a particular use, purpose, service, ...

adjective:

15. kept in reserve; forming a reserve: a reserve fund; a reserve supply.

For the answerers who suggest that such code should be deleted, is a waste of time, is clutter or obsolete, consider this scenario: Programmer thinks of a neat new feature for a product and codes it.  Her manager says, "Yes, that's neat, but our marketing plan for this product calls for a new major version six months from now; let's keep this in reserve until then."

  • I would go with the 'in reserve' form of this. Not sure why it was attracting down votes. Especially since other answers quote definitions or describe their own suggestions explicitly using this one! – Phil Miller Apr 18 '16 at 14:58
1

Depends on why you disabled it. You could perhaps be more descriptive about why you disabled it rather than looking for a generic "____ code". Here's a few generic words:

  • Disabled
  • Unused
  • Stashed

And a few specific ones:

  • Uncontrolled
  • Untested
  • Deprecated
  • Obsolete
  • Non-production ready
1

I do believe this is called Dormant Code, a variant term from Unreachable code, because Unreachable code is most of the times an error effect as stated above as

    programming errors in complex conditional branches;
    a consequence of the internal transformations performed by an optimizing compiler;
    incomplete testing of a new or modified program that failed to test the bypassed unreachable code;
    obsolete code that a programmer forgot to delete;
and not a purposeful actual cause; I would term it Dormant Code, because it's functional code that you chose not to turn on but it's there whenever you need and if you trigger it; if you can't actually FIND the code although it's functional AND working, then the term is Hidden code not Dormant code. HOWEVER, if Kojiro's concept for the code fall in these:
      unused code that a programmer decided not to delete because it was intermingled with functional code;
      conditionally useful code that will never be reached, because current input data will never cause that code to be executed;
      then it can be placed inside the construct of Unreachable Code

      0

      If we borrow what git calls code you store away for later, try stashed.

      It does not come up often in casual conversation so there is unlikely to be conflicting usage.

      Similarly, there is also stored.

      • If you worked with GIT yourself, and ever used stash functionality - you would not post this answer, as it has totally different meaning. Has nothing to do with the OP question. – Farside Apr 16 '16 at 13:46
      • 2
        @Farside Sure, but it can potentially be used to store away working code. I assume he's going to be using it locally (with his peers/coworkers), so precision doesn't matter as long as everyone agrees upon it. – Mateen Ulhaq Apr 16 '16 at 23:34
      -2

      legacy code, used primarily for informal pseudocode

      • It was never implemented. Legacy code is code from a system that has been in place for a long time. – TRomano Apr 14 '16 at 16:55
      • Legacy code doesn't necessarily imply implemented; I keep legacy Access VBA code from old magazines without having ever really implementing it. – John Edward Law Apr 14 '16 at 17:02
      • 8
        Legacy pertains to the age/era of the code or codebase not to its disuse. – TRomano Apr 14 '16 at 17:09
      • 2
        legacy code – is source code that relates to a no-longer supported, not-maintained anymore, and may be partially/fully not in use. This definition might be a bit blurry, and not all these conditions are necessarily part of the term, it mainly depends on the context of usage. But for sure, disuse - is not definitive here, it's more a consequence of the fact, that code is aged out, inherited and not maintained properly. – Farside Apr 15 '16 at 10:15
      • As for the OP, I would definitely say that most application developers (or software developers...) would say "I am going to save this code" or "I am going to pitch this code", given our proclivity to being pack rats of code ;-) – John Edward Law Apr 15 '16 at 15:13

      protected by Andrew Leach Apr 14 '16 at 18:03

      Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

      Would you like to answer one of these unanswered questions instead?

      Not the answer you're looking for? Browse other questions tagged or ask your own question.