Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

jgs Object-Oriented Principles Design

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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?

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

jgs Object-Oriented Principles Programming

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

jgs 460 00001010 Naming

Slide 15

Slide 15 text

jgs 460 00001010 DRY? Create code Elegant and Efficient

Slide 16

Slide 16 text

jgs 460 00001010 Where are the variables?

Slide 17

Slide 17 text

jgs 460 00001010 Readability Naming Review Language Guidelines

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

jgs 460 00001010 Readability

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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 !

Slide 22

Slide 22 text

jgs 460 00001010 Reference Chapter 2, 3

Slide 23

Slide 23 text

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.