byby
Joined 3 years ago
Joined 3 years ago
I disagree, it's not.
3 functions is better. Think about it. Do people write all their stuff in one big function? No. Better to compose higher level functions with smaller ones rather then write one big monolith like you did. The more modular something is the better.
Also IO_function is there for illustration purposes. Technically it's just wrapping print with a name so you can understand the intent. In reality you just use the regular print here without a wrapper, so in actuality only two functions are defined.
>The job of ChatGPT was to make cool_function unit testable. You haven't done it.
It did. By giving it a return value. Just like you did by giving it a new input value.
>You still have cool_function using side effect generating code hitting the actual IO system.
Yeah but one component of cool_function is pure and you can unit test that. Cool function itself can never be tested because it generates no output, you test the unit components of cool function. That's the point of unit tests.
>Genuinely the worst unit test I have ever seen written, on a poor form per line basis, absolute bananas. If you don't understand why [i for i in range(4)] is bad in a unit test and [0,1,2,3] is correct then I need you to walk away from the computer.
Let's just talk about it like adults. Just tell me what exactly about it makes you think it's bad?
Most likely it's some pedantic stylistic philosophy you have? I'm thinking you only want to test literals? Perhaps you prefer [0,1,2,3]? Am I right on the money?
Logic potentially has errors so you don't put logic in your test code. Makes sense, but who cares. For trivial shit it's fine. While in this case the logic in the test is identical to the function, typically 'logic_function' represents something significantly more complex and the list comprehension so I could care less if I'm not following the strictest form of testing. The comprehension is just something akin to an alias shortcut I prefer to use over writing out a massive literal. For the toy example the test is pointless because the logic is identical but typically it's fine to use range as an alias to represent a sequence of numbers.
Someone who strictly follows these stylistic rules without seeing intent or having the ability to bend the rules is just an inflexible pedantic programmer. It's not good to boast about it either by telling other people to walk away from a computer. That's just rude.
ME:
def (x: int):
for i in range(x):
print(i)
It takes an int. Are you trolling now or did you get mixed up with something else?
This is counterintuitive but actually there is raw science to back the opposite fact up. I'm not joking.
The more delusional you are as in the less ability you have to take and accept criticism the more likely you are to be successful. There is a positive correlation for this verified by science.
It gels with my anecdotal experience too. At the top end of success those guys are the most delusional and least accepting of criticism, for example Elon musk or Steve jobs, etc. Etc.
But even on the lower end of the spectrum, senior engineers it's there too. For example people who claim they are able to unbiasedly accept criticism are often the people who are worst at it.
The reason for this is not any sort of deliberate emotional reaction or anything like that. But rather because the brain actively deludes you from seeing the complete truth. It pushes people to construct artificial scaffolds of logic to uphold their existing beliefs.
Senior engineers are not immune to it nor are they better. What determines the senior role has a lot of factors and definitely not all the factors are related to the actual formal senior rank. A lot of it is luck, time, politics and other bullshit that gets people that rank.
Everyone builds these ideals about their identity, their rank, and their engineering ability. The reality is that a lot of it is delusional. By deluding yourself it becomes easy to include other people in your delusion as well and that's how a lot of hierarchies work.
Not saying their aren't competent people out there, but don't fall for the false belief that a rank like "senior engineer" conveys a certain level of emotional maturity to accept criticism.