Search Results

Search found 2 results on 1 pages for 'thesender'.

Page 1/1 | 1 

  • anonymous function variable scope [js, ajax]

    - by arthurprs
    $(".delete").click( function() { var thesender = this; $(thesender).text("Del..."); $.getJSON("ajax.php", {}, function(data) { if (data["result"]) $(thesender).remove(); // variable defined outside else alert('Error!'); } ); return false; } ); This can cause problems if user clicks on another ".delete" before the ajax callback is called?

    Read the article

  • Conceptual inheritance implementation

    - by TheSENDER
    Hi there, I'm writing a spatial data structure and I have a doubt about what's the best NODE implementation. According to my design I have an abstract node entity and three classes which inherit from it: EMPTYNODE, FULLNODE, INTERNALNODE. The first one has no particular data. The second one has 1 reference to a generic element. The third one has 2 references to other nodes. I have found several ways to implement this situation (that I have already coded) but I can't decide what's the best. The first solution that I have found is to use a single class Node that potentially performs all the operation in this way: private static class Node { private Elem elem = null; private Node left = null, right = null; public Elem getElem() { assert isFull(); return elem; } public boolean isEmpty() { return elem == null && left == null; } public boolean isFull() { return elem != null; } public boolean isInternal() { return elem == null && left != null; } } The second solution is to write an explicit division by classes where every class offers only its methods. Obviously in this way we are obliged to perform several casts to the node objects. private static abstract class Node { public abstract boolean isEmpty(); public abstract boolean isFull(); public abstract boolean isInternal(); } private static class FullNode extends Node{ private ITriangle elem; @Override public boolean isEmpty() { return false; } @Override public final boolean isFull() { return true; } @Override public final boolean isInternal() { return false; } public Elem getElem() { return elem; } } The third one solution is to use the inheritance allowing every classes to offer all the methods, but the object type should by check by "isEmpty()" and similar methods. In case of wrong call we'll throw an exception. private static abstract class Node { public abstract boolean isEmpty(); public abstract boolean isFull(); public abstract boolean isInternal(); public abstract Elem getElem(); } private static class Empty extends Node{ @Override public boolean isEmpty() { return true; } @Override public final boolean isFull() { return false; } @Override public final boolean isInternal() { return false; } @Override public Elem getElem() { throw new AssertionError(); } } What do you think about these three solutions? Which one would you use? Any other ideas? Thanks for your help. Every idea will be appreciated.

    Read the article

1