moving to ood

43
Moving to OO Development Sean McSharry

Upload: april-six

Post on 12-Aug-2015

52 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: Moving to OOD

Moving to OO DevelopmentSean McSharry

Page 2: Moving to OOD

Who is this jerk?

Author on Actionscript 3.0 for Flash and Flex

Prerelease tester on many Adobe products

Organize and run PokerCoder

Run Flashcoder blog

Senior Partner at Logic Bureau

Page 3: Moving to OOD

Why, What and How

Page 4: Moving to OOD

Why?

Page 5: Moving to OOD

Why OO?

OO vs. Procedural

Page 6: Moving to OOD

Why OO?

OO vs. Procedural

The best things take time

Page 7: Moving to OOD

Why OO?

OO vs. Procedural

The best things take time

Be Pragmatic

Page 8: Moving to OOD

What?

Page 9: Moving to OOD

A programming paradigm

It does what it says on the tin

Objects are represented as classes

Not difficult

What is OO?

Page 10: Moving to OOD

Modularity

OO Core Concepts

Page 11: Moving to OOD

Modularity

Inheritance

OO Core Concepts

Page 12: Moving to OOD

Modularity

Inheritance

OO Core Concepts

Page 13: Moving to OOD

Modularity

Inheritance

Encapsulation

OO Core Concepts

Page 14: Moving to OOD

Modularity

Inheritance

Encapsulation

OO Core Concepts

classA.count=1;

classA.setCount(1);

Page 15: Moving to OOD

Modularity

Inheritance

Encapsulation

Abstraction

OO Core Concepts

Page 16: Moving to OOD

Modularity

Inheritance

Encapsulation

Abstraction

Polymorphism & Interfaces

OO Core Concepts

Page 17: Moving to OOD

Patterns

State

Command

Decorator

Memento

MVC

Singleton

Factory

Proxy

Page 18: Moving to OOD

UMLUnified Modeling Language

What is UML?

UML is used to specify, visualize, modify, construct and document the artifacts of an object oriented software intensive system

Page 19: Moving to OOD

UMLUnified Modeling Language

Why is UML useful?

Page 20: Moving to OOD

UML

Use Case

Activity

Class

Sequence

Collaboration

State

Component

More...

Unified Modeling Language - Diagrams

Page 21: Moving to OOD

UMLUnified Modeling Language - Diagrams

Page 22: Moving to OOD

UMLUnified Modeling Language

DiagramsUse Case

Page 23: Moving to OOD

UMLUnified Modeling Language - DiagramsClass

Page 24: Moving to OOD

UMLUnified Modeling Language - DiagramsClass

Page 25: Moving to OOD

UML

UML modeling tools

gModeler

More info:

http://www.uml.org

Unified Modeling Language - Diagrams

Page 26: Moving to OOD

How?

Page 27: Moving to OOD

Anatomy of a Class

Package definition

Class definition

Class Constructor

Class Instantiation

Variable definition

Access modifiers (Public, Private, Protected & Internal)

Page 28: Moving to OOD

Anatomy of a Class Package definition

package com.earth.animals{

}

Page 29: Moving to OOD

Anatomy of a Class Class definition

package com.earth.animals{public class Mammal extends Animal{}}

Page 30: Moving to OOD

Anatomy of a Class Class Constructor

package com.earth.animals{public class Mammal extends Animal{

public function Mammal(){}

}}

Page 31: Moving to OOD

Anatomy of a Class Class Imports and Variable definitions

package com.earth.animals{import com.earth.animals.Dog

public class Mammal extends Animal{private var myDog:Dog;

public function Mammal(){

}}}

Page 32: Moving to OOD

Anatomy of a Class Class Instantiation

package com.earth.animals{import com.earth.animals.Dog

public class Mammal extends Animal{private var myDog:Dog;

public function Mammal(){myDog = New Dog();

}}}

Page 33: Moving to OOD

Anatomy of a Class Access Modifiers (Public, Private, Protected & Internal)

Page 34: Moving to OOD

Anatomy of a Class Access Modifiers (Public, Private, Protected & Internal)

Public: The public modifier provides access for external classes i.e. those who are not a part of same package or same class, to modify or invoke public members.

Page 35: Moving to OOD

Anatomy of a Class Access Modifiers (Public, Private, Protected & Internal)

Private: The private modifier is very much private for the owner class where the private members can only be called/modified by the owner class itself. The privatemembers are not exposed to external, instances or extended classes.

Page 36: Moving to OOD

Anatomy of a Class Access Modifiers (Public, Private, Protected & Internal)

Protected: You can call the Protected method/members in a subclass i.e. the class which is inheriting from the class having protected members.

Page 37: Moving to OOD

Anatomy of a Class Access Modifiers (Public, Private, Protected & Internal)

Internal: The internal methods or properties are built to be shared across a common package.

Page 38: Moving to OOD

Anatomy of an Interface

Packages

Classes

Instantiation

Page 39: Moving to OOD

What methods areavailable

What parameters thosemethods accept

What, if any, types arereturned by those methods

Polymorphism & Interfaces

An Interface indicates and dictates :

Page 40: Moving to OOD

Polymorphism & Interfacespackage package {public interface IAnimal {

function procreate(parameter:Type)ReturnType;function set noOfLegs(value:Type):void;function get noOfLegs():ReturnType;}}

Page 41: Moving to OOD

Polymorphism & Interfacespublic class Mammal implements IAnimal

public class Reptile implements IAnimal

Page 42: Moving to OOD

FinallyBe pragmatic

Read up on UML, Patterns and OO

Don’t pretend to see the Emperor’s new clothes

Don’t strictly enforce Patterns - they are guidelines

Don’t over engineer

Think about maintenance but only when it will be maintained

Page 43: Moving to OOD

Thank you. Now where’s my beer?

www.pokercoder.com

www.flashcoder.net/blog

blog.logicbureau.com

Adobe User Group

Apress User Group