190 likes | 209 Views
Create flexible, reusable ColdFusion code easily with BlackBox methodology for faster development, increased flexibility, and enhanced code organization. Learn the concept, start coding, and elevate your development process.
E N D
BlackBox Methodology A means of creating efficient and flexible reusable ColdFusion code. www.cfblackbox.com
Personal Info -Dan Chick • Web programmer since 1994 • Founder of FastCart Corp. (www.fastcart.com) • Founder of Webkit Inc. (www.webkit.com) • Creator of BlackBox Methodology • Published CF author, Allaire.com, CFDJ • Ran Twin Cities CFUG for 3 years • Semi-pro photographer and musician • dan@webkit.com
The State of 1999 • Fusebox (www.fusebox.org) • Difficult to nest modules/applications • Unattractive URLs • Often difficult to customize the output • I created techniques to address these but they were awkward and difficult • I wanted a better way that addressed all of these issues. Enter BlackBox….
What’s in a Good Methodology? • Separates brains from beauty • Re-use of code • Flexible code • Attractive URLs • Ability to make different modules interact • Lets you code in your own style while still allowing you to share code with others • Simple to learn and employ
Why BlackBox? Developers say… • Abstraction of functionality • A high level of code re-use • A tremendous increase in development speed • Enhanced flexibility and extensibility • A thought process leading to an ease of development • Rapid prototypes • Compartmentalization of code • Easy knowledge transfer • Portability and openness • Confidence in existing modules
Coding in BlackBox • Learn the concept • Get blackbox.cfm • (Optional) Get starter modules from cfblackbox.com • Start coding
Technical Aspects • It’s all about how your organize your files Web Root (folder, can access modules) Blackbox (folder) Forums Guestbook Users Blackbox.cfm Directory1 (folder, can access modules) Blackbox.cfm Directory2 (folder , can access modules) Blackbox.cfm Directory3 (folder , can NOT access modules)
Or… Custom Tag Folder Custom Tags Blackbox (folder) Forums Guestbook Users Blackbox.cfm Web Root (folder, can access modules) Directory1 (folder, can access modules) Directory2 (folder , can access modules) Directory3 (folder , can access modules)
How To Call Blackbox <CF_BLACKBOX TOOL=“users.login_form”> <CF_BLACKBOX TOOL=“users.login_action”> OR <CF_BLACKBOX TOOL=“users.login_package”> (more on packages in a second…)
Interview with the Module • bbsettings.cfm • Form_add_message.cfm • Display_messages.cfm • Action_add_message.cfm These can be coded in ANY STYLE YOU WANT!!!
Techniques:bbsettings.cfm • I put a file called bbsettings.cfm in the Blackbox root folder • Contains functions and settings I want to share to all modules • Another file in each module called bbsettings.cfm that includes ../bbsettings.cfm • My blackbox.cfm file checks to see if this file exists in module folder and includes it. • Think of this as a sort of an application.cfm for one or more modules
Techniques: application.cfm • Certain variables can be shared if they are established in the scope of the entire app • Request.datasource, request.username, request.password • Application.site_root, application.site_directory
Inheriting settings……if you want <CFPARAM NAME="request.datasource" DEFAULT=""> <CFPARAM NAME="attributes.datasource" DEFAULT="#request.datasource#"> #attributes.datasource# - uses passed value OR request value as default OR is empty <CFPARAM NAME=“session.user_guid" DEFAULT=""> <CFPARAM NAME=“form.user_guid " DEFAULT="#session.user_guid #"> <CFPARAM NAME=“url.user_guid " DEFAULT="#form.user_guid #"> <CFPARAM NAME=“attributes.user_guid " DEFAULT="#url.user_guid #"> #attributes.user_guid# - uses passed value OR url value OR form value OR session value OR is empty
Packages - Overview • All pages link to attributes.nextpage • attributes.nextpage default value is cgi.script_name • Each page exit action (link, form) passes another variable (module_action) • One ‘package’ action within the folder is the only action called. It uses module_action to access the right files • Modules can be called as packages OR as standalone actions
Packages - Anatomy <CFPARAM NAME="form.links_action" DEFAULT="categories"> <CFPARAM NAME="url.links_action" DEFAULT="#form.links_action#"> <CFPARAM NAME="attributes.links_action" DEFAULT="#url.links_action#"> <CFSWITCH EXPRESSION="#attributes.links_action#"> <CFCASE VALUE="categories"> <CFINCLUDE TEMPLATE="categories.cfm"> </CFCASE> <CFCASE VALUE="category_detail"> <CFINCLUDE TEMPLATE="category_detail.cfm"> </CFCASE> <CFCASE VALUE="click_link"> <CFINCLUDE TEMPLATE="click_link.cfm"> </CFCASE> </CFSWITCH>
Illustration of Time Saved • ColderFusion 50 minutes including design • User and user profiles • Content • Links • File Repository • Forums
The developing community • www.cfblackbox.com • Forums • File sharing area • White papers • Developer Profiles • Mailing List • http://groups.yahoo.com/group/cfblackbox/
Some sites running BlackBox • www.flashmn.com • www.darktwincities.com • www.colderfusion.com • www.cfblackbox.com • www.pinhole.org • www.photosmack.com