object oriented software development
play

Object Oriented Software Development Naufal F. Setiawan School of - PowerPoint PPT Presentation

Object Oriented Software Development Object Oriented Software Development Naufal F. Setiawan School of Computing and Information Systems University of Melbourne Workshop 2 (All images from Wikimedia Commons) Object Oriented Software


  1. Object Oriented Software Development Object Oriented Software Development Naufal F. Setiawan School of Computing and Information Systems University of Melbourne Workshop 2 (All images from Wikimedia Commons)

  2. Object Oriented Software Development Question 1 How do you check equalities for the following different types? int double String

  3. Object Oriented Software Development Question 1 cont... Why shouldn’t we use == on Strings or other objects (i.e. Classes that we may make later)? Answer

  4. Object Oriented Software Development Question 1 cont... spidey1 spidey2 Implementation spidey1 == spidey2 will return false . spidey1.equals(spidey2) should return true . spidey1 == spidey1 will return true .

  5. Object Oriented Software Development References In Java, non-primitive variables are stored using references. References are similar to pointers in the sense that they store addresses to where instances are stored . They are much nicer than pointers as we don’t need manual dereferencing ( & , * , -> ). We may find it useful to visualize references as name tags.

  6. Object Oriented Software Development Visualizing Variables Code new Elephant();

  7. Object Oriented Software Development Visualizing Variables elph1 Code Elephant elph1 = new Elephant();

  8. Object Oriented Software Development Visualizing Variables elph1 elph2 Code Elephant elph2 = elph1;

  9. Object Oriented Software Development Visualizing Variables: Mutations elph1 elph2 Code // does elph2 change too? elph1.setFace(new HumanFace());

  10. Object Oriented Software Development Visualizing Variables: Mutation � = Reassignment! elph2 elph1 Code elph2 = new Elephant();

  11. Object Oriented Software Development Visualizing Variables Recap: var = ... Assignment is like slapping name tags. On other contexts, the variable refers to whatever it is referring/pointing to.

  12. Object Oriented Software Development Question 2 What is method overloading ? Answer

  13. Object Oriented Software Development Overloading Examples The Good public void connect(String url) {} public void connect(IPAddress ip) {} The Bad public float max(float x, double y) { ... } public float max(double x, float y) { ... }

  14. Object Oriented Software Development Java Theory What is type casting, and describe the following types of type casting: Answer Type casting: Explicit typecasting: Implicit typecasting:

  15. Object Oriented Software Development Java Theory What is boxing and unboxing? Answer Boxing: a typecast Unboxing: a typecast

  16. Object Oriented Software Development Boxing Example Boxed variables are stored as an object, while unboxed variables are stored as a primitive data. Example int someNumber = 3; Integer boxedNumber = 3; someNumber.shortValue(); // doesn't work boxedNumber.shortValue(); // works Boxing does not have many benefits for now until we learn Generics later on.

  17. Object Oriented Software Development Wrapper Classes are still useful Most wrapper classes are useful due to their static methods . Example int number = Integer.parseInt(inputString); Notice that the most visible difference between a static and instance method is how we call them!

  18. Object Oriented Software Development Design Suppose we are developing for an uber-like start-up. How should we implement the following classes in a multi-class system? Vehicle Driver What other classes can we implement to help us implement the above classes?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend