How To Get A New Shirt Make it yourself: How To Get A Shirt Make - - PowerPoint PPT Presentation

how to get a new shirt
SMART_READER_LITE
LIVE PREVIEW

How To Get A New Shirt Make it yourself: How To Get A Shirt Make - - PowerPoint PPT Presentation

How To Get A New Shirt Make it yourself: How To Get A Shirt Make it yourself: Get if from a store or factory: How To Get A Shirt Make it yourself: Get if from a store or factory: Have someone give it to you: How To Get A


slide-1
SLIDE 1

How To Get A New Shirt

  • Make it yourself:
slide-2
SLIDE 2

How To Get A Shirt

  • Make it yourself:
  • Get if from a store or factory:
slide-3
SLIDE 3

How To Get A Shirt

  • Make it yourself:
  • Get if from a store or factory:
  • Have someone give it to you:
slide-4
SLIDE 4

How To Get A New Object

  • Make it yourself (create an object with new):

JPanel panel = new JPanel() ;

slide-5
SLIDE 5

How To Get A New Object

  • Make it yourself (create an object with new):
  • Get it from a factory (another object or class):

JPanel panel = new JPanel() ; . . . Component[] children = panel.getComponents() ;

slide-6
SLIDE 6

How To Get A New Object

  • Make it yourself (create an object with new):
  • Get it from a factory (another object or class):
  • Have it handed over (injected):

JPanel panel = new JPanel() ; . . . Component[] children = panel.getComponents() ; . . . JLabel label = new JLabel("Kelvin") ; panel.add(label) ;

slide-7
SLIDE 7

Make It Yourself Vs. Purchase

  • Make It Yourself

– You get one very specific shirt or object. – You are bound to the specific type of shirt or object.

  • Store or Factory

– Get any shirt or object that meets a general specification:

  • 15" neck and 32" sleeve (sport shirt, dress shirt, sweatshirt)
  • One or more objects extending a base class or implementing an

interface

– Wider selection:

  • Different stores or factories provide different conforming

products.

  • All we care about is the spec (size, interface).
slide-8
SLIDE 8

Make It Yourself Vs. "Gift"

  • Make It Yourself

– You get one very specific shirt or object. – You are bound to the specific type of shirt or object.

  • Gift (Injection)

– Accept any gift that meets the specification

  • 15" neck and 32" sleeve (sport shirt, dress shirt, sweatshirt)
  • One or more objects extending a base class or implementing an

interface

– Don't even have to know where it came from:

  • "Giver" decides on where shirt / object comes from.
  • "Giver" may make it directly or get it from a factory.
slide-9
SLIDE 9

Store / Factory Vs. "Gift"

  • Factory

– You have to be able to find the factory. – If conditions change you need to find a different factory.

  • Gift (Injection)

– Not bound to any particular factory or store. – What you use comes from the "outside."

slide-10
SLIDE 10

Summary for Objects

  • Make it yourself - binds you to a specific concrete

class.

  • Use of factory - allows different concrete classes from a

specific (concrete) factory.

  • Get via injection - binds you only to the behavior

desired (wherever the object originates).

  • Consider the final SwingUI version of the weather station

application:

– Any examples of "make it your self"? – Any examples of "factory"? – Any examples of "gift" or "injection"?