-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
do we avoid dead code? #13
Comments
I agree with this as a general guideline. However I think it is really important to remember that all of these guidelines/best practices we are wrangling over are just out workings of fundamental principles that we would most likely all be in agreement with (think torah vs talmud for those of you theologically inclined). There are always going to be those instances where guidelines should be violated to do something that adheres better on balance with the principles. In fact I think it would be a good idea to provide a rationale for each guideline that points to one or more of these basic principles. |
@nncarlson sorry, but my English understanding is very limited, my lexicon annoverates just technical English (a very limited subset of).
What do you mean with out workings of fundamental principals?
Does this means something like
Absolutely agree (I think 😄 )
I am not sure which principles you are referring to, can you give me an example? |
@szaghi, my apologies! I need to be more mindful that there are non-native english speakers here. A silly example for the purpose of illustration only. A fundamental principle might be "Code should be readable." (something no one would disagree with I hope). Guidelines that come from that (the "out working") might be guidelines about line length. The truly important thing is not "80 char max" but "readability", and situations might arise where "readability" is better served by violating the "80 char" guideline. Oh, and torah == principles, talmud == guidelines. |
Do not worry, only with me try to speak slow, I am the only donkey here 😄 Wonderful example, now it very clear. I think that we could found a more clear form at to highlight which sentences are general principles and which are guidelines. Thank you also for torah/talmud clarification (it is really interesting for me) |
I don't think that "don't write dead code" is a good principle, its intent is better captured by something like "write elegant code, not superfluous code". Further I don't think that any of the rules suggested above follow naturally from the principle that they are supposed to support, but spring from some other largely unrelated principle (eg ttd is more about correctness by testing that it is about minimizing code lines, what it does say in that vein stems from the desire to have no untested code). Mainly I think that "dead code" is a bad concept for high level principles because it not a general idea, as far as I know it is mainly a rather closed technical term from the world of compiler construction. On the language level, I don't think there is any concept of code with no effects beyond the comment statements; searching trough a draft of the 2003 standard most code seems to have effects except for a small number that has no effect in certain circumstances (the flush instruction for an non-existent file for instance). Calling a rule that only has something to say about "end if" statements (the execution of which the standard draft says has no effect) and superfluous "import none" statements a principle seems quite a stretch! If we allow ourselves to include the execution of a piece of fortran code on an imagined fortran machine (thereby sidestepping the issues of how to regard the actions of the various compiler binaries) we can have a well defined notion of dead code: it is code that is never reached trough the repeated execution of or program over its complete range of possible inputs. Clearly writing this code was a waste. At the same time any reasonably complex piece of fortran code will show unexpected and unintended behaviour when tested over its complete range of possible inputs; it will have bugs. On of the fundamental sources of bugs is the programmer misjudging the state of variables, something that has critical effects at branch time. And I expect the main source of dead code is branches that are never taken ( the other source being that leap-frog integrator you wrote and tested but then never actually included in production; and other such bits and bobs). So it seems fairly likely that much dead code will only be recognized as such after careful examining of the program, and in the typical case this insight will lead to swearing and modification of the program until the test works as intended because nobody actually wants to write non-trivial pieces of dead code. With this I mean to say that the only non-trivial pieces of dead code (such as an default statement "for safety") are unintentional, so that even if we look at the execution context the no-dead-code principle only has opinions on trivial examples (because the programmer will most likely not correctly identify the dead code except in trivial examples). |
@Tobychev I am sorry for my delay, I am traveling for work. Asap, I will try to summarize your arguments. See you soon. |
From a note on another thread...
Is this an agreed guideline?
The discussion is open 😄
Summary from other thread
@zbeekman
@rouson
@tclune
@LadaF
@nncarlson
The text was updated successfully, but these errors were encountered: