Category of object-orientation in Ruby [closed] - ruby

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Object-oriented languages can be categorized into two:
Class-based: like C++
Prototype-based: like JavaScript.
Ruby has class, so it is class-based. But its class is also an object. So is Ruby still a class-based language, or is it something in between? Is this a third category?
EDIT:
Ok, what I was wondering is, is other class-based language doing same thing like ruby, like create a class object of class Class?

In an object-oriented language, what else would a class be, than an object? If one of the most important things in an object-oriented language weren't an object, then the language wouldn't be very object-oriented, would it?
Classes are objects in many class-based OO languages. Smalltalk, Python, Ruby, Newspeak, you name it. There are some languages where they aren't, e.g. Java and C#, but even there you can get a reflective proxy object which represents a class.

Class is an instance of Class class. There is nothing in Ruby that goes against it being class based.

Related

Does the method name need to be grammatical? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 days ago.
Improve this question
I have a question that may seem silly, my english is not very good, I often don't know how to name variables or methods.
For example, There is a method, its function is to open a modal for creating users, I will name it openCreateUserModal, Its corresponding English sentence is "open create user modal", I think this is not grammatical in English because there are two verbs. Would it be better to name it openCreatingUserModal?Or the method name does not need to follow English grammar?
I want to get a rule for naming complex methods
openCreateUserModal is perfectly fine. It clearly conveys what the function does. Following the rules of english grammar is not important in this context as long as the function name clearly indicates what the function does.
Since you haven't mentioned any particular language, below is a source c# naming conventions. The principles are the same for any programming language.
https://csharp-book.softuni.org/Content/Chapter-10-methods/method-naming/method-naming.html

Ruby: Benefits of putting my code inside a Module? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
What's the benefit of putting all my methods inside a Module?
module Math
def Math.print_message
puts "Testing 123 ..."
end
end
If I just write "print_message" in the file and then require the file from within another file, then I can call "print_message" as well.
What's the advantage of having it within this Module-end construct?
Some Things a Ruby Module Can Do for You
In many ways, modules act a lot like classes, although you can't actually instantiate them. There are quite a number of reasons to put code, classes, and other objects inside modules. These include:
Namespacing, to prevent collisions between same-named constants, classes, methods, and variables.
The ability to compose or extend classes, rather than relying on Ruby's single-inheritance model by "mixing in" modules. That's why modules in Ruby are often called mixins.
The ability define class and module level methods that don't need to be instantiated to be used.
The ability to hook the inclusion of modules to create certain behavior when you mix them into other classes.
Support for autoloading.
The ability to adjust the lookup order of the class hierarchy depending on whether you include or prepend a module.
Support for refinements (see Module#refine and Module#using).
There are likely other things that I haven't thought about in this quick, off-the-cuff answer. However, modules are essential building blocks for gems and larger Ruby applications, and understanding them is worth doing, especially if you're planning to grow beyond basic scripting with Ruby.

What module do the class `Hash`, `Array`, `File` belong to? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Simple question:
What module do the class Hash, Array, File belong to ?
Would you just say that they are part of the ruby core?
They are instances of the Class module (class).
Classes don't "belong to modules". They are just objects like any other object. If you are asking about the constants Hash, Array, File, etc., those belong to the Object class. All constants that are not explicitly defined in some specific module belong to Object.
The simple answer to the simple question is Yes they are part of Ruby Core
Yes. Hash, Array, File they all belongs to core.

Classes of methods in ruby [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
In furthering my study of Ruby, I've noticed that some methods really seem to give power to the language, while others are just syntactic sugar.
Examples of sugar: .split, .strip, i.e. any methods that just make doing a menial task with a data structure easier.
Examples of power methods: call, send, responds_to?, method_missing, etc.
It seems like if you understand those "power methods" you really know the language.
Curious about three things:
Has anyone every made such a distinction, be it in a book/blog post etc?
Do you personally make such a distinction?
If you feel what I'm saying is correct, what "power methods" should I know and use better?
Thanks (hope this question doesn't get closed!)
These aren't really "power methods" but are just another tool in the toolbox that is the Ruby library.
Methods like call and send are for low-level operations, bypassing the usual Ruby semantic layer. responds_to? is often used when writing generic code that uses duck typing, and method_missing is a way of writing code that responds to a variety of methods in a dynamic way. This is how Rails ActiveRecord handles methods calls like find_by_name_or_phone automatically.
Methods like split, strip and chomp are simply data transformation methods. Their primary function is to convert one thing into another, optionally in-place.
I don't think there's a distinction between any of these methods, they're all quite useful, but they do have their particular uses. As far as Ruby is concerned, though, all methods are equal, there's no hierarchy or inherent importance to them.
Some methods you will use very infrequently, so you're less likely to ever have need for them unless you've done a lot of Ruby.

sub-subclass concept in OWL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am posting this on stackoverflow since I am quite confused with OWL right now.
So in OWL file, can I represent a sub-subclass concept?
For example, entities belong to a class called Wine and it inside this class, we have a sub-class called WineType and then Within the WineType, we have sub-subclass called enzyme_avability. Would this be possible in OWL as a nested class concept? (e.g. )
Please help me with this
Yes it is possible. I think what you are looking for is here
http://www.w3.org/TR/owl2-syntax/#Object_Property_Restrictions
So in sort you are representing a hierarchy structure which is completely supported by OWL.
You can write axioms like:
A subClassOf B
B subClassOf C
and so on, without limits on the number of levels you want to define. A reasoner will be able to answer queries like: is A subclass of C? by following the hierarchy.
Of course, more complex ways to arrange the hierarchy exist, e.g., the object property restrictions mentioned by Jinal.

Resources