To begin with, I am a PHP programmer with good experience. Many interesting things were written, there were large projects, services in the sphere of telecommunications covering almost the whole of Europe. Development and support of projects was carried out not a month or two, but a year and a half.
After moving to a managerial position and avoiding the need to constantly program, it became possible to devote more time to studying and comparing new languages ββand technologies. In principle, this is part of my work :)
Glance fell on Ruby he Rails. The famous
Agile Web Development with Rails: Second Edition was read and a small project was written. Here I will try to list the features of this beautiful framework that I liked. If you do not plan to write on rails, then I think you will still be interested to get acquainted with some goodies that can be easily ported to other languages ββ(a lot has already been done for PHP, including me).
Application framework (matter of taste)
Yes Yes. Although many will shout that this is a restriction of their freedom, but as my experience shows, many programmers simply need to limit. The structure of the rails is very logical. Each component has its place. Very clear separation of MVC components.
')
Application Configuration (convenient)
By following basic naming conventions for application components, you avoid tedious configuration. The initial division into runtime environments: development, test, and production is also a good programming tone.
Database version control (required for large projects)
Database migration. All the changes you make to the database: creating tables, adding indexes, etc. - placed in the application code and stored in your version control system (I have SVN). Each migration looks like this.
class AddEmailColumnToOrders <ActiveRecord :: Migration
def self.up
add_column: orders,: e_mail,: string
end
def self.down
remove_column: orders,: e_mail
end
end
Successful Active Record (powerful library)
The simplicity of creating models for working with database objects is amazing.
class Order <ActiveRecord :: Base
end
This is sufficient for working with the orders table. No explicit mapping. Communication between entities is very convenient and flexible.
Testing (necessary in large projects)
There are only emotions. There are three types of tests:
1. unit tests of models - a la JUnit, PHPUnit (this is familiar),
2. functional tests - the same unit tests, but for controllers,
3. integration (?) Tests of the entire scripts of the web application; the code will speak for itself
def test_buying_a_product
dave = regular_user
dave.get "/ store / index"
dave.is_viewing "index"
dave.buys_a @ruby_book
dave.has_a_cart_containing @ruby_book
dave.checks_out DAVES_DETAILS
dave.is_viewing "index"
check_for_order DAVES_DETAILS, @ruby_book
end
This is testing the application at the highest level.
Caching (required in large projects)
I liked 2 things here. The first is page caching. Suppose urls / products / details / 1 you display a description of the goods. Rails can create the /products/detail/1.html file in the public directory, which will be provided by the web server as static content. It is clear that this is a great impact on performance.
The second thing is the observers of the models in which you determine when to clear the cache. For example,
class ArticleSweeper <ActionController :: Caching :: Sweeper
observe article
# If we create a new article, we must regenerate
def after_create (article)
expire_public_page
end
# If we update the article
def after_update (article)
expire_article_page (article.id)
end
The cached article
def after_destroy (article)
expire_public_page
expire_article_page (article.id)
end
end
Javascript (convenient)
1. good integration with prototype,
2. a wide choice of helpers for the development of Ajax components of the application,
3. generation of javascript using RJS templates (this is a type of presentation from MVC); looks like this
page.replace_html ("cart",: partial => "cart",: object =>
cart )
page [: current_item] .visual_effect: highlight,: startcolor => "# 88ff88",: endcolor => "# 114411"
3. if your application is rich in javascript and the client has it turned off (there are still clever people), then it is rather easy to leave them the opportunity to work with your site.
Readable URLs (convenient)
A simple and logical implementation of recognition and generation of friendly URLs.
map.connect 'store / checkout',: conditions => {: method =>: get},: controller => "store",: action => "display_checkout_form"
map.connect 'store / checkout',: conditions => {: method =>: post},: controller => "store",: action => "save_checkout_form"
AdditionalDebugging and other (convenient)
Built profiler and benchmark scripts. The breakpoint method, called in the controller's action, interrupts the page's script, allows you to perform any actions with the application through the console, and then continue with the execution of the script.
This is the little that I can remember at 11 pm. Starting holivary is prohibited. I just listed what I would like to see in all projects.