Skip to main content

Timeline for Open, write and close a file

Current License: CC BY-SA 3.0

29 events
when toggle format what by license comment
Mar 22, 2018 at 16:48 comment added Toby Speight I believe your reviewers are wrong, but not for the reason you think. If the return value is supposed to be true for success, then it should return false if any of the file operations fail, not just the constructor. I've answered accordingly.
Mar 22, 2018 at 16:40 comment added Toby Speight I changed the title so that it describes what the code does per site goals: "State what your code does in your title, not your main concerns about it.". Feel free to give it a different title if there is something more appropriate.
Mar 22, 2018 at 16:40 history edited Toby Speight CC BY-SA 3.0
Describe what the code does, rather than the concerns with it
Mar 22, 2018 at 12:06 answer added Francis Cugler timeline score: 4
Mar 19, 2018 at 20:28 history unprotected Simon Forsberg
Feb 14, 2018 at 15:05 history edited 200_success
edited tags
Feb 14, 2018 at 10:51 answer added Toby Speight timeline score: 2
Jun 28, 2015 at 1:00 history edited Jamal CC BY-SA 3.0
deleted 16 characters in body; edited title
Mar 4, 2014 at 22:28 answer added ChrisW timeline score: 12
Feb 24, 2014 at 15:33 history protected Malachi
Jan 10, 2014 at 0:44 history edited Jamal
edited tags
Oct 24, 2013 at 15:41 answer added Patrick Fromberg timeline score: 9
Feb 3, 2011 at 21:06 vote accept dreamlax
Feb 3, 2011 at 12:56 comment added n1ckp @dreamlax: "because it shows that we know we are done with it" .. I think it can be a good enough reason then. It also force you to think about when you are done with it. Maybe majority of the time it is not a concern but sometimes maybe it matter. What is your industry? I agree with the commenter that said this question would be better on SO though.
Feb 3, 2011 at 8:51 comment added dreamlax @Konrad: I guess in some situations it is better to "spell things out in full" than to use more concise versions. For example, a few lines of nicely written code is often better than a clever-yet-esoteric one-liner. The rule is not so applicable in this particular case, however, and instead I think the actual reason is for explicitness.
Feb 3, 2011 at 8:45 comment added dreamlax @rwong: I would imagine so. The question is, why is the variable lingering around when the stream is no longer needed? The scope of the variable should be limited, in my opinion, to represent more-or-less the timeframe of an open file. If the stream variable is lingering, it is probably more an indication that the function is far too long.
Feb 3, 2011 at 8:21 comment added Konrad Rudolph @dreamlax: but how is verbosity ever an advantage? I agree that explicitness may be, and that this sometimes entails verbosity – but this is always a trade-off between the two. I have never seen a situation where verbosity would be an advantage in itself. That’s what I meant by “it doesn’t make any sense”.
Feb 3, 2011 at 7:16 comment added rwong Was this requirement added because the other instance had caused a bug which wasn't caught by the code review?
Feb 3, 2011 at 2:34 comment added dreamlax @Konrad: By verbosity, I mean that we are closing the file even knowing it will be closed anyway in the destructor, because it shows that we know we are done with it. In some instances, we have files open for a long time; so we have a rule that we close every stream explicitly.
Feb 2, 2011 at 21:07 history edited dreamlax CC BY-SA 2.5
added 475 characters in body
Feb 2, 2011 at 16:11 comment added kizzx2 Obviously your reviewers' style conflict with the standard design of the standard library.
Feb 2, 2011 at 14:16 comment added Konrad Rudolph “it failed code review with the reason that it is better to explicitly call it for … verbosity reasons ” – Please explain that last bit, it doesn’t make any sense.
Feb 2, 2011 at 11:33 comment added Fred Nurk If the reviewers need reassurance that close is called automatically, then C++ is probably not the best language choice. The "verbosity" reason is particularly alarming.
Feb 2, 2011 at 11:29 answer added Karl Bielefeldt timeline score: 20
Feb 2, 2011 at 8:52 history tweeted twitter.com/#!/StackCodeReview/status/32722977657196544
Feb 2, 2011 at 7:51 answer added Loki Astari timeline score: 75
Feb 2, 2011 at 4:52 answer added Jerry Coffin timeline score: 42
Feb 2, 2011 at 4:22 answer added grokus timeline score: 11
Feb 2, 2011 at 4:00 history asked dreamlax CC BY-SA 2.5