Delegate to another object

Hello, I have a dilemma with delegate handling. I have a Storage Widget with a button to upgrade the capacity of Storage State. After releasing the button, I would like to display an upgrade popup. In my case the Storage State class is responsible for that. And now I found two different solutions to accomplish this task. The first one is a classic approach to delegates which looks like this:

void UStorageWidget::CreateUpgradeButtonBinding()
{
	if (UpgradeButton)
	{
		UpgradeButton->OnReleased.AddDynamic(this, &UStorageWidget::InitializeStorageUpgrade);
	}
}

void UStorageWidget::InitializeStorageUpgrade()
{
	if (StorageState)
	{
		StorageState->CreateUpgradePopup();
	}
}

The second way is based on a direct delegation to Storage State:

void UStorageWidget::CreateUpgradeButtonBinding()
{
	if (UpgradeButton && StorageState)
	{
		UpgradeButton->OnReleased.AddDynamic(StorageState, &AStorageState::CreateUpgradePopup);
	}
}

I have never seen anyone do it the second way, so I would like to ask you which solution is better and why. Is the second approach even reasonable?

2nd is how it should be, people who not do that are not simply aware what first argument is for and this is simply pointer to current object code is executed in, but you can put any object in there and function will be called on that object. This also allows to bind more dynamically as with that single function call in loop for example you can bind to multiple different objects

1st method only creates unnecessary steps and instructions for CPU (but it won’t impact performance) you simply doing something that delegate system will do anyway.

Thank you very mych for such a great explanation, this will save me a lot of headache in the future :wink: