分享
 
 
 

Ruby and Subversion

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

Feedback on "Ten Things a Java Programmer Should Know About Ruby"

This is a compilation of feedback I received for a list of things Java programmers should be aware of when looking at Ruby. This list is not the final version, nor are all (most) of the ideas in this list mine. This is merely a temporarty holding spot for these ideas while I assemble a talk/article/presentation on the topic.

If you have a problem with anything on this list, please bring it up with the person who made the suggestion (i.e. not me!)

However, if you have further suggestions for this list, feel free to drop me a note at jim@weirichhouse.org.

Boolean methods end in ?. Dangerous methods end in !

you can fit in your mind and write code without looking at the docs every six minutes

less syntax and less typing

Discipline. Because of its inherent flexibility, Ruby require more self-discipline

"." (dot) is a method call operator. "::" (colon-colon) is a scope operator.

Ruby classes are Objects (therefore String.new, not new String())

Everything is an Object

Ruby does not have type casting.

Compared to Java, XML is agile. Compared to Ruby, XML is Heavy.

Ruby has O/R mappers, so find your Ruby "hibernate", but drop any preconceptions.

Don't worry about early performance optimization

Enjoy closures and blocks

No method overloading

Don't worry about interfaces, enjoy Duck Typing.

Reflection in Ruby is much easier than in Java, and more deeply into the language than the java.lang.reflect tack-on.

That you can write Ruby in Java (http://jruby.sourceforge.net)

Everything is an expression.

local_variable, @instance_variable, $global_variable, Constants, (and @@class_variables)

Java static methods do not (quite) translate to Ruby class methods.

you can have variable number of parameters, and multiple return values

Ruby is not a Silver Bullet, unlike Java, right? :-)

Ruby is a language to be used everywhere. You use it even in templates. No need for "Velocity/JSP."

Web-development is possible with other languages besides Java.

Many things that you're used to thinking of as syntax are now just

Ruby is strongly typed, not statically typed

Ruby has extensive reflection capabilities

Ruby is dynamic. You can add, remove and modify objects, classes and methods at runtime.

REXML vs. JAXP. I rest my case.

KISS

Think in terms of methods (behaviors) instead of classes.

you cannot rely on the compiler to catch trivial mistakes

No explicit types. Probably the most disconcerting thing for a javahead

ruby has shortcuts for accessor methods which reduces alot of redundant coding in java

you can use string interpolation, ex: "x: #{@myvar}" instead of having to say "x:" + myvar'

no semi-colons, optional parenthesis

Ruby classes are always "open".

C extensions/wrappers are *much* easier in Ruby than JNI interfaces in Java

Ruby has MVC and OO programming and libraries, but drop any preconceptions.

In Ruby data is strongly typed, but variables are *not*

Once you start coding Ruby, going back to Java is painful.

CamelCase for class names, names_with_underscores for methods and variables.

stop writing so much code

ri is your friend. irb is your other friend.

eval

the builtin classes are much faster because they're written in C and not Ruby

Avoid external utility classes

Use class methods to define pseudo-compile directives

You probably don't need Factories

Enumerable is your friend

Typing is the enemy

No external configuration files

method_missing

Singleton methods

Ruby packaging vs Java packaging

ruby has multiple inheritance through mixins (this is sooo nice to have)

writing code in ruby, can improve the code you write in java

Ruby is agile, perfectly suited for XP

Ruby's OO is message based.

Fixed what's wrong with Perl

Fixes what's wrong with Python

It's super productive (like Perl, Python and Smalltalk)- maybe 5-10x Java.

Is a lot like Smalltalk, but doesn't look as funny

Is a lot like JavaScript, but more OO and more for ful app development

Blocks and Closures

Open Classes

Duck Typing

"finally" is called "ensure"

Use blocks for transactional behavior like like File.open does.

Help at: http://ruby-lang.org/en, http://ruby-doc.org/, news:comp.lang.ruby, irc:ruby-talk

An instance of a class can be extended to be subtly different, without needing to subclass.

you can change your mind about whether .foo is a simple property or a complex method call, without affecting the interface to your class.

HEREDOC strings with variable interpolation make large chunks of output really easy to construct.

For good (but subtle) reasons, you have to leave the '++' and '--' behind.

Top 10 Things I Like About Subversion

I've been using Subversion for over two months as my repository on a project at work and I've recently transitioned all of my personal projects on my Powerbook from CVS to Subversion. I'm really digging Subversion and can't imagine or remember what it was like before I found it.

I wrote this up a few days ago for a meeting at work and thought I'd share it with everyone in blogspace. In no particular order, here are the top 10 things I like about Subversion:

Atomic Commits: It's all or nothing! If even one file out of 100 has troubles, then nothing gets committed. My repository is never in an inconsistent state.

Tools Support: If you don't like the command line (and I do), then you have Tortoise. But since I'm an Eclipse user, I tend to enjoy Subclipse (I've read several people who say that Subclipse has problems, but I've had nothing but success with it for over two months).

Hooks: Automatically kick off a build, fire an e-mail, or update my issue tracking system...just by committing some files.

Web-browsable Repository: Without having to do much additional setup (other than Apache), I get to browse my repository via my favorite web-browser.

Easy branching/tagging/merging: I create a new tag or branch by simply making a logical copy in the repository. Couldn't be smoother.

Efficient handling of binary files: It's my understanding that binary files are stored based on binary diffs to be more efficient.

Everything is versioned: Even directories and meta-data.

Externals: I haven't had the privilege of using externals yet, but they sound darn cool. Check out a project and all other projects that it depends on all at once.

Concurrent versioning: Just like CVS. I don't have to lock something before I can commit changes.

Easy refactoring: I can rename a file or repackage a class and Subversion's smart enough to keep keep the file's history.

And for an eleventh thing that I like: I've got an excellent Subversion book to help me out.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有