<Taking Suggestions for Subject Line>



  • If it doesn't work, use more inheritance? I really have no idea what the original programmer was thinking ...

    public class Item {
      public String activationData = null;
      public String activationNote = null;
      .
      .
      .
      public Integer itemId = null;
      .
      .
      .
    }
    

    public class ItemData {
    public Vector<Integer> itemIds = null;
    }

    public class ItemDataDelete extends ItemData {
    public ItemDataDelete(Vector<Integer> items) {
    itemIds = items;
    }
    }

    public class ItemDataQuery extends ItemData {
    public int type = 0;
    public ItemDataQuery(int type) {
    this.type = type;
    }
    }

    public class ItemNoteData extends ItemData {
    public String note = null;
    public ItemNoteData (String note) {
    this.note = note;
    }
    }

    public class ItemMassNoteData extends ItemNoteData {
    public ItemMassNoteData(String note) {
    super(note);
    }
    }

    public class ItemActivationData extends ItemData {
    public Item activatedData = false;
    public String activationNote = null;
    public ItemActivationData(Item activated, String note) {
    this.activated = activated;
    this.note = note;
    }
    }

    public class ItemSplitData extends ItemData {
    public Item split = null;
    public ItemSplitData(Item split) {
    this.split = split;
    }
    }

    public class ItemInfoData extends ItemData {
    public Item merged = null;
    public ItemInfoData(Item merged) {
    this.merged = merged;
    }
    }

    public class ItemStatusData extends ItemData {
    public String reportStatus = null;
    public ItemStatusData(Vector<Integer> itemIds, String reportStatus) {
    this.reportStatus = reportStatus;
    this.itemIds = itemIds;
    }
    }

    public class ItemDataThread extends Thread {
    private Analyzer analyzer = null;
    private Vector<ItemData> stack = null;

    public ItemDataThread() {
    analyzer = new Analyzer();
    stack = new Vector<ItemData>();
    }

    private ItemData getData() {
    ItemData ret = null;
    synchronized(stack) {
    if (stack.size() > 0) {
    ret = stack.remove();
    }
    }
    return ret;
    }

    public void addData(ItemData data) {
    synchronized(stack) {
    stack.add(data);
    }
    }

    public void run() {
    while(true) {
    try {
    ItemData data = getData();
    if (data != null) {
    analyzer.processData(data);
    } else {
    sleep(10);
    }
    } catch (Exception err) {
    err.printStackTrace();
    }
    }
    }
    }

    public class Analyzer() {
    .
    .
    .
    public void processData(ItemData item) {
    if (item instanceof ItemStatusData) {
    ItemStatusData data = (ItemStatusData) item;
    dao.setItemStatus(data.itemIds, data.reportStatus);
    } else if (item instanceof ItemInfoData) {
    ItemInfoData data = (ItemInfoData) item;
    Item merged = data.merged;
    dao.mergeItems(merged);
    } else if (item instanceof ItemActivationData) {
    ItemActivationData data = (ItemActivationData) item;
    dao.setItemActivationStatus(data.activationData.itemId, data.activationData.activationStatus, data.activationNote);
    }
    .
    .
    .
    .

    }
    }



  • That seems like a very zen approach to programming. If you have an implementation problem, abstract it until it becomes a design problem.



  • @zelmak said:

    If it doesn't work, use more inheritance? I really have no idea what the original programmer was thinking ...

    Something along the lines of "Hmm, if only there was a way to make a single function that did different things according to what type of object it was called on", I'd hazard a guess.




  • @db2 said:

    That seems like a very zen approach to programming. If you have an implementation problem, abstract it until it becomes a design problem.

    I knew that guy ... 'architecture astronaut' ... kept abstracting stuff out and down and up ... never wrote any functional code ... until the contract failed due to failure to deliver.


Log in to reply