»
S
I
D
E
B
A
R
«
Evejob Sprint #1 Views, Templates, Controllers Part #1: About MVC (Model-View-Controller) and MVT (Model-View-Template)
Nov 23rd, 2009 by evereq

Because Evejob Project developed in few frameworks, we need to make clear “terminology” differences used by different frameworks as well as different strategies to develop MVC applications using such frameworks.
Let’s start from MVC frameworks:
1) ASP.NET MVC as we see from name is “Model-View-Controller” framework (powered by .NET framework), so use actually concepts of “Models”, “Views” and “Controllers”. “Views” and “Controllers” concepts defined by framework itself (i.e. you need to inherit controllers from System.Web.Mvc.Controller class and inherit views from System.Web.Mvc.ViewPage to use build-in view engine). It is also possible in ASP.NET MVC to attach third-party View Engine (just google and you will found at least few). But “Models” concept in ASP.NET MVC is true “concept” – you don’t need to inherit from some base class or implement some interface to made a models in ASP.NET MVC! Instead framework provide you will full flexibility to create your own domain model and select any persistent framework if you need to persist your model entities. You can use for example Entity Framework, Linq to SQL, any other ORM or even POCO to implement your models!
2) Ruby On Rails is true “Model-View-Controller” framework and more so it uses “convention over configuration” principle. This mean that you actually have already defined conventions where to put your model entities, where to put controllers and where to put views (templates) and how to implement them (from what class you need to inherit etc). Sure while it is still possible to made some changes and even use another ORMs etc, build-in (OK, read instead “installed by default with Rails”) ActiveRecord ORM is enough for most cases (OK, at least in most simple cases ;-) ). The same things with templates (views) – you can use build in template engines (provided by ActiveView module) or add your own – at the time I write this exists not less then 20! different third-party template engines in addition to build-in (sure you can always build your own if need and made 21-th)!
3) Grails is really “Model-View-Controller” framework, was build with same principles like RoR, but because Grails work on top of Spring and Hibernate, developers initially get BEST build-in enterprise infrastructure from Java world! And sure in Grails infrastructure was extended so much (thanks to power of Groovy), that it looks like it most powerful MVC framework to the moment (this is just my personal opinion – I don’t want to start a war here :D )!

So frameworks listed above all follow MVC terminology where you actually create your own Models (Domain Models possible with Persistence), implement Controller (with actions) and create presentation using Views (that is actually powered by some build-in or custom template engine).

One framework – Django – that we use for Evejob project made use of a little different terminology (instead of MVC): Model-View-Template.
Model term is used for same purposes like Model in MVC – it is simply domain model (provided usually by build-in to Django ORM, but also possible to use your own ORM… just note that it require little more “tuning / hacking” than in other frameworks).
View in Django play the same role as Controller in MVC.
And “Template” term in MVT actually used instead of “View” from MVC (while Template terms actually also used in MVC in sense that view CAN be represented as result of Template rendering)
What I found from my experience that this difference in terminology does NOT make any actually impact on development process!
More so, actually most MVCs that available in the market used mostly in “MTC” mode – i.e. “Model-Template-Controller”.
What does it means? It means that Controllers actually render Templates in MOST of the cases! Sure in case if you use MVC framework to build for example Web Services, you will probably not render any Templates and your controllers (controllers in MVC or your Views in MVT) actually more likely will return JSON or XML directly (OK… XML it is possible also to build using Templates sometimes – look how it is done in Grails for example! But let’s think here that we want to return raw XML from Controller without any template engine). Sometimes you also can return JavaScript or any other format etc directly from Views in MVT or from Controllers in MVC.
What is good in MVT is “order” of letters that give better understanding for developers that first time here about this pattern – “Model” <-> “View” <-> “Template”. This way logical flow going – i.e. views are in the “middle” of this logical flow! (using this principle it was better initially probably call MVC as MCV, i.e. “Model” <-> “Controller” <-> “View” :D , so “Controllers” become in the middle, center of logic). It related only to logical structure, because in MVC pattern, Model accessible (and used) actually in both Controller and View, same like in MVT both Views and Templates share same Model! You can read a short overview of MVC at Wikipedia article for example if want little more information)
But as I tell before – main thing is “understanding” how pattern works, not how we call it! And “idea” of implementation of this patter in Django and other frameworks is exactly same even so name is not!

Evejob Development Environment Installation Part #5: Ruby, JRuby and Rails + AppEngine Installation
Oct 28th, 2009 by evereq

Ruby installation

Let’s start from Ruby installation. We can download Windows One-Click Installer from http://rubyforge.org/frs/?group_id=167, for example ruby186-27_rc2.exe

During installation, make sure that you select at least “Enable RubyGems” option:

RubyInstallation

You can leave default installation folder (C:\Ruby).

Ones you finish installation, you can run both “ruby” and “gem”  from withing your command line.

So it’s time to install Rails, just type in command prompt:

gem install rails

and wait few minutes to finish installation.

JRuby installation

Download installation package from http://jruby.org/download. We will need binary Windows version, for example JRuby 1.4.0RC1 Binary .zip. Extract folder content to C:\JRuby folder and add path to the JRuby to your PATH variable:

JRubyPath

Let’s test installation:

JRubyTestInstallation

Now both Ruby and JRuby installed.

The problems starts when we will try to simultaneously use them (side by side)… First of all, make sure that you delete RUBYOPT environment variable (because it seems like JRuby gems did not work correctly if this variable setup). Now you can invoke each “gem” using following commands:

For Ruby:   ruby -S gem

For JRuby:  jruby -S gem

For example this is what I get on my machine:

GemSideBySide

Note: it is actually not a big problem that I had 2 different versions of Gem on my machine – both versions (1.3.1 and 1.3.5 works well for me… update of gem 1.3.1 fails for some reasons on my machine, so I decide to leave this for now…)

One small thing to do: it is possible that you have old version 1.3.1 of RubyGems like me (in the moment when I write this, latest version is 1.3.5 like was installed for JRuby). If we leave it, we can face some problems in future with IDEA etc, so let’s just update it:

UpdateRubyGems

Also, let’s install jruby-openssl (IDEA generate Error if this gem not installed):

OpenSSLforJRuby

Rails Installation

Next step is installation of Rails – just type following commands (it is better to just install Rails twice than to share same installation for both Ruby and JRuby):

ruby -S gem install rails
jruby -S gem install rails

EvejobRoR and EvejobRoRG Project

We going to create 2 separate projects now:

EvejobRoR – will use Rails build in ActiveRecord + MySQL database

EvejobRoRG – will use App Engine hosting, datastore and Google Accounts for user authentication APIs

Let’s start from more simple EvejobRoR:

cd c:\evejob
rails EvejobRoR -d mysql

Now let’s open this “template” project in IDEA:

File -> New Project -> Create project from scratch:

CreateRubyProjectInIDEA

Change here “Project files location” to the “C:\evejob\EvejobRoR”, select “Ruby Module” and press next (see screenshot above)

Now you need to specify the Ruby SDK (current version of IDEA can’t detect SDK locations from environment variables). Press “Configure…” button and press “+” button in “Configure JDK” window:

AddRubySDK

Select “Ruby SDK” in popup and than select Ruby interpreter path:

SetRubyPath

I Hope you will get something like this:

RubySDKAddedToIDEA

If so, just press “OK” and continue IDEA project creation Wizard:

ContinueRubyProjectCreationWizardInIDEA

Select “Ruby on Rails” on next screen and press “More…”  for Rails Facet configuration:

SelectRubyOnRailsTechnology

RailsFacetSettings

Make sure that you select “Use existing Rails application” and “Preconfigure for selected database” to “mysql” like (see picture above)

Now fill free to finish project creation Wizard. Done! We get EvejobRoR project loaded into IDEA.

Same steps we need to made for EvejobRoRG project, with small difference that this time we need to add JRuby SDK, instead of Ruby SDK like before and that we don’t want to support mysql as we are going to use Google App Engine API instead.

So, first type:

cd c:\evejob
rails EvejobRoRG

Then same like before, create new project in IDEA, put here “C:\evejob\EvejobRoRG” path and in “Specify the Ruby SDK” press “Configure…” and add JRuby SDK:

JRubySDKInIDEA

After made same steps like was done for EvejobRoR project, just make sure that you unselect “Preconfigure for selected database” check box in Rails Facet Settings dialog and process steps like before to finish Wizard.

Hopefully you get EvejobRoRG project opened in IDEA!

Prepare JRuby / Rails for Google App Engine

Google App Engine runs Java applications, so we need to make sure that we can assemble our JRails applications into a Java Web Archive (.war). To do such tasks easy, let’s first install “warbler” gem:

jruby -S gem install warbler

Now it is time to check that you add Java JDK path to windows PATH environment variable (because “warbler” gem use JDK):

JDKPathToPATHVariable

Next step, to run following commands from application root folder (c:\evejob\EvejobRoRG):

jruby -S warble pluginize
jruby -S warble config

(make sure you type “warble”, not “warbler” that is just Gem name)

Now you can just check that “Warbler” works:

jruby -S warble

As result you must see EvejobRoRG.war file generated in application root folder (c:\evejob\EvejobRoRG)

We can’t use this .war file directly for Google App Engine for few reasons, but at least we see that we can get some .war file :)

I specially not use all appengine-jruby project gems for few reasons:

  • google-appengine gem install own “tuned” version of JRuby that we want to avoid for reasons, for example for quick updates as we don’t want to depend on this special version of JRuby etc (means that project must be installed using Ruby, not JRuby! And only after installation it download and install customized, ‘frozen’ version of JRuby)
  • google-appengine helps to run JRuby on Google App Engine, but not to run Rails on Google App Engine ! :) All problems related to Rails on App Engine are still exists (read more at http://code.google.com/p/appengine-jruby/wiki/RunningRails)

But what I do use is one of the gems from appengine-ruby project – “appengine-apis”, so let’s install it:

jruby -S gem install appengine-apis

Read this for now to get more information about Rails and Google App Engine specific things:

http://olabini.com/blog/2009/04/jruby-on-rails-on-google-app-engine/

http://www.railshacks.com/2009/4/25/run-your-ruby-on-rails-app-on-google-app-engine

We will get back to this later…

Evejob Development Environment Installation Part #2: IntelliJ IDEA and Plugins Installation
Oct 21st, 2009 by evereq

Let’s start with installation and configuration of the IntelliJ IDEA IDE for RoR / GoG / Django and Google App Engine development.

At the time I write this article, version 8 is available and version 9 (Maia) only at pre-release stages… So we start development in version 8 (but with really huge interest we will wait for version 9!). Also please note that community version of IDE is lack some important functions, so we going to use commercial version (30 day trial will be enough to start)

So go to http://www.jetbrains.com/idea/, download and start installation of Windows version of IntelliJ IDEA. During installation you need to select the plugins to enable. Made following selection (I am going to use Git and Subversion version controls systems in Evejob project)

SelectVCS

On next screen, when IDEA will ask you about Web/JavaEE plugins I recommend to leave all options selected (unless you know that you not going to use some of Java technologies in near future) dues to the fact that when we move to Grails development, some of this plug ins will be in used.

On “Select Application Server Plugins” I also recommend to leave all options, as probably we will want to test hosting of application on as much Web Servers as possible (unless you know specific server requirements) – it is exactly way I am going to develop Evejob!

Same way, I recommend to leave all HTML / JavaScript development Plugins and Other Plugins selected (unless you know for sure which one you going to use and which one not… seems effort to enable them later can be more then performance issues in case if you just leave everything enabled, at least on latest hardware).

In case if you have only one developer machine, on next screen with “IDEA Server Account details” you can just select “Do not login”, press “Skip”

DontLogin

and move forward to the end of installation.

Finish!

But wait – it’s not all – we need also to install plugins for RoR, Django and even Google AppEngine (Grails support build in to IntelliJ IDEA 8)…

Let’s start:
- go to File / Settings
- in Settings window found at left list box “Plugins” item and select it.

- open tab Available

- wait few seconds, until get a list of all available plugins in JetBrains database.

- in search box, start typing “Python”.

- select “Python” plugin in filtered list

- right click and press “Download and Install” link

IntelliJPythonPlugin

Plugin will be downloaded and installed for you (usually takes few minutes)!

Now it is time to install same way “Ruby” and “Google App Engine” plugins…

After you install all 3 plugins, press “Apply” button and answer “Yes” to the question about restart IDEA to activate changes in plugins.

That’s it with IntelliJ IDEA installation!

Project “Evejob” Introduction
Oct 12th, 2009 by evereq
Logo

“Evejob” is a Web 2.0 style Social Job Board Open Source web application developed in few frameworks / programming languages simultaneously and released under GPLv2 license.

Why another job board application?

First – every developer understand naturally such business domain because at least one time in his live he was a “Job Seeker” and some day probably also become (will or already) an “Employer”. So I (and readers) will not spend time to learn business domain in developing Job Board application! (sometimes really huge amount of time team or independent developer just learn business domain of application… It’s actually wrong to think about this as “time waste” because as much developers understand the business as more better software they usually made!).

Another reason why I decide to create another job board open source application(s) is absence of such project developed in true MVC architecture (at least by now). Try to search open source Job Board software? You will found huge amount of poorly written PHP scripts (most are not open source) and for sure you will not found any good ASP.NET MVC or Ruby on Rails implementations… Social Job Board software have a huge “potential” and I don’t want to lost opportunity to develop good open source version of such application (and even more – first few versions powered by different platforms!).

Last reason which I want to list here (in reality I have much more reasons for sure), is that I have some cool ideas how to make really SOCIAL Job Board and want to at least try such ideas on practice!

Evejob Application Versions

So, there will be few major versions of Evejob applications:

  • EvejobDJ (powered by Django -  high-level Python Web framework)
  • EvejobDJG (powered by Django -  high-level Python Web framework and ready to be hosted on Google App Engine)
  • EvejobRoR (powered by Ruby on Rails – open source MVC web application framework which leverages the Ruby programming language)
  • EvejobRoRG (powered by Ruby on Rails – open source MVC web application framework which leverages the Ruby / JRuby programming language and ready to be hosted on Google App Engine)
  • EvejobGoG (powered by Grails -  open source MVC web application framework which leverages the Groovy programming language that based on the Java platform)
  • EvejobGoGG (powered by Grails -  open source MVC web application framework which leverages the Groovy programming language that based on the Java platform and ready to be hosted on Google App Engine)
  • EvejobNET (powered by Microsoft ASP.NET MVC framework and written on C# programming language under Microsoft .NET platform)
  • EvejobAzNET (powered by Microsoft ASP.NET MVC framework and written on C# programming language under Microsoft .NET platform and designed to be hosted in Azure)

All versions will be developed and updated in parallel with comparisons between frameworks / languages  features, platforms and even IDEs in the way …

Why I will release project as Open Source? Sure primary reason because I want other developers will get benefits from it, like I now get benefits from all open source software that I use every day. Another reason – I want to made this application better, so I need feedback, and not only from end users, but also from other developers! In my case, because I get used few different programming languages, I will probably get really huge feedback – at least few times more then if i will write code using one language! I will get feedback from developers with different cultures (Unix vs Windows environment), different preferable coding styles (dynamic language or static) etc… Think project will benefit from this (and actually I never see something like this before so it will be at least interesting to get a try :D … ) !

Agile Development

As you probably understand by now, I am a huge fun of Agile development (and even Agile life).

What this means for selected project:

  • ANY feedback, both positive and negative highly appreciated!  (just please make sure that it’s “constructive” – I don’t want to start a wars between platforms, I don’t want to get feedback about my English level etc – just stay concentrated on the project)
  • I will try to get releases every month  (just be aware that like most of developers I do this open source project at free time at home after hard work… )
  • I will follow DRY principle (as well as many other Agile principles) and sure will always try to keep things Simple! Please correct me in case if I go in wrong direction!

Integrated Development Environments

One thing where I really don’t want to go most simple way is usage of Integrated Development Environments (IDEs) … While all development can be done using even simple text editors (notepad, vim, Emacs etc) I decide to implement this project using rich IDEs available for selected platforms.

Reason – most of developers DO use IDE at work (companies simply buy it) and I think this will help developers to make total compare of PLATFORMS, not just frameworks or programming languages. While a lot of people can argue that IDE does not make any difference (and probably they are right in some cases),  I think usage of IDE can significantly decrease developing time ones you get use of functionality they have and sometimes even improve discipline (with tools like ReSharper for C# for example) of developers.

So here is the list of IDEs I am going to use:

  1. IntelliJ IDEA by JetBrains (http://www.jetbrains.com/idea/) for Django (using Python plugin), Grails development (build-in support) and Ruby on Rails development (using Ruby Plugin). Version for Open Source development available for free at JetBrains site, for personal development costs 249$, while version for commercial developing costs 599$. But you can simple start with 30 days Trial version for now, exactly like I do.
  2. Microsoft Visual Studio 2008 (http://www.microsoft.com/visualstudio/en-us/products) for ASP.NET MVC development in C#. Standard edition cost 299$, while professional cost 799$. For our needs it’s enough to have just standard edition. Also sure thing you can download 90 days Trial version for now – after you try it (if never try before), you will 100% buy it as there is no alternative for .NET !

Why I choose IntelliJ IDEA, but not Eclipse or Netbeans (really good free alternative to IDEA) or Wing or Komodo etc? For .NET development, Visual Studio is STANDARD and Express Edition that available for free simply “for users other than professional software developers, such as hobbyists and students.” (but even so Express Edition should also work for you). Because my goal is to be at least “professional software developers” (and readers I think also) I must use at least Standard version of Visual Studio that is not free (except cases when Microsoft give it for free for start-ups etc, like on http://www.microsoft.com/bizspark/ for example)… So to make fair comparison I must use something not free for other versions also… This means that great tools like Netbeans or Eclipse simple can’t be used in this case (as both are completely free). Sure if you going to made your own projects you can use Netbeans or Eclipse because both have good support for both Ruby on Rails and Grails development and even Django (with some additional external tools / plugins). Regarding Komodo / Wing etc, they are too specific for selected languages or does not support all frameworks I need (at least by now).  While it is available free IntelliJ IDEA version for open source developing, because I (and readers) some day going to make a money, it’s make sense to compare versions for commercial development.

Application Hosting

Hosting… Yes, while I can leave this decision for later in theory, in practice it can (and will) effect our architecture… So let’s made it clear now: I am going to host Grails, Django and Ruby On Rails versions of Evejob application in Google AppEngine. Google AppEngine support Python natively so we can run Django here. Also last version of AppEngine support  Java as programming language. So because Grails leverages Groovy (which written on Java), we can also run Grails applications in AppEngine. Same for Ruby On Rails – it is available JRuby implementation of Ruby on Java so we can run Ruby On Rails applications in Google App Engine. To host ASP.NET MVC application in I am going to use latest Microsoft Azure platform.

Operation System

I am going to make all development under Microsoft Windows 7 64 bit Operation System (OS). Visual Studio 2008 does not work on any other non-Windows operation system directly (and I don’t want to use virtualization for such case – IDE must work on operation system for which it was written to get maximum performance… but, while IDEA works on almost any OS, Visual Studio does not!). Even so, It is still exists option to use Mono (cross platform Open Source development framework) to run ASP.NET MVC on other OS except Windows, and to use MonoDevelop instead of Visual Studio for example. Unfortunately I decide to port application to Mono AFTER development will be completed. (primary because I just want to wait until Microsoft legally allow to use Mono or finally will just “close” it, so I will not need to release another version for this wonderful framework).

Project sources, links and documentation

  • Projects hosting
  • Evejob Open Source Projects homepage (under construction currently)
  • Public domains for implementation sites (sites will be hosted only after Evejob reach first release version):
    - Worldwide: http://evejob.com, http://evejob.net, http://evejob.info
    - Israel: http://evejob.co.il
    - Mobile Clients: http://evejob.mobi
    - USA: http://evejob.us
    - Ukraine: http://evejob.com.ua
    - Russia: http://evejob.ru
    - “СНГ” http://evejob.su
»  Substance: WordPress   »  Style: Ahren Ahimsa
© Copyright 2008–2009 EvereQ.com All rights reserved.