Download presentation
Presentation is loading. Please wait.
Published byBritton Baldwin Modified over 8 years ago
1
Introduction to Object Oriented Programming in ColdFusion Nicholas Tunney Senior Software Architect
2
Why Am I Listening to This Guy? Experience Credentials –Articles and Whitepapers –Presentations –Adobe Community Expert –Adobe Certified Advanced ColdFusion Developer –Adobe Certified Instructor Current Projects
3
What will we cover? Why use Object Oriented concepts? Introduction to Object Oriented Programming How to apply Object Oriented principles to ColdFusion Samples Q and A
4
Why use Object Oriented Concepts Scalability Uniformity Reusability Maintainability
5
Introduction to Object Oriented Programming History (Bar trivia) –Simula I and Simula 67 (early 60s) –SmallTalk used Simula concepts (early 70s) Abstract datatypes Concurrent program execution Integrated GUIs –C++ and Java
6
Introduction to Object Oriented Programming ColdFusion is not pure OO! –Pure OO languages treat everything in the language as an object –ColdFusion allows us to use tools within the language that apply OO concepts, but does not require the use of objects –Constructors, Overloading –“Java Lite", Rails.
7
Introduction to Object Oriented Programming OO is not a language or a framework –Principles –Best Practices –Patterns
8
Introduction to Object Oriented Programming Class –Properties –Constructor –Accessors/Mutators –Object Methods –Sometimes Data Access (CRUD)
9
Introduction to Object Oriented Programming Object –Instantiated class –Real world entity
10
Introduction to Object Oriented Programming Defining an object - “Be” the object –Who can I talk to? –Who do I depend on? –What can I do?
11
Introduction to Object Oriented Programming Encapsulation –Private properties –Accessors/Mutators –Good API defines the object. –Over Engineering
12
Introduction to Object Oriented Programming Polymorphism –One class, many instantiations –Employee class Manager Accountant Programmer
13
Introduction to Object Oriented Programming Inheritance and Composition –The “is a” “has a” paradigm Employee –Employee has a(n) email address –Manager is a(n) employee –“Favor Composition”
14
Introduction to Object Oriented Programming Q & A
15
Applying Object Oriented Principles to ColdFusion Creating a class – … properties … … constructor … … accessors/mutators … … public methods … … private methods …
16
Applying Object Oriented Principles to ColdFusion Creating a class – Properties variables.id = 0; variables.firstName = “”; … -- OR – …
17
Applying Object Oriented Principles to ColdFusion Creating a class – Constructor …
18
Applying Object Oriented Principles to ColdFusion Creating a class – Accessor (“Getter”) … calculations …
19
Applying Object Oriented Principles to ColdFusion Creating a class – Mutator (“Setter”) … calculations …
20
Applying Object Oriented Principles to ColdFusion Creating a class – public and private methods –Data Access – CRUD –The “What can I do” of the object
21
Applying Object Oriented Principles to ColdFusion Instantiating an object – best practice Example:
22
Applying Object Oriented Principles to ColdFusion Interacting with properties –Properties are in private scope (encapsulation) –Use accessor/mutator methods
23
Applying Object Oriented Principles to ColdFusion Persistence Methods –CRUD (Create(), Read(), Update(), Delete()) –Can also be separated out into separate DAO –CRUD can be further encapsulated with commit()
24
Applying Object Oriented Principles to ColdFusion Gateway Objects –Used for accessing multiple objects or records –For small applications, methods can be put into one main data access object –For large applications, best practice is to move methods into object specific gateways
25
Conclusion OO is not new, just new to CF CF is not pure OO Classes contain encapsulated properties, accessor and mutator methods, private and public methods Objects are instantiated classes Objects are programmatic representations of real world entities
26
Conclusion - cont’d Think Objects instead of Relational DB. “Be” the object when defining the class Composition is preferred to inheritance DAO methods may be in the class, or in its own class (CRUD) Gateways access recordsets or multiple objects Code generators can be your best friend!
27
Q & A
28
Thanks! http://www.aboutweb.com http://www.nictunney.com http://www.cfoop.org
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.