Welcome to the Southeast Minnesota ColdFusion User Group - PowerPoint PPT Presentation

Loading...

PPT – Welcome to the Southeast Minnesota ColdFusion User Group PowerPoint presentation | free to view - id: 1a9c7e-ZDc1Z



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

Welcome to the Southeast Minnesota ColdFusion User Group

Description:

Complex data types have multiple values within one variable. ColdFusion's answer to JAVA objects ... CFC's are Self-documenting (Introspection) ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 24
Provided by: johannso
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Welcome to the Southeast Minnesota ColdFusion User Group


1
Welcome to the Southeast Minnesota ColdFusion
User Group
  • www.bittercoldfusion.com

2
The Basics of CFCs
  • Presented By Johann Sonnenberg

3
What are CFCs?
  • ColdFusion Components
  • Complex data types have multiple values within
    one variable
  • ColdFusions answer to JAVA objects
  • Introduced in CFMX 6.0
  • Store business logic
  • Now just starting to get used and figured out!

4
Components
  • ltcfcomponentgt tag
  • Defines what the component (object) is.
  • Objects are usually what we think of as nouns.
    i.e. Person, Vehicle, etc.
  • Stored in packages (folder)
  • Can create a webservice through a component also
  • Code Example

5
Vocabulary
  • Component Object

6
CFCs are Self-documenting (Introspection)
  • Meta data is created about a CFC when it is
    created/edited.
  • Can browse to a CFC and then see its
    documentation.
  • Be careful of possible security risks with
    placing CFCs in a web root.
  • Example

7
Attributes
  • Derived from what the object (noun) has as its
    properties.
  • Can default these values.
  • Examples
  • Person first name, last name, phone number,
    shoes
  • Shopping Cart number of items, total cost
  • ltcfpropertygt
  • Code Example

8
Functions (methods)
  • Specific tasks a component can do
  • Can just do a task or return values
  • Can return objects also
  • Code Example

9
Vocabulary
  • Function Method

10
Functions Access
  • Public Can be accessed by a locally calling
    page or component method.
  • Package Can be accessed by any other CFC in the
    same package or the object.
  • Private Can only be accessed by the object.

11
Scopes (variables) accessible by Functions
  • arguments any variable (simple or complex)
    passed into the function. Only accessible by that
    function.
  • var variable created within a function and
    destroyed after the function is done being
    executed. Local to that specific function.
  • variables private property of an object
    instance. Should be accessed by setters and
    getters.
  • this public property of an object instance.
  • unnamed private to a function. (no variable in
    a CFC should be un-scoped, if it is it is put
    into the variables scope)
  • Code Example

12
init()
  • Called to create an instance of a component. Not
    automatically called because CFCs do not have a
    constructor.
  • Best practice is to always call this method
    first.
  • init() can create a blank instance or can create
    a fully instantiated instance.
  • Code Example

13
Vocabulary
  • Instance Memory resident copy of the type (CFC)
    with specific values assigned to its attributes.

14
Setters and Getters
  • Setter methods set object properties.
  • ltcfset setFirstName(Clint) /gt
  • Getter methods get object properties.
  • ltcfoutputgtuser.getLastName()lt/cfoutputgt
  • Code Example

15
Creating an instance
  • CFCs are referenced by package (path)
  • Must be a mapping that you can use to get to the
    CFC
  • Call the init() method
  • Six ways to instantiate a component, we will
    focus on ltcfinvokegt and createObject()
  • Code Example

16
Calling a Function
  • instanceName.methodName(arguments).
  • Order does matter.
  • In the arguments, can be in the form of
    argumentName value.
  • Code Example

17
CFC Best Practices
  • Within CFCs, only access the arguments,
    variables, this and var scopes. No shared scoped
    variables.
  • Always use the var scoped variables for use of a
    variable in a function.
  • Always use the hint attribute of the
    ltcffunctiongt and ltcfcomponentgt tags.
  • Only have one ltcfreturngt per function.
  • Package up components when it makes sense.
  • For arguments to functions make as many as
    possible required and define their type.
  • Avoid using the this scope because it is
    unprotected and dangerous to use.
  • Try to pass structures or objects to functions
    instead of lots of variables.
  • Try not to do display (output) from a CFC.

18
10 Minute Break… Raffle Time! Then onto Advanced
Topics
19
Inheritance
  • Inheritance is…
  • Example
  • Vehicle engine, wheels, transmission, lights
  • go(), stop(), start()
  • SUV 4WD system, anti-lock brakes, rollcage
  • switchTo4WD(), checkRollOverStatus()
  • Racecar Nitro, turbo
  • fireNitro(), shift(), spoolTurbo(), crash()
  • Code Example

20
Object DAOs
  • Data Access Objects
  • Has methods that do CRUD (create, read, update,
    delete) interacting with the database.
  • ColdFusion community moving towards using DAOs.
  • Code Example

21
Object Gateways
  • Contains methods to access the database that are
    not handled by the DAO with the CRUD methods.
  • Returns recordsets, booleans, etc.
  • Code Example

22
Questions?
  • Do you have any object questions?
  • Any specific CFC questions that I didnt cover or
    need to cover again?
  • Any other questions?

23
Thanks for coming!
  • Next CFUG meeting on July 25th
  • Mach-II and ColdSpring
  • Advanced skill level
About PowerShow.com