LightFront: The incredibly simple & approachable MVC Framework for ColdFusion

Posted By: Brian Meloche; Posted At : October 7, 2009 5:59 AM

Related Categories: ColdFusion, Frameworks, LightFront

I'm finally blogging here about my new MVC framework, which I call LightFront. I first published it on RIAForge on August 31st, and I finally made the project publicly available on RIAForge on October 1st, with updates almost every day since.

I'm not at MAX this year (sorry no CFConversations episodes from MAX this year), and it's been a bit difficult for me to get out a podcast at the moment (a logistics/timing/personal issue... not worth discussing here, but I have two episodes almost out the door), so I thought it was time to post a blog entry about LightFront here.

First, here's where you can find it, and find out about it (beyond what I have said below):

LightFront is an MVC framework for ColdFusion. What, another one? Yes, another one. This one's a little different than the rest, although it's a close relative to one of them.

LightFront is short for Lightweight Front-controller. Unlike most of the CF frameworks out there, it uses only one CFC, and it's just a little bit above 200 lines, so it's straightforward enough most of you reading this with a CF background can look at the core and understand what's going on.

It's conventions based. If you follow conventions, you only have to set three settings in your Application.cfc. That said, there are some conventions that can easily be overridden with another setting. Need to put your views in the /includes/ folder (and subfolders) instead of the default /view/ folder? No problem - that's just an additional setting:

lfs.viewDirectory = "/includes/";

There are some optional settings, too, but I'll get to that below.

Your controller is all defined in CFCs. You don't need an XML file. As previously stated, all of your settings are defined in your getSettingsForLightFront() function in Application.cfc as a structure. There are no additional XML files to config or define your events... do that in your CFCs.

That's if you use CFC-based controllers. The folder has to exist, but you don't need them to make LightFront work. LightFront has a unique feature. You can also use switch-based controllers, a la Fusebox 2 and 3. It can take a switch file from an old Fusebox app and it will work in LightFront. That's not to say LightFront is 100% Fusebox compatible, and I don't intend on making it that way, but I think we can offer an easier update path on old Fusebox 2/3 sites than even Fusebox/FuseNG can. It does make it a lot easier for a team who wants to move into CFC-based apps to gradually transition into that architecture while at the same time still maintain legacy Fusebox-ian style applications. There are a couple of additional settings to add if you have a Fuseboxian switch/circuit to add to LightFront, similar to how you define circuits in Fusebox, but it's very simple to do.

LightFront is also easy to make work with legacy applications that use no framework at all. Let's say you have an application that has index.cfm, aboutus.cfm, contactus.cfm at the root. No problem. Create a view/home mapping and point it to your root. then, you will be able to call /view/home/aboutus.cfm as displayView("home.aboutus") or displayView("home/aboutus").

That is a double benefit. Let's say you have a site which has a number of static or mostly static pages. You don't need a switch or a CFC controller if you follow simple conventions. If you want to call a static /view/home/aboutus.cfm directly as an event, no problem. As long as all home events are direct calls to view pages and don't use a home.cfc controller or a home switch file, you're fine. Your URL would be ?/do=home.aboutus. LightFront will automatically check for the existence of a home controller. If it doesn't find one, it will try to call /view/home/aboutus.cfm and it will display that as the event. This is also great for prototyping a site, too. You can also define pre-events and post-events, should you need to call events before and after each url called event (they only run once per request).

You can also map assignments from one event class to another (help.contactus goes to home.contactus), change event names (do) and delimiters (.), change naming conventions of the CFCs, and a few other things.

The closest currently supported framework that I know of in ColdFusion to LightFront is FW/1. In fact, Sean beat me to the punch to release FW/1 over LightFront by a few days. I had to go back and see if LightFront was worth it at all to complete, and stopped working on it for a few weeks. After a lot of reflection and some deep analysis of the two frameworks, I decided just before CFUnited that LightFront would continue. FW/1 is very similar, but it doesn't support legacy applications quite as easily as LightFront does, it's more conventions based than LightFront and less flexible in how you code (some would say "more opinionated"), and it ties into ColdSpring or Lightwire and the services layer. I intentionally decided not to do this. It's not that I disagree with using dependency injection/inversion of control or a simple bean factory, or in the idea of a services layer (all my apps have them). It was a conscious decision for LightFront to be a controller framework - nothing more and nothing less. The same can be said for ORMs - LightFront doesn't care whether you use them or not. It's up to you. LightFront only cares about being the controller. In fact, FW/1 and LightFront have so much in common that I could see them merging at some point if that's what people want, or they could travel separate paths. I'm open to either possibility.

Where I see LightFront going depends on what developers that use the framework want. As the first developer to use the framework :-), my thought is if people want what the big frameworks have, those things would go in via a plug-in architecture. Perhaps that would continue to be in the controller folder, or a plugins folder... I don't know. That said, it's fairly simple to build a controller CFC that functions like a filter or add a controller CFC that handles caching, and building those things directly into the framework adds greater complexity to the framework - something I am dead set against. I want to keep LightFront approachable, easy to learn and easy to use.

In fact, one of my goals in making LightFront was to make a simple framework for people to use. I wanted something that didn't require a CS degree or 10 years of CF experience to understand. LightFront should be a framework you can teach any developer the basics in 30 minutes or less you have to learn three functions:

  • callEvent()
  • displayView()
  • relocate()

That, and a few helpful settings changes, are all a developer needs to know.

If you can keep things simple enough for a junior developer to both be productive AND build good code, LightFront will succeed in its main objective.

Anyway, I hope you take a look at the framework, join the Google group and help shape the new framework. And now, back to CFConversations!

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
How light is LightFront, compare to FW/1?
# Posted By Henry Ho | 10/7/09 1:20 PM
@Henry, I replied to you on Twitter (you asked the same question there), but the answer to that question is LightFront's even lighter than FW/1. That's not to say that it's better, or that lighter means better. FW/1 does a little more than LightFront does, and it may be worth it to get those extras. Choice is good, either way.

Sean and I have talked about each framework, and I gave him a little access before I released it to the public.

By the way, even though LightFront is light, it doesn't mean that it's the lightest out there. Barney's FB3Lite (http://www.barneyb.com/barneyblog/projects/fb3lite...), which was another big influencer for LightFront, is probably the lightest I've ever seen.
# Posted By Brian Meloche | 10/7/09 3:10 PM
So would you say that your framework is built to allow other things like skinning to be added in (Say something like my CuttleFish or COOP) without the framework getting in the way of other technologies like that? If so I will look at building some example apps where the those run together.
# Posted By John Farrar | 10/9/09 8:24 AM
I don't see why not, John. I'd have to look at CuttleFish, but of what I know about Co-op, it should work fine.
# Posted By Brian Meloche | 10/10/09 3:14 AM
How is the event model in Lightfront any different from using GOTO statements?
# Posted By Joe Rinehart | 10/30/09 12:38 PM
Joe,

I will preface this by saying I deeply admire you. Your speech at this years CFUnited was truly inspiring.

But that comment you made is totally uncalled for and truthfully is beneath you.
# Posted By Rick Mason | 11/5/09 5:07 PM
Joe, what ever is stressing you would be a better focus than wading up paper and spitting it through a straw. LOL, Rick is right. You typically have not been quite so bad at comments like that. It appears that you have bad blood for Brian for some reason with a comment like that. Could yo rephrase the comment with some meaning?
# Posted By John Farrar | 11/5/09 5:23 PM
Didn't realize that asking about GOTO programming was such an insult.

I'm asking how the system of termed "event" in LightFront is something that is an "event model" (allowing implicit invocation) rather than being a way to jump to labeled code blocks, where the labels are the NAME attribute of <cfcomponent> (more like GOTO). I've downloaded LightFront and was even working on rebuilding LitePost in it (as Sean did with FW/1), and I realized that things were called "events" but weren't at all acting like event-driven programming. I've been looking (for years) for a simpler approach to event-driven MVC/II development than what ended up being called Model-Glue, and I'm asking how this could be such a thing.

In short, I wasn't asking to insult or disrespect: I was asking because I wanted to know. You're right, thought, John - my comment was terribly phrased, and I shouldn't have written it until I had time to do so properly.
# Posted By Joe Rinehart | 11/13/09 12:50 PM
Joe, I guess it sounded a bit like you were stirring up the pot. I am pleased that you're interested in the framework enough to consider writing a port of Litepost for it.

I understand what you mean about it not being event-driven, and perhaps it's misnamed. OK, not perhaps, it is misnamed. It's not event-driven, and it's not implicit. It's explicit, although it may not become as directly explicit in future revisions. When I get to 0.5, I'll stop renaming things, but I will strongly consider a renaming of callEvent() to callAction() or something similar. Though it's been a week or so where I haven't updated LightFront, I've been using the framework daily, and have already made quite a few changes and considering that rename as one of them. Thanks for bringing that to my attention; it's appreciated.
# Posted By Brian Meloche | 11/16/09 3:52 PM
You said that FW/1 "ties into ColdSpring or Lightwire" and I want to clarify that it HAS NO SUCH DEPENDENCY. Sorry for shouting but your comment may lead people to think that FW/1 requires another framework and that is completely wrong.

FW/1 *allows* you to use a bean factory to manage your controllers and your services - _if you so desire_ - and in fact it supports any bean factory that follows a couple of conventions. One of the sample applications even has its own simple bean factory that it uses with FW/1.

Since some people already like to use a bean factory for their model, providing minimal built-in support for that seemed like a good idea.

It's also worth pointing out that FW/1 does not *force* a service layer on anyone. It's optional (not opinionated). Again, the driving factor was existing best practices in application design and a desire for FW/1 to support that. Since one of LightFront's users asked up front how to call methods in the model, it seems I made the right choice by providing some conventions in that area - no one has asked how to call methods in the model for FW/1 :)

I'd also challenge your comment about legacy application support. Both FW/1 and LF use Application.cfc and that in itself is an obstacle for some legacy apps. However, several people are successfully integrating FW/1 piecemeal into their legacy apps - and several sites are live in production with FW/1.

Since you've started actively promoting LightFront by presenting on CFMeetup and submitting LightFront talks to conferences, I feel the need to correct any misrepresentation of FW/1 that you put out there in the public record.
# Posted By Sean Corfield | 11/19/09 12:16 PM
Sean, my words made it seem otherwise, and that wasn't my intention. "Ties into" didn't mean "tied to". I meant it can connect to object factories but FW/1 is, in no way, dependent on them.

The Application.cfc comments are also correct, though I'm planning to offer an Application.cfm alternative in an upcoming sample.

I'll publish something on 0.4.3 once it's out, including what's planned for the next few versions.
# Posted By Brian Meloche | 11/19/09 10:42 PM
Thanks for work! Good article. I am a junior developer and wanna to try the LightFront =)
# Posted By tech | 5/25/10 3:59 AM

Hosting provided by...

Hosting provided by hostmysite.com

Calendar

<< July 2010 >>

Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Archives By Subject

  • About Me (41) [RSS]
  • ActionScript (1) [RSS]
  • Actuate (1) [RSS]
  • Adobe (16) [RSS]
  • Adobe Community Professionals (2) [RSS]
  • AIR (1) [RSS]
  • AJAX (1) [RSS]
  • Animals (11) [RSS]
  • Articles (2) [RSS]
  • ASP (1) [RSS]
  • Blogging (14) [RSS]
  • BlueDragon (2) [RSS]
  • Canadian-American (1) [RSS]
  • CFConversations (16) [RSS]
  • Cleveland (3) [RSS]
  • Cleveland AUG (20) [RSS]
  • Cleveland CFUG (23) [RSS]
  • ColdFusion (78) [RSS]
  • Conferences (33) [RSS]
  • Design (3) [RSS]
  • Dreamweaver (1) [RSS]
  • Eclipse (1) [RSS]
  • Flash (2) [RSS]
  • Flex (10) [RSS]
  • Frameworks (7) [RSS]
  • Fusebox (1) [RSS]
  • J2EE (1) [RSS]
  • JavaScript (1) [RSS]
  • Jobs (2) [RSS]
  • LightFront (6) [RSS]
  • Linux (2) [RSS]
  • Mac (3) [RSS]
  • Mach-ii (9) [RSS]
  • Macromedia (9) [RSS]
  • MAX (34) [RSS]
  • Notes to Self (1) [RSS]
  • Open Source (7) [RSS]
  • Personal (16) [RSS]
  • Podcasts (23) [RSS]
  • Politics (1) [RSS]
  • Railo (0) [RSS]
  • Random Musings (10) [RSS]
  • Reality TV (1) [RSS]
  • Social Networking (1) [RSS]
  • Speaking (7) [RSS]
  • Subversion (2) [RSS]
  • Tech News (2) [RSS]
  • Technology (2) [RSS]
  • Tutorials (1) [RSS]
  • User Groups (22) [RSS]
  • Videos (1) [RSS]
  • Weight Loss (4) [RSS]
  • Windows (0) [RSS]
  • Work (8) [RSS]
  • Search

    Twitter Updates
    Follow me!

      RSS

      Subscribe

      Enter your email address to subscribe to this blog.

      Tags

      about me adobe animals blogging cfconversations cleveland aug cleveland cfug coldfusion conferences flex max personal podcasts random musings user groups

      Recent Comments

      LightFront 0.4.4 has been released, and... my CFObjective talk...
      maertsch said: great presentation. really cool anti-mainstream but with lots of facts. i have learned a lot. thanks... [More]

      LightFront: The incredibly simple & approachable MVC Framework for ColdFusion
      tech said: Thanks for work! Good article. I am a junior developer and wanna to try the LightFront =) [More]

      LightFront - New Video Series - Getting Started with LightFront
      Brian Meloche said: As they say, "it's not you, it's me". :-) I thought everything worked as it should. I'll h... [More]

      LightFront - New Video Series - Getting Started with LightFront
      Derek said: I believe 1600x1200. 24" monitor. Not at home to check, but looks like u gotten taken care of n... [More]

      LightFront - New Video Series - Getting Started with LightFront
      Brian Meloche said: I must have a newer version of the Flash player or something. I was able to replicate the problem. I... [More]

      Podcasts I Listen To...

      Active Podcasts
      CFConversations (My Podcast)
      CFPanel (technically not a podcast, but close enough!)
      RIA Podcast
      CFHour()
      The Flex Show
      Non-active CF/Flex Podcasts (still worth a listen)
      ColdFusion Weekly
      The ColdFusion Podcast
      Helms and Peters Out Loud
      Other Podcasts
      This Week in Tech (TWiT)
      Windows Weekly with Paul Thurotte
      MacBreak Weekly
      Net @ Nite
      Slashdot Review
      Ruby on Rails Podcast (I'm not a Rails developer, but it's always a good idea to stay in touch with the competition!)
      Web Design Podcast from boagworld.com
      Practical Web Design Magazine