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
-
10
votes3
answers341
viewsWhy am I calling the subclass method?
public class A { public String imprimir() { return "A"; } } public class B extends A { public String imprimir() { return "B"; } } public class C extends B { public String imprimir() { return "C"; }…
-
9
votes2
answers2765
viewsWhat is the concept and how to implement an Anemic Domain Model?
I would like to resolve the following doubts about the Anemic Model: What is the The Anemic Domain Model? What are the differences of implementation of that model compared to Object-Oriented Model?…
-
9
votes1
answer2567
views -
9
votes2
answers274
views -
9
votes1
answer383
viewsWhat are classes, how do you use them, and in Javascript?
I started studying programming and Javascript 3 months ago, but so far only in technique. However I realized that it makes it very easy to understand the concept of object orientation. I already…
-
9
votes3
answers388
viewsRefactoring of a java class
I have a Java class that contains 1756 lines (obviously not all code, has blank lines, many comments and some commented code in case it is needed in the future) I’m implementing the structure MVC…
-
9
votes2
answers1138
viewsWhy can’t the implemented methods of an interface be private?
When I implement an interface in my class, why your implemented methods cannot be private/protected/etc? And another question, when I implement an interface method explicitly, why can’t this method…
-
9
votes1
answer422
viewsObject-relational impedance difference
Basic questioning about Object-Relational impedance Mismatch, a topic I have little experience with. It really exists? (I’m sure you do; Martin Fowler and Ted Neward already talked about the…
-
9
votes1
answer234
viewsEncapsulation and Java Access Modifiers
A very simple question: Given that class: public class User { private String nome; //get/set public boolean fazQualquerCoisa(){ **duvida**.equals("algumacoisa"); } } Within the method did All() I…
-
9
votes2
answers245
viewsConfused about the correct form of Inheritance in Javascript
I am studying ways to apply Object Orientation in Javascript. I realized that there are several ways to do Inheritance in Javascript. I did the one that I thought was simple and worked. But is it…
-
9
votes1
answer150
viewsWhat is the relationship between OOP and code security?
Is there any foundation to think that an object-oriented programming style is safer than the structural one?
-
9
votes1
answer823
viewsWhat is the Null Object standard for?
I asked that question What is the purpose of Emptyiterator? at SOEN, because I found no answers here. Then I was told in a response from the SOEN of a pattern called Null Object. What is the purpose…
-
9
votes3
answers8723
viewsDifference between "Attribute" and "Instance Variable"
Reading some books and articles about introduction to Java and OO I realized that these terms are not well defined. Looking deeper I found different definitions in different sources on the subject.…
-
9
votes1
answer574
viewsWhat is Explicit in C++?
I came across the term explicit being used in a C code++. What is the use of this keyword?
-
9
votes3
answers2573
viewsIs it possible to avoid using ifs in these cases?
I have read many materials on the internet about OOP, the overwhelming majority says to avoid if/else at all costs. For an OOP beginner like myself, many doubts arise. For example: if…
-
9
votes1
answer289
viewsWhy use a private?
I’m learning variables public and private. If it is I who create all the code of the program, what is the need to create a variable private? It is enough that I do not program a code that accesses…
-
9
votes1
answer5620
viewsWhat is the difference between inner class, nested class and anonymous class?
I often read about these three types of classes when I’m researching something about java, but the truth is that it often causes some confusion about what each one of them really is and whether…
-
9
votes2
answers450
viewsStatic blocks, heritage and constructors in Java
Hello, during my studies in Java I came across the following question Given the code below: class Foo extends Goo { static { System.out.println("1"); } { System.out.println("2"); } public Foo() {…
-
9
votes1
answer1539
viewsWhy use VAR in PHP?
Why use VAR in php if we can already declare variables without VAR? We can do this: $teste then why do it? var $teste For example, it’s the same thing I do? class Caneta { var $modelo; var $cor; }…
-
9
votes1
answer94
viewsWhy can Unboxing only be made for the type that was previously performed Boxing?
I’ve been searching for why there is Unboxing and Boxing, the answers I found say there is to value types have the same behaviour as Reference types, for example on non-generic lists ArrayList. So…
-
9
votes1
answer207
viewsWhat is the difference between String name = "test" and String S4 = new String("Peter");
What’s the difference of assigning a value to a variable by creating an object and assigning Unboxing at a direct value? String s4 = new String("nome"); String nome = "nome";…
-
9
votes1
answer298
viewsReserved word include or "use" in PHP?
I saw somewhere that word reserved include in PHP should be used only in procedural programming, and that in object-oriented programming the word reserved should be chosen use. I haven’t found…
-
9
votes1
answer325
viewsIn C++ where are the functions of the objects in memory?
In C++ when an object is declared, class variables are stored in the stack or in the heap depending on how the object was created. With the operator sizeof() it is possible to test and realize that…
-
9
votes2
answers994
viewsWhat are side effects?
I was reading that reply and it has a table where it says that functional programming has no side effects and that OOP has, it generated me two doubts, being them: What are these side effects? Can…
-
9
votes2
answers687
viewsHow do I know if a class implements an interface?
In PHP, we can implement one (or more) interface in a class. Thus: interface Authenticable { // métodos } interface Model { // métodos } class Person implements Authenticable, Model { // métodos }…
-
9
votes2
answers128
viewsIf abstract classes and interfaces cannot be instantiated, what is happening here?
I discovered that interfaces and abstract classes cannot be instantiated, but my teacher gave me an example that left me in doubt, because it seems very an instance of interface ActionListener.…
-
9
votes1
answer1978
viewsHow to program in a modular way?
I am studying some concepts here and I want to see if I have the right ideas and also launch a(s) question(s). In modular programming (either structured or OOP) instead of my application being…
-
9
votes2
answers102
viewsWhy should descriptors instances in Python be class attributes?
I’m studying descritores in Python and I found that they should be implemented as atributos de classe for example: class Descriptor: def __init__(self, obj): self.obj = obj def __get__(self,…
-
9
votes3
answers170
viewsHow to change property access level in an inheritance?
I have a class that when inherited I want one of its public attributes to become private, so that the user does not have access to the use of this variable in this class, but I do not know how to do…
-
9
votes1
answer188
viewsInstantiate a class from its name in a string, without using "Eval" and in Chrome (V75+)
I need to instantiate a class from a string. Turns out for some reason it doesn’t work the way I used to: class MinhaClasse{ meuMetodo(){ alert('Método Funciona!'); } } let nome_classe =…
-
8
votes2
answers1077
viewsHow interesting is it to use APC? Is it recommended to use it with objects?
I’ve been reading about PHP’s opcode cache, APC. Most of the materials I found to read, although good, only explain the installation/use of APC functions. What I’d like to know is: How interesting…
-
8
votes1
answer1127
views -
8
votes2
answers925
views -
8
votes2
answers2530
viewsIs a module the same as a Python class?
A module is the same thing as a class? If not what are the differences? I ask this because according to the The Zen of Python, modules should be used instead of ifs. The problem is that after…
-
8
votes3
answers2984
viewsHow to name a unit test when using TDD?
It is common to use nouns to name: classes (Car, Vehicle, Notafiscal); action verbs (infinitive or not) for method names (Calculartotal/Calculatotal, Lertodasaslinhas, Closeconnection, Abra…
-
8
votes2
answers406
viewsObject declaration in Javascript
function List(){ this.listSize = 0; this.pos = 0; this.dataStore = []; }; I can consider this code snippet as creating a List object?
-
8
votes4
answers688
viewsSuperclass can become subclass?
I have the classes Versao, that a general version, VersaoFirmware and VersaoSoftware. In practice the user can add one or more versions to an equipment. However, at first, it is not yet known what…
-
8
votes2
answers121
viewsDeclaration of an interface with Where
I’m studying a lot Pattern design, because I think they solve a lot of things and it is very opportune to study them. I took this statement on the Macoratti website and I confess, I could not…
-
8
votes2
answers742
viewsWhat’s a destroyer for?
In some languages, classes have methods destructors. In the ones I’ve seen, he’s declared a builder with the sign ~ in front. Something like: public class Foo { public ~Foo() { //Fazer algo } } What…
-
8
votes1
answer716
viewsShould I extend from an abstract class or a concrete one?
When I need to extend a class, following the concept of Object Orientation, should I extend my code from an abstract class or an abstract class? What is the best practice to join?
-
8
votes1
answer140
viewsPremises for a testable software
Based on development in object-oriented language, what would be the premises for software to have robust testability (coverage and testing facility) ?
-
8
votes1
answer452
viewsWhat is a type class "class Minhaclasseexample<T> Where T: new(){}"?
A class class ExemploClass<T> is a list? See the example class below: public abstract class MinhaClasseExemplo<T> where T: new() { public T value {get; set;} } Which means every part of…
-
8
votes2
answers881
viewsHow to avoid code repetition between classes?
To report on my application I have created several classes, and each class is responsible for a report, however, there is a repetition of a lot of code by those classes that I would like to avoid,…
-
8
votes2
answers2706
viewsHow to use vector to store a class?
Example: class Nome {private: string nome; public: Nome(string nome); virtual void exibirNome() =0; }; class SobreNome: public Nome {private: string nome; public: SobreNome(string nome, string…
-
8
votes2
answers653
viewsName collision between class and namespace
It’s wrong, bad practice or I might have problems with class like namespace? Example: namespace Cielo { public class Cielo { ... } } It’s been working, in some places it gets a little strange to…
-
8
votes1
answer331
viewsJava Point 2d code, does not display the distance correctly
package OrientacaoObjetos; public class Ponto2D { //campos publicos: nao existem restricoes p/ valores de x e y public double x, y; //constr. default: ponto definido na origem(0, 0) public Ponto2D()…
-
8
votes2
answers1212
viewsWhat does the application gain by using Type Hint?
In PHP 5 we know that the hinting type and now we can declare and force the type of parameter a function will receive. I believe it will help in the processing of the data more precisely, but what…
-
8
votes4
answers3477
viewsPrinciple of Delegation, what is it?
What Means Delegation Principle in Object-Oriented Programming? After some research, I found a definition about this principle: Principle of Delegation: way to make the composition as powerful for…
-
8
votes1
answer716
viewsIn Ruby on Rails is the business rule on the model?
In Java the business rule is in controller, but I heard a speaker saying that in Ruby on Rails the business rule is on model. Someone confirms that to me?
-
8
votes1
answer454
viewsIs it correct to say that encapsulation aims at cohesion? Why?
Based on the statement below, follow my question: Cohesion and Coupling are very software engineering principles used. When we want to have a mature and sustainable architecture, we must take these…