dimanche 24 décembre 2017

Observer pattern for store management application

I am willing to take advantage of the Observer pattern in making a retail store management system. I have made a separate library project that has the classes of Store, Product, Vendor, Cart.

The program should be able to update each vendor account balance when any of his products is added to the cart. The store also must update it's contents , ie the products that are available or those that are now sold out and not show them for the customer. The cart itself must update it's value upon the addition or removal of products from it while the purchase is still not confirmed ( paid ).

The product in turn may be a subject to a price change.

As I see it, using the Observer pattern is in order in this project, isn't it?

Can anyone point me to the starting point from which I can take advantage of the pattern.

According to my understanding of the pattern , hope I understand it correctly, I made the following designation ...

In the Cart Class

public class Cart : ObservableCollection<Product> , IObservable<Product>

.....

In the Store Class

public class Store : ObservableCollection<Product>

.....

In the Vendor Class

public class Vendor : IObserver<Product>

....

And the product class is a standard class with product properties...

..... Is this the prober implementation of the pattern in my case or I am missing something in the structure?

Is there a better way to do the Store management operations than using this pattern?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire