胡军的网络日志

pursue next update


  • 首页

  • 关于

  • 归档

  • 标签

process of design app's class and module

发表于 2013-09-12   |  
Write out the detailed specs Extract out major nouns; these are your classes. Extract out major verbs; these are your behaviors/methods. Create objects out of those classes; these are your actors in your program.
阅读全文 »

Ruby class template

发表于 2013-09-11   |  
class Dog attr_accessor :name, :height, :weight @@count = 0 def initialize(name, height, weight) @name = name @height = height @weight = weight @@count += 1 end def bark "#{ name } bark!" end def info "#{ name } weights #{ weight } lbs and is #{ height } feet tall" end def update_info(n, h, w) self.name = n self.height = h self.weight = w end end teddy = Dog.new('teddy', 3, 100) fido = Dog.new('fido', 1.5, 150) puts teddy.info teddy.update_info('ted', 2, 90) puts teddy.info
阅读全文 »

Ruby method scope

发表于 2013-09-11   |  
Ruby method scope convention Ruby method not have a strict pass by value or pass by reference. if you passing an argument, and the argument calls a method that mutates the caller which may or may not have a !, then it’s going to change that object. This is very common source bug. examplepass by value(not mutate argument in method):a = [1, 2, 1] def my_method(a) a.uniq end puts a will produce: 1 2 1 pass by reference(mutate argument in method):a = [1, 2, 1] def my_method(a) a.uniq! end puts a will produce: 1 2
阅读全文 »

use vpn for git

发表于 2013-09-10   |  
In China, if you git command can’t connect to github, get this tip: ssh: connect to host github.com port 22: Operation timed out fatal: Could not read from remote repository. Please make sure you have the correct access rights maybe(and very possible) beacuse of GFW, use VPN can solve this problem.
阅读全文 »
123
胡军

胡军

学习是一种生活方式

24 日志
7 标签
RSS
GitHub Twitter
© 2016 胡军
由 Hexo 强力驱动
主题 - NexT.Pisces