Upgrade to Pro — share decks privately, control downloads, hide ads and more …

M250 Unit 1 Subsection 6 - Classes as software ...

Avatar for Matt Matt
January 05, 2020

M250 Unit 1 Subsection 6 - Classes as software components & recap of essential Unit 1 terminology (5)

Here we finish unit 1.

Avatar for Matt

Matt

January 05, 2020
Tweet

More Decks by Matt

Other Decks in Education

Transcript

  1. M250 Unit 1 Subsection 6 Classes as software components &

    recap of essential Unit 1 terminology
  2. Classes can be thought of as software components in the

    sense that they can form a part of a greater whole (a bigger programme). Instead of a programme needing to be written from the ground-up, it can incorporate pre-written classes as a component of the programme.
  3. One analogy to real life would be that of a

    baker. The baker might make some bread, but the baker doesn’t need to make the flour that is used in the bread, she can buy her own. The flour we can think of as a class -- in that it has defined attributes and behaviours. But we can also think of it as a software component of the bread, allowing the baker to save time and effort by using it and not needing to ‘reinvent the wheel’.
  4. In much the same way, software companies will use software

    components developed by other software companies. In fact, many companies specialise in producing useful software components to sell to others. These can have a very general use or a very specialised use. But remember, to a programmer these software components are just classes developed for a purpose.
  5. Important distinction It’s important to remember that it is the

    class that is the software component, not the object. What is sold is the code for creating instances of the class, not the instances of the class themselves. This makes sense when you think about it. A class is tangible. It exists in the real world. If I really wanted to, I could print out a class and use it as wallpaper. An object isn’t tangible. I can’t touch it. It’s just software running on the computer. It’s virtual.
  6. So because we can make our software from software components,

    then we can simply replace these components with better and more reliable versions as they are developed or needed.
  7. Recap of essential unit 1 terminology • Source code –

    The text that we type when writing in a programming language such as Java. • Object – An entity that contains both data and behaviour. • Message – An instruction sent to an object. Ends in brackets. • Message answer – A response sent back from an object as a result of sending it a message.
  8. • Attribute – A characteristic of an object. • Attribute

    value – The value of a characteristic. • State – The collection of all an object’s attribute values. • Behaviour – The way in which an object responds to a message. • Protocol – The list of messages an object understands.
  9. • Identifier – The name we give to an attribute/variable.

    • camelCase – a convention we use for identifiers in which the first word begins with a lowercase letter and subsequence words start with an uppercase letter.
  10. • Variable – A named block of memory into which

    data can be stored. They can either be assigned a value or hold reference to an object. • Message-send – The code comprising of the receiver of a message, a full stop, and the message. • Class – A ‘blueprint for object creation’. Defines the attributes, behaviour, and initial state of newly created objects. Class names are capitalised.
  11. • Instance – An object of a class. Instances of

    the same class have the same attributes and behaviour. • State-dependant behaviour – The state of the object determining its behaviour in response to receiving a message.