Back to list
Views:   3.7K
Replies:  0
Archived

VS 2008 - Product location management with strategy pattern

Hi all experts!
I'm currently developing a WinMobile application for picking system.
The user must have the possibility to change the positions of the products on the shelf (using the built in barcode reader);
I would like to manage three different situations:
  1. scan a product barcode , scan a product location and assign the product to the location;
  2. scan a product barcode and remove from its current location (the product goes in a "waiting list" for subsequent location assignment);
  3. scan a product barcode, scan another product barcode and exchange their positions
I think that strategy pattern is the solution; am I right?
This is the code I've written so far:
//Strategy
public interface IChangeLocationStrategy
{
  void Assign(PickLocation source, Location target);
}
//Context class
public class PickLocation
{
    public IChangeLocationStrategy ChangeLocationStrategy { get; set; }
    
    public Product Item { get; set; }
    public Location Bin { get; set; }

    public PickLocation() { }

    public void MoveToNewLocation(Location target)
    {
        ChangeLocationStrategy.Assign(this, target);
    }

    public void RemoveFromCurrentLocation()
    {
        ChangeLocationStrategy.Assign(this, null);

    }
//the first concrete strategy class
public class SyncAssignment : IChangeLocationStrategy
{
    #region Change location strategy

    public void Assign(PickLocation source, Location target)
    {
        PickLocation newAllocation = new PickLocation();
        newAllocation.Bin = target;
        newAllocation.Item = source.Item;
    }

    #endregion
}
But now I'm confused... it seems to me that the method defined in the interface ins't correct  to manage also the other two cases.
Can anyone help me?

Thanks!
BARBON DARIO, Dec 14, 2012


Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas