You are on page 1of 20

Java Meets OO

!!! 2003 - 2007 DevelopIntelligence LLC


!!http://www.DevelopIntelligence.com
Presentation Topics
In this presentation, we will discuss:
" ! Java’s perspective on Object Oriented concepts
" ! Java coding conventions

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
Objectives
When we are done, you should be able to:
" ! Describe how abstraction, encapsulation, and
polymorphism are adopted in Java
" ! Identify two coding conventions

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
Java Meets OO

!!! 2003 - 2007 DevelopIntelligence LLC


!!http://www.DevelopIntelligence.com
Java and OO
" ! Java does not adopt OO in purest form
" ! Choices were made to make OO “easier”
" ! “Easier” sometimes means less flexible
" ! Over time, Java’s OO capabilities have
expanded

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
OO Concepts in Java
" ! Abstraction
" ! Abstract classes
" ! Interfaces
" ! Messaging Passing
" ! Methods
" ! Encapsulation
" ! Access modifiers (private, <default>, protected,
public)
" ! Inner classes

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
OO Concepts in Java [cont.]
" ! Inheritence
" ! Single inheritence
" ! Sub-classing abstractions
" ! Polymorphism
" ! Implementing interfaces and sub-classing
" ! Virtual method invocation

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
Objects
" ! Everything is an Object . . .
" ! Of type java.lang.Object!
" ! Inherit all of Object’s methods
" !equals!
" !toString!
" !hashCode!
" !wait, notify
" ! . . . except for primitive types
" ! int, float, char, boolean, etc.
" ! Conversion to objects using wrapper classes

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
Classes
" ! Five types of top-level classes
" ! Concrete classes
" ! Abstract classes
" ! Interfaces
" ! Annotations
" ! Enumerations
" ! Support for nested classes
" ! Inner classes
" ! Anonymous inner classes

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
Java Coding Conventions

!!! 2003 - 2007 DevelopIntelligence LLC


!!http://www.DevelopIntelligence.com
Coding Conventions
" ! Java Language and APIs follow a standard
coding convention
" ! Coding conventions make it “easy” to read and maintain
source code
" ! Java conventions differ from other languages
conventions
" ! Not necessarily the same as a “style guide”
" ! Loosely follows CamelCase notation

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
Java Conventions
" ! Type names are mixed-case
" ! Capitalizing first letter of each word
" ! Can have any number of words
" ! class Employee!
" ! class BankAccount!
" ! Variable names are mixed-case
" ! First word all lower case
" ! Second word adopts first-letter capitalization syntax
" ! Don’t identify type at end of variable name (ie:
empIdSTR)
" ! String empId!
" ! String fullName
! 2003 - 2007 DevelopIntelligence
http://www.DevelopIntelligence.com
Java Conventions [cont.]
" ! Behaviors are mixed-case
" ! First word all lower case
" ! Second word adopts first-letter capitalization syntax!
" ! public string getEmployeeName()!
" ! public void setSalary(float payIncrease)!
" ! Constructors are same case and name as
class names
" ! public Employee(String n, String e, Float
s)!
" ! public BankAccount()!

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
Compilation Example
public class Employee {"
//states"
private String fullName;"
private String empID;"
private float salary;"
Employee.java!
//constructor"
public Employee(String n, String e, float s) {"
fullName = n;"
empID = e;" > javac Employee.java!
salary = s;"
}"

//behavior"
public String getEmployeeName() {"
return fullName;"
}" Employee.class!

//behavior"
public void setSalary(float payIncrease) {"
salary = salary + (salary * payIncrease);"
}"
}!

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
Execution Example

public class Main { "


public static void main(String [] args) {" > javac Main.java!
//work with an employee"
String n = “Kelby”;" Main.class!
String e = “123ab4”;"
float s = 43437.77F;"
Employee emp = new Employee(n,e,s);" > java Main!
JVM calls
emp.setSalary(0.12F);"
//do some other work"
Main.main(args)
}"
}!

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
Summary
" ! Java adopts almost all OO concepts
" ! Java constrains some OO concepts, like
inheritence
" ! Coding conventions help with the readability of
source code

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
Resources
" ! Web
" ! OO Concepts
http://java.sun.com/docs/books/tutorial/java/concepts/
" ! Coding conventions
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
" ! CamelCase
http://en.wikipedia.org/wiki/CamelCase

! 2003 - 2007 DevelopIntelligence


http://www.DevelopIntelligence.com
About DevelopIntelligence
! " Founded in 2003
! " Provides outsourced services to learning
organizations in area of software development
! " Represents over 35 years of combined
experience, enabling software development
community through educational and
performance services
! " Represents over 50 years of combined software
development experience
! " Delivered training to over 40,000 developers
worldwide
! 2003 - 2007 DevelopIntelligence
Areas of Expertise
! " Instruction ! " Courseware
! " Java ! " Java Application
! " J2EE Development
! " WebServices / SOA ! " Java Web App
! " Web Application Development
Development ! " Enterprise Java
! " Database Development Development
! " OOAD / UML
! " Open Source
Frameworks ! " IT Managerial
! " Application Servers ! " Emerging Technologies
and Frameworks

! 2003 - 2007 DevelopIntelligence


Contact Us
! " For more information about our services, please
contact us:
! " Kelby Zorgdrager
! " Kelby@DevelopIntelligence.com
! " 303-395-5340

! 2003 - 2007 DevelopIntelligence

You might also like