Search code examples
redundancydead-code

Is this dead code, redundant code or usefull code?


Let's say you have an application in which module A provides the service SRVA.

You also have modules B and C that use SRVA according to the spec. Finally you have modules D and E that shouldn't use SRVA according to the spec.

Then you have 2 modes M1 and M2. And the spec says that the functionality handled by SRVA must not be executed during M1.

So here is my question. Would you add some code preventing the execution of SRVA during M2 everywhere?

I mean, if you include the following piece of code in module B and C:

if(SRVA needed & !M1)
{
  request SRVA
}
else
{
  error
}

and the following code in module A:

if(SRVA requested & !M1)
{
  service SRVA
}
else
{
  error
}

Do you consider this is dead code or redundant code? In other word, do you consider this as a bad practice?

Thank you for help!


Solution

  • So here is my question. Would you add some code preventing the execution of SRVA during M2 everywhere?

    Yes, absolutely. If I receive a requirement in the form

    the functionality handled by SRVA must not be executed during M2.

    I will honour it by coding this behaviour.

    But please revise the pseudocode you wrote as it seems to work the opposite way.