Better HN
topnewbestaskshowjobs
Log inSign up

randomdata

8,634 karma · joined Jun 23, 2011 (15y ago) · 7,679 submissions

Submissions

comment 2y ago · link · parent

> Providing working fakes for every dependency isn't always realistic.

I don't know what a fake is. Is that what mockery gives you? Per the dictionary, fake is defined similar to mock, but without the no deception condition, so I suppose that adds up.

There are also stubs, which is defined as something that is truncated or a part of. Which, as it pertains to software, is an implementation that implements some kind of bare minimum to satisfy the interface – often returning canned responses, for example. Mockery arguably also fits here, except the assertion part, which is something else. But I guess that's where fake comes in to draw that differentiation?

> But if you those are params to some external RPC suddenly this actually becomes pretty useful.

Sure, a stub might check the inputs and return an error if some condition is not met, without needing to implement the service in full. This remains true to what the real service would also do.

But that's not what mockery does. It just blows up spectacularly if something wasn't right. That doesn't really make any sense. That is now how the real implementation works. Not only that, but in the case of mockery, its documentation advises that you put the dependency logic in the test. How silly is that? Now when you replace Stripe with Line all your tests are broken. If you used a stub, you merely change the stub to match and you're good to go. This way the tests remain pure, as they need to as they are the contract you make with your users. Changing the contract is unacceptable.

And for all that, it doesn't seem to serve any purpose. But we did ask the other guy for a concrete example (i.e. code) to show where one would want to use it. Looking forward to it.

comment 2y ago · link · parent

Wealth produces income, and usually in a linear way. If you have $1.5M in wealth then you should have 1.5M times more income each year than someone who has $1 in wealth from that source alone. Note: That doesn't imply a $1.5M income; it more likely means you make, say, $50,000 while the other person makes an imperceptible amount.

If that is not the case, you are failing to utilize the asset to its full potential and should be selling it to someone who can. Feeling the pinch on the cost side is the pressure for you to make that happen. Shape up or ship out, as they say.

And, should you ship out, once you do sell it then you have $1.5M to deploy somewhere where you can fully utilize the wealth. Then you will realize the 1.5M multiple to not only to your own benefit, but also society at large. Under-utilized assets harm us all.

If you have $1.5M in wealth, you are unquestionably wealthy. If you choose to forgo the income wealth can provide, thereby hurting on the cost side, that's merely a choice.

comment 2y ago · link · parent

> I have no trouble saying what I think online

Well, sure, you're just dealing with software. What trouble could there be?

The problem with the 'Redditization' of the world is that people fail to recognize that software and people are not the same thing, and start treating people as if they are software. That leads to social issues, just as treating people as if they were dogs leads to social issues.

And here we have proof positive of this happening: You weren't even able to recognize that the world and the internet are not the same place.

comment 2y ago · link · parent

The US was, and remained, stable through those events. Were the US to become unstable, it is true that it would likely take the rest of the economic world with it, but eventually countries with some stability would start to recover. Whereas, whatever conditions made the US unstable would likely only be exacerbated in the mess – economic downturns are not a good time to find stability! – making recovery improbable.

comment 2y ago · link · parent

> The best example of this (IMO) is how `AbstractMap` works in Java.

I think it is fair to say that this is idiomatic Java, and for that reason it is a great example within the context of Java.

But does it translate to the abstract? Given your hypothetical ideal language that allows you to do anything you can imagine as you can best imagine it, is this still a good example, or would you reach for something else (e.g. composition)? Why/why not?

comment 2y ago · link · parent

Without knowing when mockery is useful, it is impossible to suggest an alternative. There may not be a viable alternative in some cases. That is why I ask. Perhaps you can give us a concrete example to work with, even if contrived? Where have you found mockery to be useful?

The above example, of course, isn't a good one as you can inject an in-memory database (i.e. a hash map) with far less effort than running the mockery tool. But, you are quite right that not all situations are as simple.

If I recall correctly, rsc says to just buckle up and provide a working implementation no matter how hard or how much work it requires, but that's easy for someone who works for Google, in a prestigious position at that, to say. We don't all live in the same lap of luxury. I grant some pragmatism here.

What have you got?

comment 2y ago · link · parent

> How nice of you to give a rather elaborate answer to a question asked towards somebody else.

And how wonderful it is that you, dear software, provided another prompt after my last journal entry. I wasn't sure of what to write next, so this prompting has proven quite helpful.

> If I understand things correctly, me, the software is prompting you back!

Prompting is two way street, indeed. Input into the software from the person may produce a result from the software, and the output from the software back to the person may produce a result that is fed back into the software. Lather, rinse, repeat. Again, this is the value that said software offers over a classic journal.

But, regardless, if that is how someone wants to spend their time in solitude, more power to them! But we do see a problem emerging where a growing number of people are not able to differentiate between people and software and are taking that solitary journaling with prompts out into the real world and are treating people as if they are software. But people aren't software, and this leads to social problems. Which isn't terribly surprising. If people treated other people as if they were dogs, you would find an emergence of social problems too. It turns out, for the best outcome of people, people need to be treated like people.

comment 2y ago · link · parent

> Mockery is equally function in the sense that it implements the interface it targets.

Consider a function with a key/value database dependency:

  type DB interface {
   Get(key string) string
   Set(key string, value string)
  }

  func ContrivedFunction(db DB) string {
   db.Set("key", "value")
   return db.Get("key")
  }
And let's test it using mockery:

  func TestContrivedFunction(t *testing.T) {
   db := mocks.NewDB(t)
   if ContrivedFunction(db) != "value" {
    t.Error("unexpected result")
   }
  }
Code looks reasonable enough, but then... Epic failure. This should work, at least it should if `db` is a mock. But it does not work. `db` deceived us. Clearly not a mock in any sense of the word.

But, okay. It is still something. We will play its game:

  func TestContrivedFunction(t *testing.T) {
   db := mocks.NewDB(t)
   db.Mock.On("Set", "key", "value").Return()
   db.Mock.On("Get", "key").Return("value")
   if ContrivedFunction(db) != "value" {
    t.Error("unexpected result")
   }
  }
Wonderful. We're back in business. Tests are passing and everything is sunshine and rainbows.

But now, the contrived project manager just called and, for contrived reasons, would like to change the organization of record keys:

  func ContrivedFunction(db DB) string {
   db.Set("ns:key", "value")
   return db.Get("ns:key")
  }
Ah, fuck! The test just broke again. But it shouldn't have. The utility of ContrivedFunction – that which is under test – hasn't changed one bit. The DB implementation should have been able to handle this just fine. The DB implementation used in production handles this just fine. This mockery tool is fundamentally broken.

But not only is it broken, it doesn't seem to serve a purpose. Why would you even use it?

comment 2y ago · link · parent

Which is funny as the top five comments all fell into the exact trap that the original comment was about – confusing people with software.

Which, to be fair, isn't surprising. If so many people weren't confusing people with software the original comment would have not been posted in the first place. We are here because that confusion has become so commonplace.

comment 2y ago · link · parent

> What's the incentive to do this?

That is no doubt one of life's mysteries, ultimately, but people writing down their thoughts seems to be a common practice amongst humans. One theory is that it helps the brain process information, but who knows? No matter the exact mechanism, though, the incentive is the same as why anyone writes something they are thinking about down.

> Educate people

Forum-going is a solitary activity. There are no people other than you. Just you and your thoughts, along with some software to prompt you with some ideas to think about (which is the value-add over a traditional journal).

And that is the problem with the 'Redditization' of the world being discussed. That solitary activity, which is fine when done in solitude – whatever floats your boat, is leaking out into the real world where other people are there to feel it and that has consequences. An increasing number of people are failing to recognize that software and people are not the same thing, thereby treating people in the real world as if they are software. But people are not software, so you find these social issues emerging.

comment 2y ago · link · parent

Per the dictionary, mock is defined as "not authentic or real, but without the intention to deceive."

As that applies to software, a mock is a fully-fledged implementation of an interface, but not the implementation you use under normal use. For example, a mock might be an in-memory database where you normally use a persisted database. Not the real implementation, but does not try to deceive – it is equally functional.

Mockery appears to be an assertion library that, bizarrely, moves the assertions into interface implementation. What purpose does it serve? You are going to end up testing implementation details by using that, which is a horrible road to go down.

comment 2y ago · link · parent

> Attacks on the account are experienced by me as attacks on me

Right. This is the 'Redditization' of the world spoken of earlier, where an increasing number of people are unable to distinguish the difference between software and people, thereby treating them as if they are one and the same. Which, as it relates to the broader topic, is problematic as they are not the same and that introduces all kinds of social issues out in the real world.

Logically, you know that the LLM behind the arbitrary forum account that attacked you is little more than a fancy random number generator, which is no more significant than a squirrel giving you the side-eye, but as you have anthropomorphized it as being human then you start to see it differently and experience it as if it were a person.

But to anthropomorphize it is flawed. Like seeing Google Maps as being the world[1].

[1] https://news.ycombinator.com/item?id=39993030

comment 2y ago · link · parent

ok

comment 2y ago · link · parent

> While money can’t be created or destroyed (unless you run a central bank…)

That's not the case. Money, of course, is just a promise to provide something of some defined value at some point in the future. Anyone can make such promises. Heck, that's why we invented accounting – to keep track of the promises outstanding and delivered!

comment 2y ago · link · parent

> You can love and hate someone at the same time.

Sure, but if they annoy you, truly, that's it.

> But we aren't software.

You might not be. But there is no one else. There is only the software you are talking to. What, exactly, do you think the impolite words floating around in your head are going to do to you if you write them down? They aren't going to do anything to the software, that is for certain.

comment 2y ago · link · parent

An increasing number of thefts is the premium cost driver right now, though. In this little part of the world, the number of theft claims have increased by more than 300% within the span of just a few years.

comment 2y ago · link · parent

> I don’t know how to say this politely.

Then say it inpolitely? Software doesn't care if you are polite or not.

> Just because I’m addicted to stupid drama online doesn’t mean I want an algorithm to feed it to me.

Understandable, but that which annoys you will not produce addict behaviour. You are drawn to the stupid drama because it does the opposite of annoy you.

comment 2y ago · link · parent

Point out to who? The GPT4-based bot?

comment 2y ago · link · parent

Are they really that different at any age?

comment 2y ago · link · parent

The ‘Hacknewsization’ is most worrisome.

- “The climate is changing and the outcome of that is bad.”

- “The climate doesn’t have enums. Have you tried Rust?”

comment 2y ago · link · parent

> The goal isn't to get any one account to zero but to get a source and destination recorded separately

Right, because transactions are actually two-sided. I give you something, you give me something in return. That's how people work with each other. And, as such, we account for a source and destination because that matches what actually happens.

But often times you only offer a promise. For example, I write some software for you, and in return you offer me food. But I'm not hungry right now, and I certainly don't want food that is going to spoil before I get around to eating it, so instead you promise to give me fresh food sometime in the future when I am hungry.

How do you account for that? You received software services, but gave nothing back in return other than a promise. Well, what if you recorded the promise? Software services in, promise out. You got your software, I get my food, the credit and debit accounts match. Everyone is happy.

Congratulations, you just created money out of thin air! -- And now, later on, I am feeling hungry and am ready to take you up on your food offer. You give me the food, I give back the promise, food out, promise in, I'm fed, debits match credits, and the money is destroyed.

That's exactly why we invented accounting: To keep track of the money being created and destroyed. You wouldn't need accounting if promises never needed to be made. Without promises, you'd have the software services, I'd have the food, and we'd have no reason to think about the transaction ever again. It is the promise that has us wanting to look back to make sure that promises outstanding are made good.

comment 2y ago · link · parent

Cash went out. One half of the double entry is correct. But nothing came back in return. There is no corresponding element of trade to account for. The transaction doesn't balance. Which is obvious in human terms. That's the point of a gift – the transaction isn't supposed to balance! But formal accounting methods are not as fluid as people are.

So, of course, in reality money was created (and then destroyed, it being a gift) in order to make the transaction whole. But as far as this magical fairytale land where money can't be created the entry doesn't work. You can't account for nothing.

Let's say it's not a gift. Let's say someone is borrowing $1,000 cash instead. The same applies. There is no corresponding element in trade to account for. It doesn’t balance. Thus, when the cash goes out you need to create money out of thin air to satisfy the other side of the transaction, which is later destroyed when the cash is returned.

comment 2y ago · link · parent

Why would a troll care if you agree or are giving the side eye? Their whole existence is simply to see if they can goad you into replying.

(And yes, you succeeded!)

comment 2y ago · link · parent

That method only works if money can be created out of thin air, and also destroyed. The grandparent comment was pretty clear that money cannot be created out of thin air, nor can it be destroyed.

A curious contradiction. How do we resolve it?

comment 2y ago · link · parent

Nobody fears posting on Reddit. That's silly. What would there be to worry about? It's just software. It doesn't even recognize that you exist.

The problem is that the real world is increasingly not understanding that the internet and the world are not the same place, and they are treating software and people the same way. It turns out that people are not software. This leads to problems. Those who confuse you with software don't apply the compassion that people would otherwise normally receive, and, as a result, will be quite happy to put you in a bad place.

You know, the 'Redditaization' of the world. Its funny that even here we see the internet and the world being seen as the same thing; emblematic of the exact same confusion that the comment is about.

comment 2y ago · link · parent

> 1. Being colored 2. Doing recreational marijuana 3. Being a specific faith (like wearing Hijab for women) 4. Heck, just being a woman

In what way are these opinions, controversial or otherwise?

Are you suggesting that people of colour, for example, were fired only if they were of the opinion that they were a person of colour? If they were visibly a person of colour, but adamant that they were caucasian, a promotion was in order instead? They just had to believe?

comment 2y ago · link · parent

> "redditization" of the internet

'Redditation' of the world. If it were only taking place on the internet it wouldn't be all that concerning.

1
545556
256