Designing operation (a,b) -> (c,d)
        Posted  
        
            by 
                golergka
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by golergka
        
        
        
        Published on 2012-06-15T21:09:00Z
        Indexed on 
            2012/06/15
            21:16 UTC
        
        
        Read the original article
        Hit count: 186
        
I have an operation that I need to design. That operation takes two objects of a certain class X, and returns two new objects of the same class (I may need the originals later). The logic that dictates the selection of this object is contained in class Y. On one hand, I don't want class Y to know details about class X implementation; on the other, I don't want class X to know details about selecting the different objects to perform this operation on.
If that was all the problem, I'd just create a static method on class A. However, the methods in language I'm working on return only one object. Also, the operation needs to be robust, and calling operation two times to get C and D respectively isn't possible, as both C & D both rely on a single random number.
How should I design such operation?
Update: I'm using Obejctive C.
© Stack Overflow or respective owner