jeudi 28 octobre 2021

Which pattern should I choose? [closed]

I am facing a problem and would like to hear an advice. On my website, customer has a wallet balance. Customer can do 4 things - Buy, Sell, Send fiat currency, Send cryptocurrency.

Each of these 4 operations change the wallet balance.

Read about an observer pattern but that would be more useful when you have few publishers and lots of subscribers. In my case these are 4 publishers(buy,sell,fiat,crypto) and 1 subscriber(wallet balance).

class SendFiat(){
    SendFiat();
}

class SendCrypto(){
    SendCrypto();
}

class Buy(){
    Buy();
}

class Sell
{
    Sell();    
}

All of these 4 methods, influence wallet balance record in database. When this is updated, I use SignalR to update html on client-side but that's another story.

Which pattern should I choose?

Aucun commentaire:

Enregistrer un commentaire