The advanced concept of properties



  • @tsaukpaetra said in The advanced concept of properties:

    Getting too old already?

    From my perspective, I never will; yet, I hear that other believe I did that decades ago....


  • Impossible Mission - B

    @remi said in The advanced concept of properties:

    @thecpuwizard said in The advanced concept of properties:

    When one sees a function/method/etc. call is it necessary to "go see"???

    My experience is that when it comes to business logic and high-level code, what a function does is never so well-defined that it can be entirely and un-equivocally be put into its name. So you very often need to be able to look at how it does something, because you're not just reading the code out of curiosity, you are trying to change it (fix a bug, add a feature...).

    bool list::is_empty() is clear, no one doubts what it should be doing

    So you just said "this never happens," followed immediately by an example of when it does happen? 😕



  • @dkf said in The advanced concept of properties:

    @thecpuwizard said in The advanced concept of properties:

    The unit tests for each of those places will fail.

    Not always. Picking a very dumb (but technically correct) sorting algorithm can cause major problems, yet not trip any (reliable) unit tests, as the problems show up principally in terms of performance. An example of this was in some code a colleague was looking at recently, which was using lists for many things and linear searching to detect if elements were present in those lists; changing the code to use hash tables accelerated it by several orders of magnitude. Was that a bug? The code was producing the right answers before, but that's often not the whole story.

    Not all problems can be fixed in isolation, nor all fitness metrics evaluated on just the smallest pieces of code.

    I agree in general, but your specific example of lists is something that definitely can be tested for [the decision of if it should be tested for is more complicated. For example if the code was known to be a list of the countries in the world, one can pretty safely assume an upper bound of double the number of existing countries and simply test against a max time.



  • @remi said in The advanced concept of properties:

    we don't have a single automated test in our codebase ....

    My condolences...

    As we have agreed, "situations vary", but I can not imagine a case where establishing a set of "pinning" domain test at the unit level would not be worth while.

    For many languages [anything .NET, C++, others] there are techniques for creating such tests using the current empirical behavior as the baseline.

    At least with this level of testing, you have a much better idea of what is impacted by various changes....



  • @masonwheeler said in The advanced concept of properties:

    @remi said in The advanced concept of properties:

    @thecpuwizard said in The advanced concept of properties:

    When one sees a function/method/etc. call is it necessary to "go see"???

    My experience is that when it comes to business logic and high-level code, what a function does is never so well-defined that it can be entirely and un-equivocally be put into its name. So you very often need to be able to look at how it does something, because you're not just reading the code out of curiosity, you are trying to change it (fix a bug, add a feature...).

    bool list::is_empty() is clear, no one doubts what it should be doing

    So you just said "this never happens," followed immediately by an example of when it does happen? 😕

    Are you trying to be funny, or did you not read my post? "business logic and high-level code" requires being able to look at the code (and not only function name). Does list::is_empty() sound like business logic to you? Also, did you read the sentence just after that you removed?



  • @remi said in The advanced concept of properties:

    Does list::is_empty() sound like business logic to you?

    <snark> If you are in the business of writing containers (software) it definitely does :) </snark>


  • @thecpuwizard If your business is writing containers, please, please, do not take inspiration from TD:wtf: !!!


Log in to reply