Ruby中的设计哲学

37 篇文章 0 订阅

Ruby中的设计哲学


  • Follow web standards and HTTP 遵循Web标准和HTTP
  • CoC (Convention over Configuration) 约定大于配置
  • MVC (Model-View-Controller)
  • DRY 不要重复造轮子(如:gems )
  • Software Engineering Patterns
  • Assets 静态资源
  • Restful API
  • Testing 测试
  • Deployment 部署
  • Automation 自动化(数据修改,移植)

Agile Development 敏捷开发

  • Philosophy
  • DRY
  • Ecosystem: Gems / Community

从本地开发到线上

  • Development Environments: Development / Test / Production / Staging(自定义模拟线上环境)
  • Test
  • Configurations 配置
  • Deployment 部署

Pages & Assets

  • Dynamic pages: Routes / Restful / Inheritance(继承)
  • Assets: Asset Pipeline / Minify / Combine / Webpack / babel etc.

Dynamic Pages

  • Routes 路由
    • HTTP GET/POST/PUT/DELETE
    • Custom routes
    • Easy to refactor
  • Filter 过滤器
    • before_filter
    • around_filter
    • after_filter
  • Cache 缓存
    • Page Cache
    • Fragment Cache
  • Response
    • HTML
    • JSON
    • XML
    • etc.

ActiveRecord

  • Powerful ORM
    User.find(2)
    User.find_by(email: 'service@abc.com')
    User.where(membership: 'gold').page(2)
      .per_page(10).order("id desc").limit(10)
    user.blogs
  • Triggers 回调
    • before_save
    • after_save
    • after_destroy
    • after_create
    • etc.

Assets

  • Javascript/CSS minify and combine
  • Assets URL
  • ETag
  • SASS
  • CoffeeScript

从开发到测试

  • Unit Test: rspec / minitest
  • Smoke Test / Continuous Integration: cucumber / selenium

脚本和自动化

  • rails c
  • rails g
  • rails s
  • etc.
  • rake task
    • rake routes
    • rake db:create
    • rake db:migrate
    • etc.

自定义rake任务

Libraries

  • gem
  • bundle
  • rails是很多gems的组合
  • 创建自己的gem
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值