@fumieval: When defining a function that âreturns true if all elements of the array satisfy the conditionâ, does it return false if you pass an empty array or Trueâ is one of the boundaries between a good programmer and a bad programmer. @fumieval: In the process of âput all attachments of an email in the inbox if they are safeâ, what about emails without attachments? It is easy to imagine the answer naturally if we think about what we should do
@kumagi: There is a gulf deeper than the ocean between âthis is mathematically natural, so this is what we should doâ and âIâve taken the liberty of thinking that the requirements of this project are in line with the requirements of mathematics, so we should do this. There is a gulf deeper than the ocean between âthis should be done because it is mathematically naturalâ and âI think the requirements of this project are in line with the requirements of mathematics, so we should call anyone who disagrees with the requirements of mathematics as having no senseâ, but there are people who cannot see it.
@IgnorantCoder: Iâm scared of a lot of people saying it depends on the requirements, like whether 1+1 is 2 depends on the context. Iâm afraid theyâll never implement itâŠ
@chokudai: ă»True is the only logical choice. false people need to study logic. I donât want it to be dependent on the situation, as it is not good to increase the effort to refer to the document on items that can be determined by > logic. / In many environments, it is better not to assume that âeveryone can think logicallyâ, so documentation and comments should be taken care of
@Cryolite: You are the author of a programming language. If you pass an empty array to the âfunction all, which returns true if and only if all elements of the array satisfy the conditionâ and âfunction any, which returns true if and only if some elements of the array satisfy the conditionâ in the languageâs standard library, you implement the following behavior:
-
@GarterBlue2303: in @Cryolite kotlinâs all documentation wikipedia.org/wiki/Vacuous_truth Vacuous truth - Wikipedia.
-
@nishio: try to reduce misunderstandings by writing the definition of any as âone or more elements of an array are ~â
@3156: I wonder if the fierce people who are saying true is the only choice in this discussion and anything else is disqualifying are usually only implementing the standard library? I thought most programmers work at the application level? If the customerâs request is ambiguous, you would work out the details before implementation. Is the subject of âprogrammerâ too big?
@kis: if itâs a customer request, that would be about the business logic implementation, not âtrue if the array meets all the conditionsâ or âif the cart meets the shipping conditions. I think it would be about something like âdoes it meet the requirements?â. @kis: Also, in the end, when creating application logic, it tends to be a more robust process if the business rules are based on mathematical principles, so a sense of body I think it is better to have it as a physical feeling.
@ito_yusaku: I feel like the factor that divides the opinions in this discussion, is how the person in question was born and raised as a programmer. I think the factor that divides this discussion is the environment in which the programmer was born and raised. People with formal programming education probably choose true. (additional fuel dropped)
@kazuho: You know, itâs interesting that there is no argument like âthe name of the function can be all or something like that, but the definition should say âa function that returns whether or not any element in the array does not satisfy the conditionâ. It was interesting that there was no claim like âthe name of the function should be all or something like that, but the definition should say âa function that returns whether or not any element in the array does not satisfy the condition. Itâs a balance between correctness and not creating misunderstandings.
@chokudai: The reason I strongly insist that you return true is because I believe that doing something that goes against logic in a place where logic can be understood has a significant impact on the overall delay in development speed and seriously reduces Japanâs development capability. Iâm sorry if you donât agree with me, but Iâm not good enough at explaining myself.
-
@nishio: To explain this with another metaphor, âI think itâs a good idea to put an automatic 10% sales tax on the sum implementation, because itâs used to total the price of the item!â I think itâs a good idea!â to someone who says âNo, itâs not a good idea! to someone who says, âItâs not a good idea!
-
@chokudai: you definitely explain it better this way!
-
@methane: great clarification.
-
I think you say âit depends on the requirementâ because you assume that a requirement that is clearly a generic process must be blurring out some specific business requirement instead of the actual requirement.
-
Itâs a question of reading what is written as it is written.
-
@inuro: I see this kind of design where the separation of responsibilities is vague, often unfortunately.
-
@yururi0818: personally I think itâs a good metaphor, There are so many systems in the world where sums are implemented in this way, I feel that the more you speak in parables, the more diffuse the discussion becomes.
-
@nishio: it doesnât spread. For example, if there are many âbuggy programsâ in the world, it doesnât mean that the buggy ones are right.
-
This is a variant of this.
-
Deteriorated copies spread - Just because there are a lot of buggy programs out there doesnât make being buggy right.
This page is auto-translated from /nishio/all(empty)==true using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. Iâm very happy to spread my thought to non-Japanese readers.