$30 off During Our Annual Pro Sale. View Details »

CSE460 Lecture 10

CSE460 Lecture 10

Software Analysis and Design
Object-Oriented Principles
(202102)

Javier Gonzalez-Sanchez
PRO

July 10, 2020
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. jgs
    CSE 460
    Software Analysis and Design
    Lecture 10: Object-Oriented Principles
    Dr. Javier Gonzalez-Sanchez
    [email protected]
    javiergs.engineering.asu.edu | javiergs.com
    PERALTA 230U
    Office Hours: By appointment

    View Slide

  2. jgs
    Object-Oriented Principles
    Design

    View Slide

  3. jgs
    460 00001010
    Key Concepts
    Encapsulation
    Abstraction
    Hierarchical
    Relationships
    Polymorphism
    Concurrency
    Persistency

    View Slide

  4. jgs
    460 00001010
    Abstraction
    § Reducing by focusing on the essential observable behavior
    § What will be outside?
    OOAD, Booch Textbook

    View Slide

  5. jgs
    460 00001010
    Encapsulation
    § Hiding the details of the implementation
    § What is inside?
    OOAD, Booch Textbook

    View Slide

  6. jgs
    460 00001010
    Hierarchical Relationships
    § Creating a hierarchy of abstractions
    § Who (is a…, uses a…, has a…) ?
    OOAD, Booch Textbook

    View Slide

  7. jgs
    460 00001010
    Polymorphism
    § The condition of denoting different forms.
    § A single name may denote objects of many different classes that are related
    by some common superclass.
    § When to use it?

    View Slide

  8. jgs
    460 00001010
    Concurrency
    § Having two o more events happening (objects acting) at the same
    time.
    § When to use it?
    OOAD, Booch Textbook

    View Slide

  9. jgs
    460 00001010
    Persistency
    § Property by which an object continues to exist even after its creator
    ceases to exist
    § Object serialization: convert it to a byte stream so way that the byte
    stream can be reverted into a copy of the object.
    § Save data OOAD, Booch Textbook

    View Slide

  10. jgs
    Object-Oriented Principles
    Programming

    View Slide

  11. jgs
    460 00001010
    Global Ideas
    § Create code Elegant and
    Efficient –Bjarne Stroustrup
    § Create code Simple and Direct
    –Grady Booch
    § Create code looks like written
    by someone who cares –
    Michael Feathers

    View Slide

  12. jgs
    460 00001010
    Clean Code Principles
    § Readability
    Use Meaningful Names for Classes, Methods, and Variables
    Follow coding guidelines: e.g., read the Java Style Reference
    § KISS (Keep It Simple by K. Johnson) for your reader
    Small functions that do one thing
    § DRY (Do not Repeat Yourself):
    Avoid Code Bloat
    § Decoupling

    View Slide

  13. jgs
    460 00001010
    Readability?
    § JFrame frmClient
    § JToggleButton btnNewButton
    § JLabel lblToggle
    § class MainWindow
    Create code Simple and Direct –Grady Booch
    Readability

    View Slide

  14. jgs
    460 00001010
    Naming

    View Slide

  15. jgs
    460 00001010
    DRY?
    Create code Elegant and Efficient

    View Slide

  16. jgs
    460 00001010
    Where are the variables?

    View Slide

  17. jgs
    460 00001010
    Readability
    Naming
    Review Language Guidelines

    View Slide

  18. jgs
    460 00001010
    Readability
    Is the comment needed?
    Public vs Private?

    View Slide

  19. jgs
    460 00001010
    Readability

    View Slide

  20. jgs
    460 00001010
    Readability
    … … …
    500 LOC in a method… it is to much!

    View Slide

  21. jgs
    460 00001010
    How many LOC per method?
    § around 20 is perfect,
    § up to 50 is still fine,
    § up to 100 is critical,
    § above 150 is bad, and
    § more than 250 is !

    View Slide

  22. jgs
    460 00001010
    Reference
    Chapter 2, 3

    View Slide

  23. jgs
    CSE 460 Software Analysis and Design
    Javier Gonzalez-Sanchez
    [email protected]
    Fall 2020
    Disclaimer. These slides can only be used as study material for the class CSE460 at ASU. They cannot be distributed or used for another purpose.

    View Slide