Showing posts with label Framework. Show all posts
Showing posts with label Framework. Show all posts

Aug 15, 2014

Mach-II Framework - Basic beginner start.

 My journey towards learning Mach-II framework

Few days back, I have added post regarding CF frameworks.
In this post we are going to understand what Mach-II is and what this beautiful framework provides.

There is already a superb Github directory from where you can learn Mach-II.
This post will help you to get familiar with some basics of Mach-II and early hurdles you face if you are a beginner.

Below points will cover whatever I've learned so far in Mach-II.

Let's begin: -
What Mach-II  is ?
  • MVC framework for ColdFusion
    • Benifit of MVC : Separation of codes into different layers which help to reuse and organize your code better using the Model(mainly CFCs), View(shows your content) and Controller(which link Model and Views)
    • In Mach-II controller comprises of plugins,listeners and filters
  • Object Oriented F/W
  • Event Driven Framework
  • mach-ii.xml where all configuration needs to be done. 
    • XML contains : Properties, Events, Listeners, Page Views, Filters, Plugins 
  • II stands for Implicit Invocation
    • As Mach-II is an event driven framework, so all events are handled though event handlers which in turn announced a component for which event is registered.
    • Know More here Implicit-Invocation-Architectures in MVC
  • Easy to maintain and provide flexibility in developing robust application.
How to setup Mach-II ?
  •  First download Mach-II f/w code and skeleton from
    MachII Github or Mach-II home
  •  A basic folder structure which I kept up while learning Mach-II



     
  • Once code downloaded,  now we have to run mach-II application based on where you kept our framework files and skeleton files.
    If you are keeping f/w files outside web root,  then we have to add a mapping in CF administrator. You can also extend Mach-II f/w codes to setup your mach-ii f/w environment.
    Here is the link which shows you various ways to setup your mach-ii application
  • Above Image shows my application folder comprises of both f/w codes + skeleton.
    • I pointed this directory as a Virtual Directory in my IIS and named as "mach2test"
    • Now we need to open /config/ mach-II.xml.  In property applicationRoot we have to specify the root of our application.
      <property name="applicationRoot" value="/mach2test" />
    • Now,  once we have added value for applicationRoot, we have to add mapping or inherit f/w codes using extends attribute.
      So for this I have added "MachII.mach-ii" in application.cfc to inherit mach-ii.cfc
       <cfcomponent displayname="learnMach-ii" output="false" extends="MachII.mach-ii">
    • Now code setup is over, you are ready to run your first o/p in the browser.
      http://localhost/mach2test/index.cfm. If you have downloaded Mach-II skeleton then first o/p will be Hello Mach-II!

Flow of Mach-II Application:
  • All Mach-II request flows from index.cfm because it follows pattern called Front Controlerl
    • Wiki: It provides a centralized entry point for handling requests.
  •  As Mach-II is event driven in nature, so everything goes on by calling an event which creates event objects. Let's look for one example to get a clear Idea on Mach-II flow.
  • Say for example: If you have a basic login page in your application
    • URL : http://localhost/mach2test/index.cfm?event=login. So first request goes to central page index.cfm and start looking for Mach-II.xml
    • As we are calling an event called login (If we don't specify any eventParameter then defaultEvent will execute) so It will look for event-handers where an event is login
    • Now event handler told to open a view called login.cfm.
    • In login.cfm - we have one form whose action calls "index.cfm?event=checkLogin"
    • Now, once again flows go to Mach-II.xml and look for checkLogin event. checkLogin event handler calls listener loginListener which looks for validateLogin method present under loginComponent CFC which resides under the model.
    •  validateLogin() return success/failure and announces an event loginSucess and shows home.cfm or  loginFailure which shows error message.
 Hope you get a basic flow of Mach-II framework.
I am still driving deeper into Mach-II framework, hope I will be coming with some more post related to Mach-II soon. 

Happy Learning :)




Aug 3, 2014

ColdFusion Frameworks - Which one to choose ?

Someone asks me a few days back regarding Skill set of ColdFusion frameworks -

Conversation Starts.

Anonymous - Do you know any of the CF frameworks like Mach-II ?
Me - No, I have not worked with any of them in my project so far, but I am having some Idea about MVC frameworks.

Anonymous: Ok, good. So how long It will take you to learn Mach-II framework ?
Me: Probably x days to get acquainted with all stuffs in it.
Anonymous: Ok, tx.

Conversation ends.

I am not great fan of Frameworks yet.

Yes, I heard that Frameworks do make developer's life easy and you can do some stuffs very easily by writing a few lines of code rather than a bunch of plain codes.

Once I attended Seminar on FuseBox framework months back.  Holy crap that was too much of fuses and circuits drama.
To just add a Login Functionality. We have to take care of  too many settings.

So, what to do now ?
Lot's of question coming to my mind.

After lot's of reading and searches, I thought that It's the best time to learn some frameworks not because someone asking me to learn but I found interesting after seeing this "Sunsetting Mach-II".  
Even if the core developers move out from Mach-II but still Mach-II and FuseBox are most popular CF frameworks.

Frameworks available for ColdFusion
1. Mach-II - one of the first Object Oriented ColdFusion frameworks.
2. FuseBox
3. ColdBox
4. Cold Spring
5. Model-Glue
6. F/W 1
7. CF wheels
*There may be much more of it.

So, I am going to take Mach-II as my first CF framework which will be added to my skill set then FuseBox.

What I want from these frameworks -
1. Easy to Use
2. Rapid Development
3. Good Community Support

Let's Begin ..