Documente Academic
Documente Profesional
Documente Cultură
Module 2: Overview
1/2
Module 2 Overview
Rails Overview Your First Rails App The Blog App Iteration 1 Rails Philosophy Version Control Git and Rails
Module 2: Overview
2/2
Module 2, Lecture 1
1/6
Rails Background
Ruby on Rails (Rails) is a software framework for building Web applications. Features: Built using the Ruby programming language. Open source MIT License. Provides a full stack back-end data store to front-end presentation of web pages, and everything in between. Released in 2004, and has continued to evolve rapidly. Some sites built using Rails: Twitter, Hulu, GitHub,Yellow Pages and Funny or Die
Module 2, Lecture 1
2/6
Model-View-Controller
The Rails framework is built around the Model-View-Controller (MVC) design pattern:
Script/ Service Web Client (Browser) 1: request Network 2: response
Connector Database
Web Server
Client tier
Web tier
Data tier
Module 2, Lecture 1
4/6
Rails Criticisms
It doesnt scale High prole issues at Twitter. Its magic The framework and code generation means you really dont know whats going on under the hood. My Answer Its all a part of the natural progression:
Module 2, Lecture 1
5/6
The point is that the cost per request is plummeting, but the cost of programming is not. Thus, we have to nd ways to trade eciency in the runtime for eciency in the thought time in order to make the development of applications cheaper. I believed weve long since entered an age where simplicity of development and maintenance is where the real value lies. David Heinemeier Hansson
Module 2, Lecture 1
6/6
Module 2, Lecture 2
1/3
Module 2, Lecture 2
2/3
my_app Models, Views and Controllers code Helper scripts (bundle, rails, rake) App, database & route configuration Database schema and migrations Specify the required gems Application logging directory Webroot of the application Tests - Agile development
Module 2, Lecture 3
1/5
Module 2, Lecture 3
2/5
Now, create the post and comment database tables using: $ rake db:migrate
c 2011-13 G.L. Heileman Module 2, Lecture 3 3/5
Module 2, Lecture 3
4/5
Module 2, Lecture 3
5/5
Module 2, Lecture 4
1/5
Rails Philosophy
The Rails philosophy is based upon three principles: Convention over Conguration Common aspects of a web application are provided (i.e., precongured) for you, so use them, rather than ght against them! Ideally, the developer should only have to specify the unconventional aspects of the application. Dont Repeat Yourself (DRY) Every piece of information should have a single, unambiguous, authoritative representation within a system. Duplication of code fragments throughout an application can lead to logical contradictions, and in general make the application more dicult to maintain. Agile Development Software development methodologies based on iterative and incremental development, where requirements and code evolve with minimal planning through self-organizing, cross-functional teams.
c 2011-13 G.L. Heileman Module 2, Lecture 4 2/5
Module 2, Lecture 4
3/5
DRY
Every piece of information should have a single, unambiguous, authoritative representation within a system. E.g., In Rails, with ActiveRecords, once a model is specied, you dont need to specify database column names theyre determined from the model. When applied successfully, a modication to a system element does not change any other logically-unrelated system element, while elements that are logically related all change predictably and uniformly, thereby keeping them in sync. This principle makes it easier to use code generators and automatic build systems. Thus, DRY code is typically created by data transformations and code generators, allowing the software developer to avoid copy and paste operations. Following the DRY principle makes it easier to maintain large software systems.
c 2011-13 G.L. Heileman Module 2, Lecture 4 4/5
Agile Development
Agile development emphasizes working software as the primary measure of progress. Rails was built with agile development in mind:
A working application is available immediately. In development mode, there are no recompile, deploy, restart cycles. I.e., Rails does not generally require you to stop the server; changes made to the application will be automatically picked up by the server. Rails has simple tools to generate code quickly. Testing is built into the Rails framework.
Extreme programming is an agile approach that that centers around test-driven development (TDD). Behavior-driven development (BDD), a second generation agile approach, extends TDD by writing test cases in natural language that non-programmers can read. BDD focuses on obtaining a clear understanding of desired software behavior through discuss with stakeholders. RSpec and Cucumber are BDD tools for Ruby that well use.
c 2011-13 G.L. Heileman Module 2, Lecture 4 5/5
Module 2, Lecture 5
1/9
Version Control
Midnight Train to Georgia by Gladys Knight and the Pips: Considered the signature song of legend Gladys Knight. One of the greatest R&B songs of all time. Rolling Stone lists it as one of their 500 Greatest Songs of All Time.
The original title was Midnight Plane to Houston about a plane trip from Nashville to Houston, and the author envisioned it as a country song.
Module 2, Lecture 5
2/9
Version Control
The need for managing software versions has existed as long as theres been software. Version control is commonly used by a development team to keep track of the various pieces of source code that dierent members of the project are working on, along with the various versions that they may wish to create.
Module 2, Lecture 5
3/9
file A
checkout
Version 2
files: A, B, C
Version 1
files: A, B, C
Module 2, Lecture 5
4/9
Developer 1 file A
checkout
files: A, B, C
Version 1
files: A, B, C
Module 2, Lecture 5
5/9
Version 2
Version 3
1
Version 4
2
Version 5
3
Module 2, Lecture 5
6/9
Module 2, Lecture 5
8/9
pull/push Version 2
files: A, B, C
Version 1
files: A, B, C
Version 2
files: A, B, C
Version 2 pull/push
files: A, B, C
Version 1
files: A, B, C
Version 1
files: A, B, C
Module 2, Lecture 5
9/9
Module 2, Lecture 6
1/6
Module 2, Lecture 6
2/6
Git Basics
Git tracks les, which may reside in three locations:
Working directory Staging area Git repository
Furthermore, the les in your working directory can be in one of two states:
Tracked: les that were saved to the Git repository by the last commit operation. Untracked: all other les in your working directory.
working directory
staging area
checkout <branch> merge <branch>
Module 2, Lecture 6
4/6
working directory
staging area
checkout <branch>
Module 2, Lecture 6
5/6
Module 2, Lecture 6
6/6