abstraction
What’s the difference between a sequence and a collection in Clojure
Any object supporting the core first and rest functions is a sequence. Many objects satisfy this interface and every Clojure collection provides at least one kind of seq object for walking through its contents using the seq function. So: user> (seq [1 2 3]) (1 2 3) And you can create a sequence object from … Read more
Why are interfaces preferred to abstract classes?
That interview question reflects a certain belief of the person asking the question. I believe that the person is wrong, and therefore you can go one of two directions. Give them the answer they want. Respectfully disagree. The answer that they want, well, the other posters have highlighted those incredibly well. Multiple interface inheritance, the … Read more
Should I use public or private variables?
private data members are generally considered good because they provide encapsulation. Providing getters and setters for them breaks that encapsulation, but it’s still better than public data members because there’s only once access point to that data. You’ll notice this during debugging. If it’s private, you know you can only modify the variable inside the … Read more
Is an ORM redundant with a NoSQL API?
Well, yes, Object-Relational mappers are redundant with MongoDB because MongoDB isn’t a relational database, it’s a Document-Oriented database. So instead of SQL, you write queries in JSON. Unless you really, really want to write raw JSON, as opposed to, say, Linq, then you’re still going to want to use a mapper. And if you don’t … Read more
Is it better to use List or Collection?
It just depends, do you want your users to be able to index into the data? If yes, use List. Both are interfaces, so you’re not leaking implementation details, really, you just need to decide the minimum functionality needed.
What’s the difference between abstraction and generalization?
A very interesting question indeed. I found this article on the topic, which concisely states that: While abstraction reduces complexity by hiding irrelevant detail, generalization reduces complexity by replacing multiple entities which perform similar functions with a single construct. Lets take the old example of a system that manages books for a library. A book … Read more
What is the difference between Abstraction and Polymorphism
Abstraction Imagine a fraction class: class fraction: int denominator int numerator Now two objects of that: fraction(obj1): denominator=-1 numerator=-1 fraction(obj2): denominator=1 numerator=1 Both objects have the value 1: (1/1) == (-1)/(-1). You wouldn’t expect they behave any different to the outside. That’s abstraction. You abstract the data your object holds into a logical view, even … Read more
What does the quote “An extra level of indirection solves every problem” mean? [closed]
Generally it means that by increasing the level of abstraction one can make the problem easier to understand/resolve. Be careful with your abstractions though, the full quote at least as I heard it is, “You can solve every problem with another level of indirection, except for the problem of too many levels of indirection”.