SlideShare ist ein Scribd-Unternehmen logo
1 von 56
Downloaden Sie, um offline zu lesen
1
Introduction to OOP
& Design Principles
Trenton Computer Festival
March 15, 2014
Michael P. Redlich
@mpredli
about.me/mpredli/
Sunday, March 16, 14
Who’s Mike?
• BS in CS from
• “Petrochemical Research Organization”
• Ai-Logix, Inc. (now AudioCodes)
• Amateur Computer Group of New Jersey
• Publications
• Presentations
2
Sunday, March 16, 14
Objectives (2)
• Object-Oriented Programming
• Object-Oriented Design Principles
• Live Demos (yea!)
3
Sunday, March 16, 14
Object-Oriented
Programming (OOP)
4
Sunday, March 16, 14
Some OOP Languages
• Ada
• C++
• Eiffel
• Java
• Modula-3
• Objective C
• OO-Cobol
• Python
• Simula
• Smalltalk
• Theta
5
Sunday, March 16, 14
What is OOP?
• A programming paradigm that is focused on
objects and data
• as opposed to actions and logic
• Objects are identified to model a system
• Objects are designed to interact with each
other
6
Sunday, March 16, 14
OOP Basics (1)
• Procedure-Oriented
• Top Down/Bottom Up
• Structured programming
• Centered around an
algorithm
• Identify tasks; how
something is done
• Object-Oriented
• Identify objects to be
modeled
• Concentrate on what an
object does
• Hide how an object
performs its task
• Identify behavior
7
Sunday, March 16, 14
OOP Basics (2)
• Abstract Data Type (ADT)
• user-defined data type
• use of objects through functions (methods)
without knowing the internal representation
8
Sunday, March 16, 14
OOP Basics (3)
• Interface
• functions (methods) provided in the ADT that
allow access to data
• Implementation
• underlying data structure(s) and business logic
within the ADT
9
Sunday, March 16, 14
OOP Basics (4)
• Class
• Defines a model
• Declares attributes
• Declares behavior
• Is an ADT
• Object
• Is an instance of a class
• Has state
• Has behavior
• May have many unique
objects of the same class
10
Sunday, March 16, 14
OOP Attributes
• Four (4) Main Attributes:
• data encapsulation
• data abstraction
• inheritance
• polymorphism
11
Sunday, March 16, 14
Data Encapsulation
• Separates the implementation from the
interface
• A public view of an object, but
implementation is private
• access to data is only allowed through a defined
interface
12
Sunday, March 16, 14
Data Abstraction
• A model of an entity
• Defines a data type by its functionality as
opposed to its implementation
13
Sunday, March 16, 14
Inheritance
• A means for defining a new class as an
extension of a previously defined class
• The derived class inherits all attributes and
behavior of the base class
• “IS-A” relationship
• Baseball is a Sport
14
Sunday, March 16, 14
Polymorphism
• The ability of different objects to respond
differently to the same function
• From the Greek meaning “many forms”
• A mechanism provided by an OOP
language as opposed to a programmer-
provided workaround
15
Sunday, March 16, 14
Advantages of OOP
• Interface can (and should) remain
unchanged when improving implementation
• Encourages modularity in application
development
• Better maintainability of code
• Code reuse
• Emphasis on what, not how
16
Sunday, March 16, 14
Classes (1)
• A user-defined abstract data type
• Extension of C structs
• Contain:
• constructor
• destructor
• data members and member functions (methods)
17
Sunday, March 16, 14
Classes (2)
• Static/Dynamic object instantiation
• Multiple Constructors:
• Sports(void);
• Sports(char *,int,int);
• Sports(float,char *,int);
18
Sunday, March 16, 14
Classes (3)
• Class scope (C++)
• scope resolution operator (::)
• Abstract Classes
• contain at least one pure virtual member
function (C++)
• contain at least one abstract method (Java)
19
Sunday, March 16, 14
Classes (3)
• Abstract Classes
• contain at least one pure virtual member
function (C++)
• contain at least one abstract method (Java)
20
Sunday, March 16, 14
Abstract Classes
• Pure virtual member function (C++)
• virtual void draw() = 0;
• Abstract method (Java)
• public abstract void draw();
21
Sunday, March 16, 14
Class Inheritance
22
Sunday, March 16, 14
Static Instantiation
(C++)
• Object creation:
• Baseball mets(“Mets”,97,65);
• Access to public member functions:
• mets.getWin(); // returns 97
23
Sunday, March 16, 14
Dynamic Instantiation
(C++)
• Object creation:
• Baseball *mets = new
Baseball(“Mets”,97,65);
• Access to public member functions:
• mets->getWin(); // returns 97
24
Sunday, March 16, 14
Dynamic Instantiation
(Java)
• Object creation:
• Baseball mets = new
Baseball(“Mets”,97,65);
• Access to public member functions:
• mets.getWin(); // returns 97
25
Sunday, March 16, 14
Deleting Objects (C++)
Baseball mets(“Mets”,97,65);
// object deleted when out of scope
Baseball *mets = new
Baseball(“Mets”,97,65);
delete mets; // required call
26
Sunday, March 16, 14
Deleting Objects (Java)
Baseball mets = new
Baseball(“Mets”,97,65);
// automatic garbage collection or:
System.gc(); // explicit call
27
Sunday, March 16, 14
Object-Oriented
Design Principles
28
Sunday, March 16, 14
What are OO Design
Principles?
• A set of underlying principles for creating
flexible designs that are easy to maintain
and adaptable to change
• Understanding the basics of OOP isn’t
enough
29
Sunday, March 16, 14
Some OO Design
Principles (1)
• Encapsulate WhatVaries
• Program to Interfaces, Not
Implementations
• Favor Composition Over Inheritance
• Classes Should Be Open for Extension, But
Closed for Modification
30
Sunday, March 16, 14
Some OO Design
Principles (2)
• Strive for Loosely Coupled Designs
Between Objects That Interact
• A Class Should Have Only One Reason to
Change
31
Sunday, March 16, 14
Encapsulate What
Varies
• Identify and encapsulate areas of code that
vary
• Encapsulated code can be altered without
affecting code that doesn’t vary
• Forms the basis for almost all of the
original Design Patterns
32
Sunday, March 16, 14
33
// OrderCars class
public class OrderCars {
public Car orderCar(String model) {
Car car;
if(model.equals(“Charger”))
car = new Dodge(model);
else if(model.equals(“Corvette”))
car = new Chevrolet(model);
else if(model.equals(“Mustang”))
car = new Ford(model);
car.buildCar();
car.testCar();
car.shipCar();
}
}
Sunday, March 16, 14
Program to Interfaces,
Not Implementations
• Eliminates being locked-in to a specific
implementation
• An interface declares generic behavior
• Concrete class(es) implement methods
defined in an interface
34
Sunday, March 16, 14
35
// Dog class
public class Dog {
public void bark() {
System.out.println(“woof”);
}
// Cat class
public class Cat {
public void meow() {
System.out.println(“meow”);
}
}
Sunday, March 16, 14
36
// Animals class - main application
public class Animals {
public static void main(String[] args) {
Dog dog = new Dog();
dog.bark();
Cat cat = new Cat();
cat.meow();
}
}
// output
woof
meow
Sunday, March 16, 14
37
// Animal interface
public interface Animal {
public void makeNoise();
}
Sunday, March 16, 14
38
// Dog class (revised)
public class Dog implements Animal {
public void makeNoise() {
bark();
}
public void bark() {
System.out.println(“woof”);
}
// Cat class (revised)
public class Cat implements Animal {
public void makeNoise() {
meow();
}
public void meow() {
System.out.println(“meow”);
}
}
Sunday, March 16, 14
39
// Animals class - main application (revised)
public class Animals {
public static void main(String[] args) {
Animal dog = new Dog();
dog.makeNoise();
Animal cat = new Cat();
cat.makeNoise();
}
}
// output
woof
meow
Sunday, March 16, 14
Favor Composition
Over Inheritance
• “HAS-A” can be better than “IS-A”
• Eliminates excessive use of subclassing
• An object’s behavior can be modified
through composition as opposed through
inheritance
• Allows change in object behavior at run-
time
40
Sunday, March 16, 14
Classes Should Be
Open for Extension...
• ...But Closed for Modification
• “Come in,We’re Open”
• extend the class to add new behavior
• “Sorry,We’re Closed”
• the code must remain closed to modification
41
Sunday, March 16, 14
A Simple Hierarchy...
42
Sunday, March 16, 14
...That Quickly
Becomes Complex!
43
Sunday, March 16, 14
Refactored Design
44
Sunday, March 16, 14
Live Demo!
45
Sunday, March 16, 14
Strive for Loosely
Coupled Designs...
• ...Between Objects That Interact
• Allows you to build flexible OO systems
that can handle change
• interdependency is minimized
• Changes to one object won’t affect another
object
• Objects can be used independently
46
Sunday, March 16, 14
Live Demo!
47
Sunday, March 16, 14
A Class Should Have...
• ...Only One Reason to Change
• Classes can inadvertently assume too many
responsibilities
• interdependency is minimized
• cross-cutting concerns
• Assign a responsibility to one class, and
only one class
48
Sunday, March 16, 14
Local C++ User
Groups
• ACGNJ C++ Users Group
• facilitated by Bruce Arnold
• acgnj.barnold.us
49
Sunday, March 16, 14
Local Java User Groups
(1)
• ACGNJ Java Users Group
• facilitated by Mike Redlich
• javasig.org
• Princeton Java Users Group
• facilitated byYakov Fain
• meetup.com/NJFlex
50
Sunday, March 16, 14
Local Java User Groups
(2)
• NewYork Java SIG
• facilitated by Frank Greco
• javasig.com
• Capital District Java Developers Network
• facilitated by Dan Patsey
• cdjdn.com
51
Sunday, March 16, 14
Further Reading
52
Sunday, March 16, 14
53
Resources
•java.sun.com
•headfirstlabs.com
•themeteorbook.com
•eventedmind.com
•atmosphere.meteor.com
Sunday, March 16, 14
Upcoming Events (1)
• Trenton Computer Festival
• March 14-15, 2014
• tcf-nj.org
• Emerging Technologies for the Enterprise
• April 22-23, 2014
• phillyemergingtech.com
54
Sunday, March 16, 14
55
Upcoming Events (2)
Sunday, March 16, 14
56
Thanks!
mike@redlich.net
@mpredli
javasig.org
Sunday, March 16, 14

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Collections in-csharp
Collections in-csharpCollections in-csharp
Collections in-csharp
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
ORM: Object-relational mapping
ORM: Object-relational mappingORM: Object-relational mapping
ORM: Object-relational mapping
 
Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners Object Oriented Programming Concepts for beginners
Object Oriented Programming Concepts for beginners
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 
TypeScript - An Introduction
TypeScript - An IntroductionTypeScript - An Introduction
TypeScript - An Introduction
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
C# Exceptions Handling
C# Exceptions Handling C# Exceptions Handling
C# Exceptions Handling
 
interface in c#
interface in c#interface in c#
interface in c#
 
Object oriented programming With C#
Object oriented programming With C#Object oriented programming With C#
Object oriented programming With C#
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Abstract class
Abstract classAbstract class
Abstract class
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
 

Andere mochten auch

Chapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentChapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentEduardo Bergavera
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops conceptsNilesh Dalvi
 
Cmp2412 programming principles
Cmp2412 programming principlesCmp2412 programming principles
Cmp2412 programming principlesNIKANOR THOMAS
 
itft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in javaitft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in javaAtul Sehdev
 
Lecture 17 design concepts (2)
Lecture 17   design concepts (2)Lecture 17   design concepts (2)
Lecture 17 design concepts (2)IIUI
 
Introduction to AOP, AspectJ, and Explicit Join Points
Introduction to AOP, AspectJ, and Explicit Join PointsIntroduction to AOP, AspectJ, and Explicit Join Points
Introduction to AOP, AspectJ, and Explicit Join PointsKevin Hoffman
 
Powerpoint Presentation
Powerpoint PresentationPowerpoint Presentation
Powerpoint PresentationSumesh SV
 
Lm catering services
Lm catering servicesLm catering services
Lm catering servicesPaulaMaeRamos
 
Getting Started with MongoDB
Getting Started with MongoDBGetting Started with MongoDB
Getting Started with MongoDBMichael Redlich
 
University Assignment Literacy Assessment
University Assignment Literacy AssessmentUniversity Assignment Literacy Assessment
University Assignment Literacy Assessmentmforrester
 
Power point Presentation
Power point PresentationPower point Presentation
Power point PresentationSumesh SV
 
POWER POINT PRESENTATION
POWER POINT PRESENTATIONPOWER POINT PRESENTATION
POWER POINT PRESENTATIONSumesh SV
 
Paginas libres
Paginas libresPaginas libres
Paginas libresINGRID
 
Data Structures by Yaman Singhania
Data Structures by Yaman SinghaniaData Structures by Yaman Singhania
Data Structures by Yaman SinghaniaYaman Singhania
 

Andere mochten auch (20)

Chapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software DevelopmentChapter1 - Introduction to Object-Oriented Programming and Software Development
Chapter1 - Introduction to Object-Oriented Programming and Software Development
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 
Cmp2412 programming principles
Cmp2412 programming principlesCmp2412 programming principles
Cmp2412 programming principles
 
Design final
Design finalDesign final
Design final
 
itft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in javaitft-Fundamentals of object–oriented programming in java
itft-Fundamentals of object–oriented programming in java
 
Lecture 17 design concepts (2)
Lecture 17   design concepts (2)Lecture 17   design concepts (2)
Lecture 17 design concepts (2)
 
Introduction to AOP, AspectJ, and Explicit Join Points
Introduction to AOP, AspectJ, and Explicit Join PointsIntroduction to AOP, AspectJ, and Explicit Join Points
Introduction to AOP, AspectJ, and Explicit Join Points
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Menupra1
Menupra1Menupra1
Menupra1
 
huruf prasekolah
huruf prasekolahhuruf prasekolah
huruf prasekolah
 
WhoIsFrancisFairley
WhoIsFrancisFairleyWhoIsFrancisFairley
WhoIsFrancisFairley
 
Powerpoint Presentation
Powerpoint PresentationPowerpoint Presentation
Powerpoint Presentation
 
Lm catering services
Lm catering servicesLm catering services
Lm catering services
 
Getting Started with MongoDB
Getting Started with MongoDBGetting Started with MongoDB
Getting Started with MongoDB
 
University Assignment Literacy Assessment
University Assignment Literacy AssessmentUniversity Assignment Literacy Assessment
University Assignment Literacy Assessment
 
Power point Presentation
Power point PresentationPower point Presentation
Power point Presentation
 
POWER POINT PRESENTATION
POWER POINT PRESENTATIONPOWER POINT PRESENTATION
POWER POINT PRESENTATION
 
Paginas libres
Paginas libresPaginas libres
Paginas libres
 
Data Structures by Yaman Singhania
Data Structures by Yaman SinghaniaData Structures by Yaman Singhania
Data Structures by Yaman Singhania
 
Mata
MataMata
Mata
 

Ähnlich wie Introduction to Object-Oriented Programming & Design Principles (TCF 2014)

Getting Started with Java (TCF 2014)
Getting Started with Java (TCF 2014)Getting Started with Java (TCF 2014)
Getting Started with Java (TCF 2014)Michael Redlich
 
Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)Michael Redlich
 
Introduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesMichael Redlich
 
Introduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesMichael Redlich
 
Java Advanced Features (TCF 2014)
Java Advanced Features (TCF 2014)Java Advanced Features (TCF 2014)
Java Advanced Features (TCF 2014)Michael Redlich
 
C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)Michael Redlich
 
OOP History and Core Concepts
OOP History and Core ConceptsOOP History and Core Concepts
OOP History and Core ConceptsNghia Bui Van
 
Getting Started with Meteor (TCF ITPC 2014)
Getting Started with Meteor (TCF ITPC 2014)Getting Started with Meteor (TCF ITPC 2014)
Getting Started with Meteor (TCF ITPC 2014)Michael Redlich
 
Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)Michael Redlich
 
Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript TestingRan Mizrahi
 
Getting Started with Java
Getting Started with JavaGetting Started with Java
Getting Started with JavaMichael Redlich
 
The View object orientated programming in Lotuscript
The View object orientated programming in LotuscriptThe View object orientated programming in Lotuscript
The View object orientated programming in LotuscriptBill Buchan
 
Linked Data at the OU - the story so far
Linked Data at the OU - the story so farLinked Data at the OU - the story so far
Linked Data at the OU - the story so farEnrico Daga
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programmingRiturajJain8
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSkillwise Group
 
CIS110 Computer Programming Design Chapter (10)
CIS110 Computer Programming Design Chapter  (10)CIS110 Computer Programming Design Chapter  (10)
CIS110 Computer Programming Design Chapter (10)Dr. Ahmed Al Zaidy
 

Ähnlich wie Introduction to Object-Oriented Programming & Design Principles (TCF 2014) (20)

Getting Started with Java (TCF 2014)
Getting Started with Java (TCF 2014)Getting Started with Java (TCF 2014)
Getting Started with Java (TCF 2014)
 
Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)
 
Introduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design Principles
 
Introduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design PrinciplesIntroduction to Object Oriented Programming & Design Principles
Introduction to Object Oriented Programming & Design Principles
 
Java Advanced Features (TCF 2014)
Java Advanced Features (TCF 2014)Java Advanced Features (TCF 2014)
Java Advanced Features (TCF 2014)
 
C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)
 
OOP History and Core Concepts
OOP History and Core ConceptsOOP History and Core Concepts
OOP History and Core Concepts
 
Getting Started with Meteor (TCF ITPC 2014)
Getting Started with Meteor (TCF ITPC 2014)Getting Started with Meteor (TCF ITPC 2014)
Getting Started with Meteor (TCF ITPC 2014)
 
Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)Getting Started with MongoDB (TCF ITPC 2014)
Getting Started with MongoDB (TCF ITPC 2014)
 
How To Write a Testable Code
How To Write a Testable CodeHow To Write a Testable Code
How To Write a Testable Code
 
Oops in java
Oops in javaOops in java
Oops in java
 
Intro to JavaScript Testing
Intro to JavaScript TestingIntro to JavaScript Testing
Intro to JavaScript Testing
 
Getting Started with Java
Getting Started with JavaGetting Started with Java
Getting Started with Java
 
The View object orientated programming in Lotuscript
The View object orientated programming in LotuscriptThe View object orientated programming in Lotuscript
The View object orientated programming in Lotuscript
 
Linked Data at the OU - the story so far
Linked Data at the OU - the story so farLinked Data at the OU - the story so far
Linked Data at the OU - the story so far
 
Sencha Touch in Action
Sencha Touch in Action Sencha Touch in Action
Sencha Touch in Action
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 
CIS110 Computer Programming Design Chapter (10)
CIS110 Computer Programming Design Chapter  (10)CIS110 Computer Programming Design Chapter  (10)
CIS110 Computer Programming Design Chapter (10)
 
ActiveRecord 2.3
ActiveRecord 2.3ActiveRecord 2.3
ActiveRecord 2.3
 

Mehr von Michael Redlich

Getting Started with GitHub
Getting Started with GitHubGetting Started with GitHub
Getting Started with GitHubMichael Redlich
 
Building Microservices with Micronaut: A Full-Stack JVM-Based Framework
Building Microservices with Micronaut:  A Full-Stack JVM-Based FrameworkBuilding Microservices with Micronaut:  A Full-Stack JVM-Based Framework
Building Microservices with Micronaut: A Full-Stack JVM-Based FrameworkMichael Redlich
 
Building Microservices with Helidon: Oracle's New Java Microservices Framework
Building Microservices with Helidon:  Oracle's New Java Microservices FrameworkBuilding Microservices with Helidon:  Oracle's New Java Microservices Framework
Building Microservices with Helidon: Oracle's New Java Microservices FrameworkMichael Redlich
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++Michael Redlich
 
Getting started with C++
Getting started with C++Getting started with C++
Getting started with C++Michael Redlich
 
Building Realtime Access to Data Apps with jOOQ
Building Realtime Access to Data Apps with jOOQBuilding Realtime Access to Data Apps with jOOQ
Building Realtime Access to Data Apps with jOOQMichael Redlich
 
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)Michael Redlich
 
Building Realtime Web Apps with Angular and Meteor
Building Realtime Web Apps with Angular and MeteorBuilding Realtime Web Apps with Angular and Meteor
Building Realtime Web Apps with Angular and MeteorMichael Redlich
 
Getting Started with Meteor
Getting Started with MeteorGetting Started with Meteor
Getting Started with MeteorMichael Redlich
 

Mehr von Michael Redlich (12)

Getting Started with GitHub
Getting Started with GitHubGetting Started with GitHub
Getting Started with GitHub
 
Building Microservices with Micronaut: A Full-Stack JVM-Based Framework
Building Microservices with Micronaut:  A Full-Stack JVM-Based FrameworkBuilding Microservices with Micronaut:  A Full-Stack JVM-Based Framework
Building Microservices with Micronaut: A Full-Stack JVM-Based Framework
 
Building Microservices with Helidon: Oracle's New Java Microservices Framework
Building Microservices with Helidon:  Oracle's New Java Microservices FrameworkBuilding Microservices with Helidon:  Oracle's New Java Microservices Framework
Building Microservices with Helidon: Oracle's New Java Microservices Framework
 
Getting Started with C++
Getting Started with C++Getting Started with C++
Getting Started with C++
 
C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
 
Java Advanced Features
Java Advanced FeaturesJava Advanced Features
Java Advanced Features
 
Getting started with C++
Getting started with C++Getting started with C++
Getting started with C++
 
C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
 
Building Realtime Access to Data Apps with jOOQ
Building Realtime Access to Data Apps with jOOQBuilding Realtime Access to Data Apps with jOOQ
Building Realtime Access to Data Apps with jOOQ
 
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
Building Realtime Access Data Apps with Speedment (TCF ITPC 2017)
 
Building Realtime Web Apps with Angular and Meteor
Building Realtime Web Apps with Angular and MeteorBuilding Realtime Web Apps with Angular and Meteor
Building Realtime Web Apps with Angular and Meteor
 
Getting Started with Meteor
Getting Started with MeteorGetting Started with Meteor
Getting Started with Meteor
 

Kürzlich hochgeladen

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 

Kürzlich hochgeladen (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 

Introduction to Object-Oriented Programming & Design Principles (TCF 2014)

  • 1. 1 Introduction to OOP & Design Principles Trenton Computer Festival March 15, 2014 Michael P. Redlich @mpredli about.me/mpredli/ Sunday, March 16, 14
  • 2. Who’s Mike? • BS in CS from • “Petrochemical Research Organization” • Ai-Logix, Inc. (now AudioCodes) • Amateur Computer Group of New Jersey • Publications • Presentations 2 Sunday, March 16, 14
  • 3. Objectives (2) • Object-Oriented Programming • Object-Oriented Design Principles • Live Demos (yea!) 3 Sunday, March 16, 14
  • 5. Some OOP Languages • Ada • C++ • Eiffel • Java • Modula-3 • Objective C • OO-Cobol • Python • Simula • Smalltalk • Theta 5 Sunday, March 16, 14
  • 6. What is OOP? • A programming paradigm that is focused on objects and data • as opposed to actions and logic • Objects are identified to model a system • Objects are designed to interact with each other 6 Sunday, March 16, 14
  • 7. OOP Basics (1) • Procedure-Oriented • Top Down/Bottom Up • Structured programming • Centered around an algorithm • Identify tasks; how something is done • Object-Oriented • Identify objects to be modeled • Concentrate on what an object does • Hide how an object performs its task • Identify behavior 7 Sunday, March 16, 14
  • 8. OOP Basics (2) • Abstract Data Type (ADT) • user-defined data type • use of objects through functions (methods) without knowing the internal representation 8 Sunday, March 16, 14
  • 9. OOP Basics (3) • Interface • functions (methods) provided in the ADT that allow access to data • Implementation • underlying data structure(s) and business logic within the ADT 9 Sunday, March 16, 14
  • 10. OOP Basics (4) • Class • Defines a model • Declares attributes • Declares behavior • Is an ADT • Object • Is an instance of a class • Has state • Has behavior • May have many unique objects of the same class 10 Sunday, March 16, 14
  • 11. OOP Attributes • Four (4) Main Attributes: • data encapsulation • data abstraction • inheritance • polymorphism 11 Sunday, March 16, 14
  • 12. Data Encapsulation • Separates the implementation from the interface • A public view of an object, but implementation is private • access to data is only allowed through a defined interface 12 Sunday, March 16, 14
  • 13. Data Abstraction • A model of an entity • Defines a data type by its functionality as opposed to its implementation 13 Sunday, March 16, 14
  • 14. Inheritance • A means for defining a new class as an extension of a previously defined class • The derived class inherits all attributes and behavior of the base class • “IS-A” relationship • Baseball is a Sport 14 Sunday, March 16, 14
  • 15. Polymorphism • The ability of different objects to respond differently to the same function • From the Greek meaning “many forms” • A mechanism provided by an OOP language as opposed to a programmer- provided workaround 15 Sunday, March 16, 14
  • 16. Advantages of OOP • Interface can (and should) remain unchanged when improving implementation • Encourages modularity in application development • Better maintainability of code • Code reuse • Emphasis on what, not how 16 Sunday, March 16, 14
  • 17. Classes (1) • A user-defined abstract data type • Extension of C structs • Contain: • constructor • destructor • data members and member functions (methods) 17 Sunday, March 16, 14
  • 18. Classes (2) • Static/Dynamic object instantiation • Multiple Constructors: • Sports(void); • Sports(char *,int,int); • Sports(float,char *,int); 18 Sunday, March 16, 14
  • 19. Classes (3) • Class scope (C++) • scope resolution operator (::) • Abstract Classes • contain at least one pure virtual member function (C++) • contain at least one abstract method (Java) 19 Sunday, March 16, 14
  • 20. Classes (3) • Abstract Classes • contain at least one pure virtual member function (C++) • contain at least one abstract method (Java) 20 Sunday, March 16, 14
  • 21. Abstract Classes • Pure virtual member function (C++) • virtual void draw() = 0; • Abstract method (Java) • public abstract void draw(); 21 Sunday, March 16, 14
  • 23. Static Instantiation (C++) • Object creation: • Baseball mets(“Mets”,97,65); • Access to public member functions: • mets.getWin(); // returns 97 23 Sunday, March 16, 14
  • 24. Dynamic Instantiation (C++) • Object creation: • Baseball *mets = new Baseball(“Mets”,97,65); • Access to public member functions: • mets->getWin(); // returns 97 24 Sunday, March 16, 14
  • 25. Dynamic Instantiation (Java) • Object creation: • Baseball mets = new Baseball(“Mets”,97,65); • Access to public member functions: • mets.getWin(); // returns 97 25 Sunday, March 16, 14
  • 26. Deleting Objects (C++) Baseball mets(“Mets”,97,65); // object deleted when out of scope Baseball *mets = new Baseball(“Mets”,97,65); delete mets; // required call 26 Sunday, March 16, 14
  • 27. Deleting Objects (Java) Baseball mets = new Baseball(“Mets”,97,65); // automatic garbage collection or: System.gc(); // explicit call 27 Sunday, March 16, 14
  • 29. What are OO Design Principles? • A set of underlying principles for creating flexible designs that are easy to maintain and adaptable to change • Understanding the basics of OOP isn’t enough 29 Sunday, March 16, 14
  • 30. Some OO Design Principles (1) • Encapsulate WhatVaries • Program to Interfaces, Not Implementations • Favor Composition Over Inheritance • Classes Should Be Open for Extension, But Closed for Modification 30 Sunday, March 16, 14
  • 31. Some OO Design Principles (2) • Strive for Loosely Coupled Designs Between Objects That Interact • A Class Should Have Only One Reason to Change 31 Sunday, March 16, 14
  • 32. Encapsulate What Varies • Identify and encapsulate areas of code that vary • Encapsulated code can be altered without affecting code that doesn’t vary • Forms the basis for almost all of the original Design Patterns 32 Sunday, March 16, 14
  • 33. 33 // OrderCars class public class OrderCars { public Car orderCar(String model) { Car car; if(model.equals(“Charger”)) car = new Dodge(model); else if(model.equals(“Corvette”)) car = new Chevrolet(model); else if(model.equals(“Mustang”)) car = new Ford(model); car.buildCar(); car.testCar(); car.shipCar(); } } Sunday, March 16, 14
  • 34. Program to Interfaces, Not Implementations • Eliminates being locked-in to a specific implementation • An interface declares generic behavior • Concrete class(es) implement methods defined in an interface 34 Sunday, March 16, 14
  • 35. 35 // Dog class public class Dog { public void bark() { System.out.println(“woof”); } // Cat class public class Cat { public void meow() { System.out.println(“meow”); } } Sunday, March 16, 14
  • 36. 36 // Animals class - main application public class Animals { public static void main(String[] args) { Dog dog = new Dog(); dog.bark(); Cat cat = new Cat(); cat.meow(); } } // output woof meow Sunday, March 16, 14
  • 37. 37 // Animal interface public interface Animal { public void makeNoise(); } Sunday, March 16, 14
  • 38. 38 // Dog class (revised) public class Dog implements Animal { public void makeNoise() { bark(); } public void bark() { System.out.println(“woof”); } // Cat class (revised) public class Cat implements Animal { public void makeNoise() { meow(); } public void meow() { System.out.println(“meow”); } } Sunday, March 16, 14
  • 39. 39 // Animals class - main application (revised) public class Animals { public static void main(String[] args) { Animal dog = new Dog(); dog.makeNoise(); Animal cat = new Cat(); cat.makeNoise(); } } // output woof meow Sunday, March 16, 14
  • 40. Favor Composition Over Inheritance • “HAS-A” can be better than “IS-A” • Eliminates excessive use of subclassing • An object’s behavior can be modified through composition as opposed through inheritance • Allows change in object behavior at run- time 40 Sunday, March 16, 14
  • 41. Classes Should Be Open for Extension... • ...But Closed for Modification • “Come in,We’re Open” • extend the class to add new behavior • “Sorry,We’re Closed” • the code must remain closed to modification 41 Sunday, March 16, 14
  • 46. Strive for Loosely Coupled Designs... • ...Between Objects That Interact • Allows you to build flexible OO systems that can handle change • interdependency is minimized • Changes to one object won’t affect another object • Objects can be used independently 46 Sunday, March 16, 14
  • 48. A Class Should Have... • ...Only One Reason to Change • Classes can inadvertently assume too many responsibilities • interdependency is minimized • cross-cutting concerns • Assign a responsibility to one class, and only one class 48 Sunday, March 16, 14
  • 49. Local C++ User Groups • ACGNJ C++ Users Group • facilitated by Bruce Arnold • acgnj.barnold.us 49 Sunday, March 16, 14
  • 50. Local Java User Groups (1) • ACGNJ Java Users Group • facilitated by Mike Redlich • javasig.org • Princeton Java Users Group • facilitated byYakov Fain • meetup.com/NJFlex 50 Sunday, March 16, 14
  • 51. Local Java User Groups (2) • NewYork Java SIG • facilitated by Frank Greco • javasig.com • Capital District Java Developers Network • facilitated by Dan Patsey • cdjdn.com 51 Sunday, March 16, 14
  • 54. Upcoming Events (1) • Trenton Computer Festival • March 14-15, 2014 • tcf-nj.org • Emerging Technologies for the Enterprise • April 22-23, 2014 • phillyemergingtech.com 54 Sunday, March 16, 14