moving to ood
TRANSCRIPT
Moving to OO DevelopmentSean McSharry
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
Why, What and How
Why?
Why OO?
OO vs. Procedural
Why OO?
OO vs. Procedural
The best things take time
Why OO?
OO vs. Procedural
The best things take time
Be Pragmatic
What?
A programming paradigm
It does what it says on the tin
Objects are represented as classes
Not difficult
What is OO?
Modularity
OO Core Concepts
Modularity
Inheritance
OO Core Concepts
Modularity
Inheritance
OO Core Concepts
Modularity
Inheritance
Encapsulation
OO Core Concepts
Modularity
Inheritance
Encapsulation
OO Core Concepts
classA.count=1;
classA.setCount(1);
Modularity
Inheritance
Encapsulation
Abstraction
OO Core Concepts
Modularity
Inheritance
Encapsulation
Abstraction
Polymorphism & Interfaces
OO Core Concepts
Patterns
State
Command
Decorator
Memento
MVC
Singleton
Factory
Proxy
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
UMLUnified Modeling Language
Why is UML useful?
UML
Use Case
Activity
Class
Sequence
Collaboration
State
Component
More...
Unified Modeling Language - Diagrams
UMLUnified Modeling Language - Diagrams
UMLUnified Modeling Language
DiagramsUse Case
UMLUnified Modeling Language - DiagramsClass
UMLUnified Modeling Language - DiagramsClass
UML
UML modeling tools
gModeler
More info:
http://www.uml.org
Unified Modeling Language - Diagrams
How?
Anatomy of a Class
Package definition
Class definition
Class Constructor
Class Instantiation
Variable definition
Access modifiers (Public, Private, Protected & Internal)
Anatomy of a Class Package definition
package com.earth.animals{
}
Anatomy of a Class Class definition
package com.earth.animals{public class Mammal extends Animal{}}
Anatomy of a Class Class Constructor
package com.earth.animals{public class Mammal extends Animal{
public function Mammal(){}
}}
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(){
}}}
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();
}}}
Anatomy of a Class Access Modifiers (Public, Private, Protected & Internal)
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.
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.
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.
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.
Anatomy of an Interface
Packages
Classes
Instantiation
What methods areavailable
What parameters thosemethods accept
What, if any, types arereturned by those methods
Polymorphism & Interfaces
An Interface indicates and dictates :
Polymorphism & Interfacespackage package {public interface IAnimal {
function procreate(parameter:Type)ReturnType;function set noOfLegs(value:Type):void;function get noOfLegs():ReturnType;}}
Polymorphism & Interfacespublic class Mammal implements IAnimal
public class Reptile implements IAnimal
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
Thank you. Now where’s my beer?
www.pokercoder.com
www.flashcoder.net/blog
blog.logicbureau.com
Adobe User Group
Apress User Group