[AS3] Losing my religion: subclassing vs. composition

I have been until now a fervent disciple of compositing a
graphic instance into a class in every case, rather than making my
class extend MovieClip. Admittedly I was a piker at AS2 and only
now that I am cranking on AS3 do I consider myself worthy to call
myself a beginner OOP programmer. But I bought into all the
reasons, and if I were still making AS2 apps, I might remain in
that camp.
But lately my devotion has been shaken and now I am seriously
considering extending (and then subclassing from) MovieClip or
Sprite when making any class which has a visual component. Whereas
before I would always compose in a MC instance, almost never make
my class inherit from anything but my own superclass, and implement
interfaces for polymorphism, now I think I will extend, although
still implement interfaces for the usual other reasons. I also
still plan to be a composition devotee in all other ways-- I like
composition more than inheritance. Also I would not extend MC for
classes which have no graphical component, such as game logic
components. (I am making games and other interactive entertainment
apps, for in-browser distribution.)
Can I please be illuminated by better coders than I as to the
wisdom or folly of my change of heart?
Here are a few reasons why my mind is changing; please feel
free to refute or support any of these:
--Changes between AS2 and AS3 make the downside of
subclassing MC/Sprite smaller than before. I'll let far more
informed people come up with good examples, but one seems to be the
explicit nature of adding an object to the display list-- the
overhead hit of being an MC is small (nonexistent?) if it is not on
the list.
--Colin Moock, in his seminal "Essential ActionScript 2"
book, advocated composition-- see his large MVC example in which
his view class, although nearly entirely visual in function, did
not extend MC but rather composited MC. However, in Moock's equally
impressive AS3 book, all his examples now seem to use extension. I
really admire Moock so this gives me a new perspective.
--All the Adobe best practices and examples use extension, as
do nearly all code samples I see in other helpful forums. I am not
one to blindly run with the crowd but I think I'd get better
feedback on my code from my peers if I follow suit.
--All the AS3 Flash components seem to use extension, and
indeed, AS3 itself is heavily inheritance-based rather than
composition-based, for understandable reasons.
I am probably missing a lot and mis-stating much of what is
there but hopefully you get the idea.
So once again I ask my better peers: what are now the
arguments for and against extending MC or Sprite for one's visually
represented classes in AS3? Any observations would be much
appreciated.

Here is a bit more concrete example:
In Moock's AS2 book he has an extensive example of the MVC
pattern involving, what else, a clock. In his code his Clock view
does *not* extend MovieClip (Sprite not having been available in
AS2), which is in keeping with his general admonition to compose a
graphic element into a class rather than extend one. His view's
constructor takes an MC as an argument, and the view attaches its
MC instance (which contains all the clock visuals) to the passed
MC. The view object is not itself attached, because it is not an
MC. The view class contains an MC which ends up getting attached.
To change the XY of the view would be to ask the view to change its
MC instance's XY. Pure composition.
In Moock's AS3 book he has an extensive "Virtual Zoo" example
which among other things uses an MVC-ish structure, in which the
view and controller are the same class. If anything, this would
make composing in the view's root graphic element even more
sensible than his AS2 example. The View does not really fit the
definition "is-a Sprite"; it also is a view manager and controller.
But, contrary to his AS2 stance and in keeping with all the other
examples in his AS3 book, Moock's view class *extends* Sprite, and
is added as a child by the main class. Though the view does happen
to contain objects which are also made from Sprite-extending
classes (pictures of the zoo animal and the like), the view class
does not contain its root sprite the way the AS2 example contained
its root MC. The view *is* a Sprite. To change the XY of the view
would be to simply set its inherited XY properties from the
outside, as any Sprite would be positioned. So though Moock still
is a devotee of composition in every other way, on this one point
he seems to have decided to use inheritance and take a path
different from his AS2 book.
And I have seen most other AS3 code examples follow suit. The
Lott AS3 book does, and all the Adobe examples do. So forgive me
for having my faith shaken a wee bit.
Though I remain convinced of the rule to favour composition,
in this particular set of cases I am considering routinely using
inheritance, even though I easily *could* use composition. It just
seems to be messier, denser, and longer to use composition *in this
set of cases*. So is my reasoning good, faulty, or does it simply
betray deep cluelessness about OOP?

Similar Messages

  • How to achieve polymorphisim using composition

    How to achieve polymorphisim using composition

    Not possible. This is very wrong, polymorphism is very much facilitated by Composition (or Aggregation).
    Polymorphism goes hand in hand with
    either imlementing an interface or extending a class.The fundamental objective of Polymorphism is the handling/using Objects of multiple types in a uniform manner, i.e. to a fixed contract.
    Composition may be used to delegate the
    implementation of an interface or subclass' method.Composition allows much more than delegation, it about defining a static contract between two objects.
    composition itself is not polymorphic.The main difference between simple composition and polymorphism is the valence. In Polymorphism it is explicityly 1. .N in the case of composition it is implicitly 0..N
    I think this code proves that a Composition of classes for Odd and Even can be used polymorphically.
    public class Polymorphism {
      abstract public class Base {
        public void method()
          System.out.println( this.getClass().getName() + ".method()" ) ;
      public class Odd extends Base {
      public class Even extends Base {
      final int ARRAY_SIZE = 10;
      Base[] composition = new Base[ARRAY_SIZE] ;
      public Polymorphism() {
        for(int i = 0 ; i < ARRAY_SIZE ; i+=2 )
          composition[i] = new Even() ;
          composition[i+1] = new Odd() ;
      public void process() {
        for(int i = 0 ; i < ARRAY_SIZE ; i++ ) {
          composition.method() ;
    public static void main(String[] args) {
    Polymorphism polymorphism = new Polymorphism();
    polymorphism.process() ;

  • Petition: "Insert to queue" function for creativ

    I would really appreciate such an option in zens. I was disappointed that my micro didn't have it. It might be confused with "add to selected" but it's quite different, let me explain it by an example.
    For instance with "add do selected" i added 00 songs to my selected music. While listening to those songs let's say in shuffle mode(that's i use most), all of a sudden I wanted to listen R.E.M losing my religion, and just after that let's say linkin park-numb. So what I do is although it's in my selected music I enqueue losing my religion as st and numb as 2nd. These songs play and aferwards it continues with other songs in my list. The use of it is I can do it any time I want, i don't need to create a playlist in a certain order each time my tastes change.
    I remember there was such a function in winamp, maybe it was a plug-in or a patch, I'm not sure.
    I guess an "insert to queue" tab in the menu appearing when you tab the scroll pad in the "selected music", would be very useful and I would be very grateful for it. It wouldn't be a hard thing to include in the firmware i guess.
    SSR said Rio Karma had such an option. It would be nice if my zen had.
    So, to sum up:
    I signed for the petition to include "insert to queue" in the next firmware for all zens

    a play next or insert into que option would be good.
    Also when adding music to a playlist on the player, i've found the only wauy to insert a track somewhere is to open a playlist, then add a new track, then go to selected music, if you select change order it wont let you put the new track in the playlist, loaded in selected musis, only at the top or the bottom of a playlist.
    the only way round this is to have just the playlist and the aditional tracks loaded then to save them as a playlist with the same name, it will say "playlist already exists on player overwrite?" save it, then clear the selected muisc, re-load the playlist with the new tracks at the bottom or the top, and then sort out the order.
    save and overwrite the playlist again, and the new tracks have been inserted.
    theres got to be an easier way than that, come on creative.

  • How to copy sap standatd report to add fields and to make it work

    Hi experts,
        Can you tell me how to copy the sap standard report to add fields.
    I copied regular way including all includes also, but the porgram not activated and also every field started with %
    exp : data %dtab type standard table of /1BCDWB/IQ000000008078 with header line.
    Thanks

    Local object yes.
    I realise you're not an abaper, but if you got one in, he could simply create a subclass of /SAPPSSRM/CL_FY_NUMBER  (assuming it's not been made final) and override only the method that needs changing.  ( if it is final, then you have to use composition, but again, that's pretty straight forward ).  The point is, that copy a class rarely, if ever, needs to be done.  That's one of the major points about using classes.  If you use subclassing or composition, only small amounts of code need to be copied - which means if SAP change other bits in a new release, you automatically get them, thereby reducing the risk of an upgrade mucking up your cloned class.
    I'd be extremely nervous about having any code that had been implemented by a non-developer, being put into productive use.
    matt

  • Album art request for community

    Hello!
    If you can find
    Losing My Religion - EP
    from your countrys iTunes store, could you change some songs info match it and get cover art.
    Then could you copy the cover art from iTunes into paint or something else and make it PNG img and share it here.
    I will give points to whoever gave the img.
    I need it for my song, which is not available in my iTunes store.

    As long as you choose anything above 600x600 for example 1000x1000 itunes will resize it accordingly.
    I always aim for the larger sized album art because the resolution and therefore image quality is better.
    Hope that helps.  ;o)  In the meantime this is the album art for the Out Of Time Album which contains losing my religion (originally it was at a higher resolution but as stated above itunes has resized it to 600x600)

  • DPL and composite pattern

    Hello...using DPL, JE (3.1.0), and trying to come up with a design that fits the following mold:
    @Entity
    public class Thing {
       @PrimaryKey
       long id;
       @SecondaryKey(relate=MANY_TO_ONE)
       int thingTypeId;
       // how to link this to thing attribute model below?
       List<ThingAttribute> thingAtts = new ArrayList<ThingAttribute>( );
    }Thus, a Thing can have a list of attributes. A thing has a unique id (primary key), and a thing has a thing-type id...and there can be many instances of that thing-type, so it is MANY_TO_ONE.
    Now, a ThingAttribute follows the Composite Pattern...as below. I took a stab at annotations here, but I'm not sure it seems correct:
    @Persistent
    public abstract class AbstractThingAttribute {
       /* only simple attribute subclass has an id -- composite subclass does not
        * so we add a sequence here
       @PrimaryKey(sequence="ID")
       long id;
       // thing type id
       @SecondaryKey(relate=MANY_TO_ONE)
       int thingAttributeType;
    @Entity
    public class SimpleThingAttribute<T> extends AbstractThingAttribute {
      // unique id
      @SecondaryKey(relate=ONE_TO_ONE)
      long id;
      // generic type value
      T value;
    @Entity
    public class CompositeThingAttribute extends AbstractThingAttribute {
      // this is a recursive-definition relationship; not sure how to deal with DPL?
      // list of children
      List<ThingAttribute> children = new ArrayList<ThingAttribute>( );
    }As an aside, there is an interface for ThingAttribute, SimpleThingAttribute, and CompositeThingAttribute...this is not too relevant for this example, but Simple/Composite interfaces extend the ThingAttribute interface.
    Q1) If I create a new Thing object, and I want to persist it, it is clear to me how it works for the primary secondary key here, but how do I annotate the ThingAttribute hierarchy such that it gets persisted along with the Thing object? I guess this boils down to a couple things:
    a) how to treat the thingAtts ArrayList in a Thing object itself so it gets persisted?
    b) now, i have a list of objects, where each entry in the list follows the structure of the composite pattern. how should i approach annotating this model?
    Thanks in advance,
    Davis

    Hi Davis!
    Q1) If I create a new Thing object, and I want to
    persist it, it is clear to me how it works for the
    primary secondary key here, but how do I annotate the
    ThingAttribute hierarchy such that it gets persisted
    along with the Thing object? I guess this boils down
    to a couple things:
    a) how to treat the thingAtts ArrayList
    in a Thing object itself so it gets persisted?You just embed the thingAttrs object (as you have) in the entity. As long as the class is @Persistent (or a simple type) you can persist arbitrarily complex graphs of objects. The thin to remember is that it is stored as one object graph per entity, indexed by primary key and optionally by one or more secondary keys.
    b) now, i have a list of objects, where each entry
    in the list follows the structure of the composite
    pattern. how should i approach annotating this
    model? Don't annotate the embedded objects with @Entity, just with @Persistent. @Entity is only used when you want a separate PrimaryIndex. Objects embedded inside an entity are annotated with @Persistent only.
    So when you have multiple objects you can use either embedding or relationships. With embedding, the object graph for the entire entity is stored in a single record.
    With relationships, you store the keys of one entity as a field in the other entity, and you annotate that field with @SecondaryIndex(relate=..., relatedEntity=...). With relationships, you have to get the related object yourself via its own PrimaryIndex.
    Hope this helps,
    Mark

  • Questions on composition and assosiation relationship

    Which two are true about the composition relationship "A Blip consists of many
    Blipverts."? (Choose two.)
    A. A Blip must have at least two Blipverts.
    B. A Blipvert can be a part of only one Blip.
    C. A Blipvert must be part of at least one Blip.
    D. When a Blipvert is deleted, its Blip should also be deleted.
    E. When a Blip is deleted, each of its Blipverts should also be deleted. Answer: BE
    according to me its answer shud be C and E. as composition says that one can not exsit without other..means blipvert can not exist without blip..hence it must be part of atleast one blip..
    but actual answer given in book is B and E.
    Can some one explain.
    Question on Assosiation
    Which is true about association navigation?
    A. Association navigation is meaningful for only OO design, NOT implementation.
    B. Association navigation is used to describe the relationship between a subclass and its superclass.
    C. Association navigation indicates which direction a relationship can be traversed.
    D. Association navigation indicates how many instances of each object type are involved in an association.
    Answer should be C and D....D because we mention the how many instances can one have of other....example 0..1, 1..* etc etc...so D should also be an answer
    but in book it is only C..
    can someone explain this.
    Am i wrong in my explanation?...
    Thanks

    (Choose two.)Choose none. This is not a homework answering site for your multiple-choice questions, that are only designed to elicit whether you have done the study they are about. Future posts of this nature will be deleted without notice. Locking this thread.

  • Losing SFSB after exception thrown - how can I avoid this?

    I am using Sun Java System Application Server 9.0
    I am using a State Full Session Bean (SFSB) via a Remote Business Interface. In this SFSB I do a �try/catch� to perform an update on an entity with child entities. My catches look for an OptimisticLockException and any other exception. When Oracle throws an OptimisticLockException the catch does not recognize this and catches the any other exception. In both case another exception is thrown, see below for the code. But when this happens the SFSB is destroyed and no longer available causing the client to fail when it tries to use one of the SFSB�s business interface methods.
    Can anyone please tell me how I avoid losing the SFSB or how to reload it automatically and quickly?
    A plus would be can you tell me why the Oracle exception is not caught by the correct catch? The full exception is oracle.toplink.essentials.exceptions.OptimisticLockException and I have no idea whether is a subclass of another exception type.
    } catch (OptimisticLockException ole) {
         Debug.debugPrintln("OrderControllerBean.updateOrder() - optimistic lock exception: " + ole.getMessage());
         throw new EntityAlreadyUpdatedDeleted("Order number: "
                        + oldOrderHeader.getOrderNumber()
                        + "cannot be updated because it has changed or been deleted since you last looked at it");
    } catch (Exception ex) {
         Debug.debugPrintln("OrderControllerBean.updateOrder() - other exception persist failed orderNumber: "
                        + oldOrderHeader.getOrderNumber()
                        + " exception: " + ex.getMessage());
         throw new EJBException(ex);
    Many thanx����.
    Edited by: jdraven on Mar 27, 2008 11:06 PM

    No worries!
    Thank you for sharing the solution to your problem with the community!
    Kameralina
    Ask NI (ni.com/ask)
    Search The KnowledgeBase
    NI Developer Zone
    Measure It. Fix It. ni.com/greenengineering/
    NI Vision ni.com/vision/

  • Motion 5 crashes on opening compositions

    When trying to manually add a key frame to text in the properties tab (if I remember correctly) the user interface lost part of its visibility (buttons, the timeline and other GUI parts disappeared) and the program became unresponsive.
    After restarting and ever since I cannot open motion documents (compositions), new or old, without the program crashing. Tried it with different resolutions to no avail. I can only open final cut effects, titles, generators or transitions. Repairing permissions did not remedy the problem. Removing the app from the applications and installing it anew from the app store did not remedy the problem. This effectively rendered the program unusable. I have been sending crash reports to Apple in the hope that it will help fix the issue. Still, it does not make up for losing a few day's worth of work in Motion 5. Here's to hoping for a quick update. Just to let you know the problem exists—if you do happen to think of a solution, please fire away.

    I'm experimentin the same problem here. All suddenly it stop working, I get the first screen where I can choose to open a new project or a tempalte but after that what evere I choose it won't do anything, nor opening a new project, template or a old (motion 5) file.
    what can I do?
    I will try to reinstall the software and we'll see.

  • To subclass, or not to subclass? That is the question.

    I have a comand bar built from Command objects. The Command knows how to display itself (flat, then raised w/mouseOver, depressed w/mousePressed...). The command bar may be either an icon bar or a menu bar - the Command knows about icons, text names, tooltip text and so on.
    The icon bar is simpler in its painting (just icon). The menu shows icon (if any) name, shortcut, . . . So should I have a CommandBar class that knows how to display itself in two skins? Or should I have a MenuBar that extends IconBar? Or a MenuBar and an IconBar that both extend CommandBar?
    More generally, given close siblings when should you choose a single class with options and when should you subclass? (Assume that the single class is not so big that division is a practical necessity.)

    You can always use the Decorator (GoF) pattern. Look at what Sun did with collections. You have List (and ArrayList, etc.). There is also a method in Collections: synchronizedList(). That 'wraps' the normal list with a decorator that provides synchronization. For your application, take the 'base' functionality and add a decorator for paint() and fire().
    As far as general design principles, I follow something that is probably not an accepted standard: I only sub-class abstract classes. Sometimes, you get a non-sensical design, such as:
    AbstractButton
    DefaultButton extends AbstractButton (with only a constructor)
    ComplicatedButton extends AbstractButton (with constructor and extra methods)
    Now, from an efficiency perspective, it would probably be best to collapse AbstractButton into DefaultButton and have ComplicatedButton extend that class. However, I have been on too many projects where someone wants to create a hierarchy n levels deep (usually more than three). The problem is that tihs 'freezes' your design, as you can only inherit from a single superclass.
    So, my general solution to this is to have only one level of inheritance, and that inheritance only occurs from an abstract parent. For the remainder of the design, I use interfaces, composition and delegation liberally. This allows the most 'freedom' in your hierarchy without any loss in functionality.
    For example, why inherit from a concrete class when you can simply declare an interface, make a helper that implements that interface's methods and then delegate calls to the helper in subclasses? I now am only inheriting from Object, which allows me, in the future, to inherit from a Java class or my own abstract class.
    That probably did not help answer your question. But that's generally how I approach things. Caveat implementor: other designs may be equally valid.
    - Saish

  • Flex/AS3 Best way to construct a derived class instance from an existing base class instance?

    What is the best way to handle the instantiation of a derived class from an existing base class.
    I have a base class which is being created via remote_object [RemoteClass alias] from the server.   I have other specialized classes that are derived from this baseclass, but serialization with the server always happens with the base class.     The base class has meta data that defines what the derived class is, for example
    [RemoteClass (alias="com.myco...')]
    public Class Base
         public var derivedType:String;
         public function Base()
    public Class Derived extends Base
         public "some other data"
         public function Derived()
    In my Cairgorm command which retrieves this object from ther server I want to do this:
    public function result (event: Object):void
        var baseInstance:Base = event.result;
         if (baseInstance.derivedType = "derived")
              var derivedInstance:Derived = new Derived( baseInstance );
    What is the most efficient way of doing this?   It appears to me that doing a deep-copy/clone and instantiation of the derived class is pretty inefficient as far as memory allocation and data movement via the copy.

    Thanks for the assistance.  Let me try to clarify.
    MY UI requires a number of composite classes.    The individual components of the composite classes are being transfered to/from the server at different times depending upone which component has changed state.    The construction of the composite classes from the base class happens in my clients business logic.
    Composition happens in a derived class; but server syncronization happens using the base class.    When I recieve the object from Blazeds through the remote object event, it is in the form of the base class.  I then need to instantiate the derived class and copy the elements of the base class into it (for later composite construction).   And likewise when sending the base class back to the server, I need to upcast the derived class to its base class.   But in this case just a mere upcast does not work.  I actually need to create a new base class and copy the attrbutes into it.  I believe this is limitation of how remoting works on Flex/AS3.
    My question is, what is the best way to turn my base class into it's derived class so further composite construction can take place.   The way I am currently doing it is to create a  load method on the base class, that takes the base class as on argument.  The load function, copies all of the instance attribute references from the base class to the target class.
    public Class Base
         public function Base()
         public function load(fromClass:Base)
        {  //  copy the references for all of the instance attributes from the fromClass to this class }
    Then,  after I recieve the base class from the server.   I create a new derived class and pass the base class into the load function like this:
                for (var i:int=0; i < event.result.length; i++) {
                    var derived:Derived = new Derived();
                    derived.load(event.result[i]);
    The drawbacks of this approach is that it now requires 2 extra instance creations per object serialization.   One on recieving the object from the server and one sending it to the server.    I assume copying references are pretty efficient.  But, there is probably some GC issues.     The worst of it is in code maintenance.   The load function now has to be manually maintained and kept in sync with the server class.
    It would be interesting to hear how others have solved this problem.      The server side is an existing application with around 2M LOC, so changing the code on the server is a non-starter.
    Thanks for your help.

  • Inserting html into a composition in muse

    Hi, I am trying to insert some html into a composition in Muse.  I would like to have a clickable button trigger, and then a kind of overlay opens up with an interactive calculator inside.  I have the html for the calculator, the problem is no matter how I try to insert it into Muse, the calculator either disappears (as well as the trigger) for some reason, or the calculator stays on the page the entire time, losing the whole clickable effect.
    Can someone tell me the best way to do this?

    Hello,
    Which Composition are you trying to Use ? Blank,Featured News, Lightbox Display, Presentation or Tooltip ?
    Also Make Sure to drag and drop the inserted HTML window over the target (Border of target gets activated once you move it over), Hopefully this will work.
    I created the same using Tooltip composition and its working fine. Please take a look at the link.
    Home
    If it do not work then please share the calculator HTML  code that you are inserting so that I can do some test at my end.
    Regards
    Vivek

  • Multi-layered compositions creating overly large compressed files

    Hi there community!
    FCP HD 4.5
    I have a composition that involves 3 layers of video and 4 audio tracks. It is only short but when trying to compress a sample for the web I'm having difficulty getting the file size down to something reasonable, like between 3 - 5 MB as with my other clips. I've tried exporting the project in uncompressed format and then trying to compress from that single track file, but FCP treats it just the same as the original. The original has a few effects applied and I also modified the composition mode, so it is somewhat complex. I've been trying to compress to quicktime movie using the following:
    video:
    H.246
    size 400 x 300
    quality: medium
    frame rate: 15 fps
    encode: multi-pass - best
    audio:
    mpeg-4
    Resulting file size is 17 MB for a 1 minute clip. Way too high.
    These settings are ideal for my other stuff, but this clip is more complex. I'm a professional preparing video content for the web. What is the nack for squashing a complex project without losing too much quality?

    You should be using Compressor (moreover, you should upgrade 4.5 to 5.1 before the offer runs out).
    Prior to Compressor 2 (and if I want QT 6 compatible quicktimes), I use Sorenson Squeeze. At high quality, I generally get 640x480 resolution at 4MB for 30 seconds. Or I use Compressor and H.264 LAN.
    Both do a far superior job to straight export from FCP.
    Patrick

  • When to use inheritance and When to use Composition

    java support both inheratiance and composition .I also know "is a" and
    "has a realitionship" but there is always a problem with me to understanding whethere i have to use extends or having a object of a class has a member of othere class.
    and also "A pure OOP must support polimorphisim,inheretiance,encapluction,Abstraction and Composition" correct me if i am wrong
    thank you and have a nice day.

    Bruce Eckel, author of Thinking In Java, has this to say about composition vs. inheritance:
    When deciding between inheritance and composition, ask if you need to upcast to the base type. If not, prefer composition (member objects) to inheritance. This can eliminate the perceived need for multiple base types. If you inherit, users will think they are supposed to upcast.
    Choose composition first when creating new classes from existing classes. You should only used inheritance if it is required by your design. If you use inheritance where composition will work, your designs will become needlessly complicated.
    Bill Venners: Composition versus Inheritance
    Use inheritance (of implementation) only when the class satisfies the following criteria:
    1) "Is a special kind of," not "is a role played by a";
    2) Never needs to transmute to be an object in some other class;
    3) Extends rather than overrides or nullifies superclass;
    4) Does not subclass what is merely a utility class (useful functionality you'd like to reuse); and
    5) Within PD: expresses special kinds of roles, transactions, or things.
    -- from Java Design: Building Better Apps and Applets (2nd Edition), by Peter Coad and Mark Mayfield

  • Losing field (in a Composit Object) in an HttpSession

    Hello. I am losing fields in a Composite object (object tree) that I am storing inside of an HttpSession. I'm developing with Tomcat and I saw that Tomcat implements the put/getAttribute methods with a Hashtable.
    So in my case, I store object A. in an HttpSession. For a user requests, I get A. and do some processing that sets object D. If I put that object back into the session and come back to it in a later request, object D has now been lost.
    A
    B
    C
    D
    Is there some contract that I'm missing here? I don't think these objects (A - D) need to be serialized. What am I missing here?
    Thanks in advance
    Tim

    It is very difficult to figure out what is going wrong from the info u have given. Examine your server log carefully if you can find any clue.
    You may also write a listener implementing HttpSessionAttributeListener and implement the methods
    attributeAdded(HttpSessionBindingEvent) ,attributeRemoved(HttpSessionBindingEvent) ,attributeReplaced(HttpSessionBindingEvent) to write some meaningful message in logs.
    Track the message generated by attributeRemoved() method in particular to find out when exactly is your object D going out of session. May be that will give u some clue. You can use HttpSessionBindingEvent.getName() and
    HttpSessionBindingEvent.getValue() methods to know about the object added/removed/reset in your session that has invoked the particular method in your listener.
    Also you will need to register the listener class in your web.xml for that to work properly.
    You will find more examples/help of this listener in net if u do a google search.

Maybe you are looking for