Loading software onto the bits and pieces.

Purely hypothetical, prone to errors and misconceptions on my part, but here goes:

Let's say I have an Uno connected to a shield which is connected to a Leonardo which is connected to a shield which is connected to another shield; in short, a sort of daisy chain where the output of something feeds the input to something else. Maybe that's do-able, I don't know.

When it comes to writing the code do I write something specific for each component's inputs and which spits output out? Again, if that's viable do I need to upload each bit of code to the individual cards, one by one? I ask because I don't actually have any cards yet so I'm thinking ahead to how you do things now. It's possible the starter kit might lead me through this. I did download the Arduino IDE and I can see a menu of devices that you nominate to receive the code that's compiled which leads me to think you write specifically and upload to where it needs to go specifically.

Or do you upload once to the first card and it takes what it needs and throws the rest to the next. Sorry, I know this is probably a naff question but I'd like to understand more about the uploading process before I buy any cards. TIA.

Cards can communicate. Each card is connected to your computer via USB while uploading code to it.
You send your programs, one at a time, to each receiving cards.

That makes sense. I presume then that once you've uploaded the specific piece of code it stays on the card forever until it's either replaced or a master reset takes place (if such a thing exists)?

Am I right in thinking that not all shields require code? The reason I mention this is that not all the shields look like they have a usb port and in the IDE, the Tools -> Board menu doesn't list the screen shield for example, suggesting, you basically wire to it, send it a message, and it does the rest without you needing to write code for it.

Some shields have some smarts, and you would not re-code them. Display shields with their own interface hardwware for example. Many are just devices that are 100% controlled by the Arduino and have no capability to do anything if not connected to a microcontroller. Motor shields, IO expander shields, etc.