OOP - Handle class - oop

I came about the term handle class in object-oriented programming in Matlab. What do we mean by this?
Thanks.

MatLab: Handle classes (Objects that share references with other objects)

Related

What does Invariants in Classes means in Objective C?

I came across the word invariants.
From the statement: Don't break superclass invariants.
(This is based from WWDC15 Video - Protocol-Oriented Programming. It's a discussion about Class inheritance being intrusive and if it contains stored properties, you don't want to break superclass invariants.)
You can watch it at https://youtu.be/g2LwFZatfTI?t=9m10s
The video will start to the point related to it.)
But I don't really know what invariant means?
I tried to search the web and there is no clear definition about it is?
How does it relate to inheritance of classes?
Thanks.

object oriented-ness, extensability and modularity for simple program

How efficiently we can apply object oriented-ness, extensability and modularity for simple program? If it is application I can identify Entities and relations between them. When it comes to simple program I am not able to do this.
Please help me in achieving object oriented-ness, extensability and modularity in the Berlin clock program in the link.
http://technologyconversations.com/2014/02/25/java-8-tutorial-through-katas-berlin-clock-easy/
Thanks in Advance.
Here's how I would tackle the problem
object oriented-ness
First of all find out all the entities involved in your problem. Then intepret them as classes. In this case for example the clock is based on different Lights and their inter communication to display actual time.
So I would consider Light as an abstract class and would also inherit different other lights (E.g. RedLight, YelloLight etc) from this abstract Light class and extend them.
Extensability
Always use interfaces rather than directly accessing the classes. In this way you could replace or extend your classes
Modularity
Have your Model (Classes), Business Logic, UI Logic etc separated in different class libraries (or separate projects).
Hope this simple explanation helped.

How to simulate genericity using inheritance?

I do not understand how to simulate genericy using inheritance, I am consulting the article "Genericity versus Inheritance" of Bertand Meyer, but I still do not understand it. I would apreciate a clearer explanation.
In some programming languages you can simulate genericy using inheritance with abstract type members.
Here is an example using scala. It should be understandable even if you don´t know scala.
class Collection {
type T;
//all methods are using T for the contained type.
}
I´m not sure but in c++ type would be typedef.
Following this approach you can get a collection with elements of type A by subtyping the collection and specifying type T to A:
class IntCollection extends Collection {
type T = Int;
//...
}
This solutions has some shortcomings in relation to generics or templates but also offers benefits.
If you are interested then consider reading this:http://www.artima.com/weblogs/viewpost.jsp?thread=270195
Abstract Type Members versus Generic Type Parameters in scala.
again you don´t have to know scala to understand the post.
edit: to cite just one sentence:
At least in principle, we can express every sort of parameterization as a form of object-oriented abstraction.
Hope that helped
Generics are needed only in static typed languages (or those with type-hinting) - because you do not want to lose that hardly acquired type-safety.
If your (static) language does not have them, it's probably time to think about different one - simulating using inheritance is ugly hack.
Or better - think about dynamic languages and test driven development. You'll gain much more power (everything is generic, no need for typing) and tests will represent your contract - including concrete examples - which is what even the best type-safe abstraction simply can't do. (because it's abstract)
In the general case, you can't do it. That's why OO languages have had things like templates and generics added to them. For example, all attempts to create generic containers in C++ prior to the introduction of templates foundered or were almost completely unusable.

Multiple inheritance in OOP

I'm confused about an OOP feature, multiple inheritance. Does OOP allow Multiple Inheritance? Is Multiple Inheritance a feature of OOP? If Multiple Inheritance is a feature then why don't languages like C#, VB.NET, java etc. support multiple inheritance? But those languages are considered as strongly supported OOP language. Can anyone address this question?
There is no requirement in OO to support multiple inheritance, which is supported by languages such as C++. C# and Java don't support and they are no less OO because of that.
Inheritance doesn't have anything to do with object orientation. There's plenty of OO languages that do not support inheritance at all and there's plety of non-OO languages that do support inheritance. Those two things are completely orthogonal.
Please take a look at Diamond Problem
Languages like Java and C# , which is highly inspired from java as matter of Object Oriented Principles, are built for application making development,so the designers of these kind of languages decided to take approach in which OOP can be understandable and quickly be learnt by developers.So, for the sake of simplicity and clarification of responsibilities of each class in inheritance, they avoid considering one object inherit from multiple objects.Instead they consider using Interfaces in order to implement multiple very different behaviors and attributes.With this in mind the principles of:
Single responsibility of each object ,and transparent segregation of responsibility of each interface and subsequent inherited objects be fully understandable.
Multiple inheritance refers to a feature of SOME object-oriented programming languages, not all of them.
These other languages you are referring to use interfaces.
First, you have to distinguish between multiple inheritance and multiple supertypes, these are two very different things.
Multiple inheritance usually reflects to an actual inheriting of implementation (like class inheritance in most OOP languages) and presents a variety of concerns. One is conflict between names and implementations (e.g., two methods with same name and a different implementation), and then issues like the idamond problem.
Multiple supertypes usually refers to the ability to check types (and in some cases cast), and usually does not involve inheriting implementations. For example, in Java you have interfaces that merely declare your methods. So your subtype supports the union of the method supported by the supertypes. This presents less problems because you do not have a method with multiple implementations.
Multiple inheritance usually involves multiple supertypes, though some languages like C++ allow you modify the visibility of this fact (e.g., who can know that type B is a subtype of type A).
To the best of my knowledge, there is no requirement for an OOP language to support either, but at least multiple-supertypes is necessary for a usable OOP language where most design patterns can be implemented in a straightforward way. Multiple inheritance, IMHO, is really not that useful to justify the complexity and costs. I've made the switch to Java ten years ago and can't say that I missed it too much.
Java
Multiple inheritence in Java is quite possible. But there are certain restrictions that Java has.
Java classes do not support multiple inheritances but java interfaces do support multiple inheritances
Java Classes
public class elderchild
{
\\elder child attributes
}
public class middlechild
{
\\middle child attributes
}
public class parent extends middlechild, elderchild \\this is wrong, multiple class inheritance is restricted
{
\\parent attributes
}
Java Interfaces
public interface animal
{
\\animal attirbutes
}
public interface mammal
{
\\mammal attributes
}
public class dog implements animal, mammal \\this is correct!
{
\\dog attributes
}
Note: The diamond problem can also occur in java. To read more about it, open:
https://stackoverflow.com/questions/29758213/multiple-inheritance-ambiguity-with-interface#:~:text=Java%20doesn't%20support%20multiple,methods%20will%20have%20same%20signature.

object oriented programming in c++

how do i make only 1 object creation of any class?
It's known as the Singleton design pattern. There are many tutorials for it, e.g. one here.
Check out the Singleton Pattern: http://sourcemaking.com/design_patterns/singleton
EDIT: Updated link from C# to C++