25,844 reputation
25193
bio website thehungersite.com
location United Kingdom
age 46
visits member for 4 years
seen 4 hours ago
experienced software engineer with many years in the industry, mostly c++ for large-scale, high-reliability systems.

Apr
15
awarded  Good Answer
Apr
15
comment TDD Red-Green-Refactor and if/how to test methods that become private
@BenAaronson or he has a public method with some code that he has tested, and later makes it private, this too is ok, it means the test is now obsolete (assuming it was correct to make such a test in the first place) - whatever calls the private method should have its test improved to exercise that private code by passing the right data or whatever to it. This is the root of it all - TDD is about testing the interface not the implementation which is where the OP is going wrong. Tests for each individual method is an easy route to making this mistake - at least that's what I'm trying to convey!
Apr
15
comment TDD Red-Green-Refactor and if/how to test methods that become private
@BenAaronson My point is really that he's has followed strict TDD but has created tests for methods that he shouldn't have - when he wrote the test he had a mind to the method he was going to be testing, and now finds things to be falling apart. If he had in mind a class interface then his tests would be more focussed on the use of that class and not the implementation of the methods which he now has. If you start with a class with 1 method, and later migrate some of that method's code to a private fn, the test shouldn't need to be changed.
Apr
15
awarded  Nice Answer
Apr
15
comment TDD Red-Green-Refactor and if/how to test methods that become private
@DocBrown what's that got to do with methods? red/green/refactor says to write a small bit of test, then write a small bit of code, then refactor to continually improve the system (AFAIK). Nowhere does unit testing 1 method at a time come into play, you can do this with a class just as easily. The only link is that you may be making changes to a single method at a time as you only make small changes, but you should still be testing more than just that. Here's a link that explains RGR without mentioning methods at all
Apr
15
comment TDD Red-Green-Refactor and if/how to test methods that become private
@DocBrown no, it answers him completely in saying "don't over-granualise" your units and make life hard for yourself. TDD is not method based, it is unit based where a unit is whatever make sense. If you have a C library, then yes each unit will be a function. If you have an class the unit is an object. As Fowler says, sometimes a unit is several tightly-related classes. I think many people consider unit testing to be method-by-method simply because some dumb tools generate stubs based on methods.
Apr
15
answered performance versus reusability
Apr
15
comment Full screen command line app that user cannot close in any way
4 8 15 16 23 42 - cultural reference from the TV series Lost
Apr
15
comment Full screen command line app that user cannot close in any way
install DOS! (ok, ok, or an OS that doesn't have a GUI layer such as Linux without a GUI installed, only having the monitor window available)
Apr
15
answered How to share memory between applications written in C/C++
Apr
15
comment TDD Red-Green-Refactor and if/how to test methods that become private
@HenrikBerg think why you have objects in the first place - they're not convenient ways to group functions, but are self-contained units that make complex systems easier to work with. Hence, you should be thinking of testing the class as a thing.
Apr
15
answered TDD Red-Green-Refactor and if/how to test methods that become private
Apr
15
answered how to paginate and combine results that come from different sources sorted
Apr
14
comment Why do many exception messages not contain useful details?
@jpmc26 so apply what you said to a const int. It can have just as good a descriptive name, can be commented equally well, its easy to type out the name (even via intellisense) and the compile will ensure the existence of this code. You're mistaking the type of thing with the information it conveys. Hence an exception class that is simply a language entity is no different from a code - they both convey 1 piece of information that is equally useful in diagnosing the problem. Thus I think adding more info is better, don't get caught up in exception v error ideology, think of the data.
Apr
14
comment How to save many changes to database data?
@Swiftheart surely if there is no 'id' entry for an added row, then it becomes an insert otherwise update the row for that ID. You'll thank us for doing it this way when someone wants edited rows to automatically persist when they click off the grid.
Apr
14
comment Design documents as part of Agile
@user145400 something I experienced :-(
Apr
14
comment Why do many exception messages not contain useful details?
@MikeNakis but you do not "already have them" - somebody somewhere made them up. They could have made up #define return codes just as easily TBH. Think it through - you're just dressing up one system with something better looking. Now, putting codes or text in the exception objects, that makes more sense and starts to build error information that helps. Eg IndexOutOfBounds passing the index that was used so you can see if it was uninitialised value, -1 or 7 in a 6-element collection.
Apr
13
comment Why do many exception messages not contain useful details?
@MikeNakis fundamentally, what's the difference? A code is a value that means something, whether it is an int or a pointer or a compiled runtime object. They're all a single value, no matter how you dress them up differently. You may be thinking of C-style #defines when I say "error code" but that's not necessarily the case. Single value however is.
Apr
13
comment Why do many exception messages not contain useful details?
@Snowman I hardly think security is a consideration when a full stack trace is available, and index number is not. Sure I understand an attacker probing for buffer overflows, but many exceptions leave out quite safe data too (eg which Oracle table wasn't found)
Apr
13
comment Why do many exception messages not contain useful details?
Sure, I almost agree that an exception should contain a code only and that an "error message" is redundant in such cases. However, this just shifts the problem to a stack of error codes which requires even more rigour in writing them, at least with an error message you can type out whatever you like at the time and prevents a plethora of exception objects being defined for every error case.