OOP

Started by
31 comments, last by gharen2 17 years, 1 month ago
Quote:Original post by Way Walker
Maybe a little relevant. The other day I was reading an intro book on Ruby. At one point, it made a big deal of how Ruby was object oriented and how instead of doing Math.abs(someFloat) like you would in Java you do someFloat.abs because Float is a class and knows how to do nifty things like that. Ok, cool. Now, I wanted to calculate the distance between two points. someFloat.sqrt -> Error. Nope, you do Math.sqrt(someFloat). [headshake]


<continuing-tangent> Gotta love the little things like that, eh?

A powerful (if easily abused) feature of Ruby is it's open-ness of classes however:

irb(main):001:0> class Floatirb(main):002:1>        def sqrt()irb(main):003:2>                Math.sqrt(self)irb(main):004:2>        endirb(main):005:1> end=> nilirb(main):006:0> 9.0.sqrt=> 3.0irb(main):007:0> _


Clarification on earlier points:

When I argue against Object Obsessed Programming, I argue against forcing the programmer to deal with everything from within the OOP paradigm. Everything can be an object as long as the programmer isn't forced to be aware of it.
Advertisement
Quote:Original post by MaulingMonkey
Quote:Original post by Way Walker
[headshake][headshake][headshake]

[cool][cool][cool]

[inlove][inlove][inlove]
Quote:Original post by daviangel
Try C# if Java is giving you a headache since Java forces every program you write to be in a class whereas with C#/VB/c++ you can decide if you want your program to use oop or not.


Actually, C# is actually just as much an object-obsessed language as java. Even the program's main function is a static member of a class.

I believe vb.net allows procedural code, but only inside modules.

This topic is closed to new replies.

Advertisement