Why does a. Net programmer learn Ruby on Rails?

Source: Internet
Author: User
Tags control label learn ruby on rails
Why am I a senior. net Program Employee, after a month of Ruby on Rails learning, he will think: only after I understand Ruby on Rails, in order to complete many previously developed applications with less time and coding?

You are a senior. Net programmer and have already used ASP. NET to build many web applications.

Countless sleepless nights. To make the event-driven model in the ASP. Net control life cycle run as you want, you have to work hard and go deep into the details.

You are proficient in layering your applications using design patterns such as presentation model and Model View presenter to make them easier to test and maintain.

You think Ruby on Rails is just one of the many boasted technologies. You won't pay too much attention to it until it has gained a considerable market share.

Welcome to my world. If you are still reading this articleArticleI would like to pay tribute to you. You may be curious about the following statement. Why am I a senior. net programmers, after a month of Ruby on Rails learning, will think: only after I understand Ruby on Rails, in order to complete many previously developed applications with less time and coding?

Honestly, I still think. NET is great. It provides me with a platform that enables me to continuously provide great commercial value to customers. But I always remind myself that there are a lot of different methods and technologies to solve a simple problem, and there are always some better than others. Being interested in a certain technology will inevitably lead to some unconscious prejudice, which will ultimately hinder my ability to provide business value to customers. For example, my understanding of dynamic scripting languages like Ruby makes me think: Compared with compiled languages, I can spend less time writing simple automatically processed batch/shell scripts.

Why not?

The following are some typical differences I found when I (A. Net programmer) studied Ruby. Hope you like it.

No need to compileRuby has no compilation concept. Everything works during running. Some people thinkCodeCompilation can prevent code carelessness. Then, you may want to see how test-driven development works and continuous code integration (Of course, not every day ), unit testing (tests that do not involve databases and web services) and dependency injection can help you generate code of good quality, allowing you to change your code with confidence and flexibility. The role of compilation is suddenly less important.

Dynamically add class behavior-do not use decorator ModeTo dynamically add class behavior in a static type language, we can use the decorator mode or template method. In Ruby, there are more ways to do this easily without complicate the object design structure. This is only because the language itself supports it. For example, the module is used as Minxin, And the class_eval and instance_eval methods are used. In fact, you can even define class methods at runtime by programming. In a static type language, you can also generate code to complete it. However, knowing more methods can help you take a step toward solving a good problem.

(Note:MixinProgramming LanguageIs a class that provides some functions to inherit the subclass, but Mixin cannot be instantiated. Inheritance from a Mixin is not a special form, and it is more suitable for the collection function. A subclass can even inherit all or most of its functions by inheriting one or more mixins. A Mixin can be extended to runtime definition and binding method, and attributes and instance parameters can also be defined at compilation. This is different from our common methods, such as defining all attributes and methods first, and initializing during compilation .)

By removing all types of declarations and interface declarations, the code library is "reduced" by 10-20%Ruby is a dynamic language. You do not need to declare its type before using the variable, or define an appropriate type for the parameters in the method signature. This means your code will become thinner, but it is at the cost of code debugging and Error Tracking, right? This is not the case if you believe in unit testing and good object-oriented design concepts. If your class is small and compact, the class method is short and sophisticated, and you have passed a good unit test, debugging and Error Tracking will be simple.

Timely AjaxRuby on Rails has built-in scripts. aculo. support for the US database (script. aculo. us is an Ajax class library that contains a large number of dazzling Ajax effects. Using these effects can make your applications more interactive and friendly ). In many cases, this is equivalent. net, drag a control label to the HTML page, and write the method for it elsewhere (in rails, This is the Controller) to process Ajax Web requests on the server side. Your web page supports Ajax, just like Google suggest's AutoComplete or drag-and-drop sorting. That's simple.

Rails does not require dedicated o/R ing.Naming conventions are used to name tables and columns in a database and your domain model object, which makes it easy for you to perform o/R ing yourself. Ruby on Rails will achieve this for you. In the simplest case, add a field to the view and make it persistent. You only need to add a text box in HTML and add a new column in the corresponding database table, then you can see that the newly entered text is stored in the column created by the database. Really, it's that simple.

It is better to build, deploy, or publish applications using Ruby scripts than Nant.Rake is a standard build tool used in Ruby on Rails development. Rake uses the ruby syntax, which means you need to use Ruby to compile your build script when building and deploying different applications. As a language, Ruby is particularly outstanding in the following aspects: it processes the creation of strings, files and directories, and supports advanced regular expressions. Think about the number of times, you need to perform the following operations in the batch processing and Nant Script: put all the commands in directory A on server. copy SQL files with the extension to server B and execute these files in sequence. If you hate the programming restrictions of batch processing scripts, or do not like writing scripts in XML format like Nant, you will like rake.

Benefits I have to overcome many obstacles when learning Ruby. First, I have to accept the fact that, compared with the "comfortable" technology being usedSolution It takes me more time. However, it will not take long for you to feel happy, because you can solve different problems in a large number of ways. Secondly, I learned Ruby/rails to benefit me a lot. I learned to use it to deepen my understanding of the knowledge. Remember, you can either use it or let it disappear for things you have consumed time to learn.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.