Most voted "oop" questions
Object orientation is a paradigm of analysis, design and programming of software systems based on the composition and interaction between several units of software called objects.
Learn more…1,456 questions
Sort by count of
-
25
votes2
answers2094
viewsPrinciple of Liskov’s replacement
Liskov’s substitution principle says that if given types T and S being S subtype of T then S should be replaced by T. My understanding is that if I have an instance of S then I can use it in places…
-
24
votes1
answer2920
viewsIs this a correct example of Javascript inheritance?
I am studying ways to apply Object Orientation in Javascript. I found a solution to utilize inheritance. I wonder if there are better ways and how to encapsulate my classes. What I’ve been doing:…
-
24
votes3
answers4038
viewsWhat is the difference between using virtual property or not in EF?
I have my models public class Cliente { public int Id {get;set;} public string Nome {get;set;} } and public class Pedido { public int Id {get;set;} public int ClienteId {get;set;} public virtual…
-
24
votes3
answers971
viewsIs POO the same in all languages?
Is the way of structuring, programming in POO the same in all languages? For example, class, interface, etc...
-
24
votes4
answers1016
viewsIs the use of "private" in C# classes optional?
What’s the difference between private string abc = ""; and string abc = "";? Is there any difference or is it just the way you write that changes? I did a test with and without the private and saw…
-
23
votes1
answer15547
viewsHow is 'super' used in Python classes and what is it used for?
How to use and for what purpose super in classes Python?
-
23
votes2
answers2433
viewsWhat is Javascript Prototype?
I see in various instances of native objects a '.protoype' in the middle before a method or attribute but I don’t know what they are EXACTLY. The only thing I know is that it’s Javascript’s way of…
-
23
votes2
answers268
viewsNull attributes on an object is Bad?
I have an object that has 7 attributes: 2 attributes are always with some value assigned. 3 values are always set if a filter query is required (3 attributes are filters). The last 2 attributes are…
-
23
votes2
answers2818
viewsWhat is "Inversion of Dependency Principle" (DIP)?
I’m getting to know the beginning now SOLID: S Single Responsabilty Principle The Open/Closed L Liskov Substitution Principle I Interface Segregation D Dependency Inversion Principle However I could…
-
23
votes3
answers2385
viewsHow important is the use of the word "this"?
What is the real use of using the reserved word this? As far as I can see it makes use or not, but I doubt its functionality.
-
23
votes2
answers418
viewsIs it bad practice to use empty interfaces?
I have heard comments that it would be a good idea, when a future implementation can take place. Also heard that it is a bad practice. I know that in PHP, for example, there is an interface called…
-
23
votes5
answers13505
viewsDifference between Object and Instance
Object-oriented programming is often spoken of in both class and object instances. Seeking the meaning of each one, I realized that now the concepts are unified and the same are treated as synonyms,…
-
22
votes3
answers624
viewsAnalysis and Project in Javascript
When we work with object-oriented languages like Java and C# we have a whole process of analysis and design that helps us to know how to design the application to write more cohesive, less coupled…
-
22
votes3
answers1780
viewsIs the SQL language object oriented?
Is the SQL language object oriented? If so, could you show an example?
-
21
votes2
answers15418
viewsDoesn’t Java have multiple inheritance?
I had seen somewhere now I don’t remember, I think it was in a course on object orientation, which Ruby possesses. But in Java I’ve never seen it. Is that why abstract classes are used? Or is this…
-
21
votes1
answer5221
viewsHow does Design Pattern Observer work and how does it implement it?
I am in doubt regarding Design Pattern Observer, when its working and how to use(present practical example).
-
21
votes1
answer1449
viewsWhat are the SOLID principles?
Lately, I’ve heard a lot about the term but for me it’s never clear if it’s a Pattern design or good practice in object orientation. Maybe it’s a very broad question, but why SOLID is useful and…
oop software-engineering solid programming-principlesasked 7 years, 10 months ago ldeoliveira 2,015 -
21
votes2
answers8871
viewsHow and when to use Interface?
When should I use an interface, in which situations its use is feasible and which is not feasible and how to use it correctly? I developed an example to illustrate a situation, below: using System;…
-
21
votes6
answers1578
viewsIs it good practice to use constructors (or magic methods) in interfaces?
Well, I usually come using interfaces to define how some methods will be used. But to be honest, I’ve never seen anyone using interfaces to define contracts for a construtor. In a specific case I…
-
20
votes3
answers7017
viewsWhat is an abstraction?
Web outside and also here in Stack, sometimes we talk about "abstraction" when the subject is architecture/engineering software and orientation to objects, mainly. What is this "abstraction"? Why is…
-
20
votes7
answers1682
viewsMake the class builder private?
When placing a constructor of a class in C# as private, get the following error: I would like to know the technical explanation for the reason of this error and whether there is any case of use of a…
-
20
votes2
answers10490
viewsWhat is the difference between Association, Aggregation and Composition in OOP?
On relationships between classes, what is the difference between Association, Aggregation and Composition?
-
20
votes2
answers1468
views -
20
votes4
answers4351
viewsHow and why use MVC in PHP?
I always made websites and systems without problem using structured PHP, came the curiosity if it is possible to make a system in OOP completely and if it is more advantageous. Searching I found the…
-
20
votes3
answers719
viewsWhy static methods can be called through the "instance" of the Python 3 class?
Let’s say I have the following class: class Person: @staticmethod def hello(): print('Hello!) When performing the operation Person().hello() the method is executed normally. But the method hello…
-
20
votes3
answers17530
viewsWhy do we have to use the attribute self as an argument in the methods?
I watched a video class where it is said that every method is required to pass the parameter self in the method definition, as in the example below: class Complex(object): def __init__(self, real,…
-
20
votes3
answers296
viewsWhat are God Objects?
I was reading the documentation of Woocommerce, and I came across the following line: Avoid God Objects God Objects are Objects that know or do Too Much. The point of Object-oriented Programming is…
-
19
votes3
answers12047
viewsWhy doesn’t C# allow multiple inheritances?
In C# we can implement several interfaces. However, because we cannot inherit from more than one base class?
-
19
votes2
answers9703
viewsIs it possible to program object oriented in C?
There is the possibility to build a C program using POO? I have looked on several websites for examples of this, but I have found nothing concrete, which tells me whether or not it really gives. If…
-
19
votes1
answer25589
viewsWhen should I use __init__ in functions within classes?
For the book I am studying, in some moments the author uses __init__ as a first function of a class. This function (and others) always has self as one of the variables (something I haven’t yet…
-
18
votes2
answers6312
viewsDoubts about the toString() method of the Object class
I’ve been doing some tests with the method toString() class java.lang.Object and found that the obtained result changes with each execution, as the example below: Excerpt from the tested code public…
-
18
votes3
answers5026
viewsHow to identify classes in an object-oriented system?
When we work with object orientation we need to know how to identify which classes are necessary for a certain application. Some classes are usually "obvious" in a sense: in a product management…
-
18
votes3
answers1132
viewsWhen to use finalizers and garbage collection in Java?
When to use the methods System.gc() and finalize()? I read that it is very useful in object orientation to destroy memory objects that are not being referenced and to finish tasks, but I see few…
-
18
votes3
answers437
viewsDatabase should follow the OO standard?
Object Orientation According to the Rules of Pure O, we have: "The Object must manipulate methods and attributes belonging only to it" That is, what does not strictly belong to class should be an…
-
18
votes3
answers8119
viewsWhat are the best practices in field validation?
I created an example to illustrate my doubt regarding field validation, the example is composed of two classes Pessoa and ModelPessoa. The class Pessoa has the following attributes: Nome, Idade,…
-
18
votes4
answers607
viewsObject orientation - How to find the right abstractions?
Actually the question I’m trying to ask is exactly that: How to identify classes in an object-oriented system?. However, I would like to ask for two additions to the accepted answer. She seems to…
-
18
votes2
answers445
viewsIs it wrong for me to use a static method to retouch a collection of objects?
First of all, I know that I should not go out making classes with various static methods but in this case that I bring here, I do not understand why it can be considered bad practice. Let’s say I…
-
17
votes4
answers2589
viewsIs it possible to create an 'abstract class' in Javascript?
When creating a Javascript class whose attributes and methods are all static (for example, for storing preset settings for a game), I wonder if it is possible to define the class as abstract in a…
-
17
votes2
answers964
viewsWhy doesn’t polymorphism work with Generics?
When trying to compile the following code I got an error. import java.util.*; class Animal { } class Cachorro extends Animal { } public class TestePoli { public static void main(String[] args) {…
-
17
votes2
answers3267
viewsWhen and why should we use polymorphism?
When and why should we use polymorphism in Java, because so far I’ve only used it to make multiple windows based on a model. The polymorphism the way I’m applying is better than making one window…
-
17
votes2
answers5548
viewsIn OOP, can an interface have attributes?
Is it possible for an interface to have attributes? If not possible, why not?
-
17
votes1
answer2146
viewsWhat is a chain of methods?
In object-oriented languages, there is a concept known as method chaining or encadeamento de métodos to Portuguese. What exactly is this ? How would be the implementation of this technique in a PHP…
-
17
votes2
answers560
viewsWhy shouldn’t I change the "getter" s and "Setter"s?
I recently came across a friend saying that it is not advisable to change getters and Setters. I had made the modification of a Setter of a List. In it I did not receive a list by parameter, but an…
-
17
votes4
answers1286
viewsHow many parameters should a method have?
What is the maximum number of parameters a method should have? When one must consider that there are too many parameters? And what to do in that case? Tupiniquim and object-oriented version of the…
oop software-engineering method parameters software-projectasked 7 years, 7 months ago Piovezan 15,850 -
17
votes4
answers936
viewsWhy is the use of Dynamic something to be avoided?
My company works with development, it is a company practice that all codes made are reviewed by another person before they are approved in pull request. Usually my codes have only a few details to…
-
17
votes1
answer191
viewsDoubt of competition on inheritance and polymorphism in object orientation
I took the test of the IFNMG competition for the position of computer teacher. The bank that prepared the test was the CEFET Foundation. One of the questions was this:: About the statements below,…
-
16
votes3
answers5592
viewsWhere to create a class of its own, and how to instantiate it later?
I have a class of my own (i.e. external to the standard PHP and Laravel libraries) that makes some connections with equipment in my network and also need to create routines for email and SMS…
-
16
votes3
answers568
viewsIs there an advantage to an explicit "self" instead of the implicit "this"?
Unlike most [most popular] object-oriented languages, which use a keyword to refer to the object that is "target" of a method call (commonly called this), the Python language requires every method…
-
16
votes2
answers3148
viewsWhy does everyone hate multiple inheritance in C++ and what’s your difference to mixins?
I’ve always heard that multiple inheritance in C++ is chaos. Why? It wouldn’t be technically the same thing as using mixins in languages such as Ruby? And what is this abstract class of Java? It’s a…
-
16
votes3
answers2459
viewsHow useful are Java Annotations?
When I first studied Java, when I saw about Annotations I only saw that they are useful for generating metadata, but I didn’t see anything that influenced the behavior of the program. Basically, I…