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
-
3
votes2
answers85
viewsClass declaration in Java
I can declare more than one class in the same Java file, and if this is possible, it is the most correct way to program in this language?
-
3
votes1
answer994
viewsDifference between type inheritance and implementation inheritance
My teacher passed a booklet on Object Oriented Data Structure with Java and in the booklet there is an excerpt (without deepening) that says the following: "Interface promotes heritage of type and…
-
3
votes1
answer141
viewsWhat to test/implement in a viewmodel?
I am trying to implement a standard MVVM (Model - View - Viewmodel) that is related to MVP. Since Viewmodel, by my understanding, is responsible for "passing" the data from the View layer to the…
-
3
votes2
answers144
viewsHow to implement polymorphism correctly?
One of the first things we hear about when we study the object-orientation paradigm is polymorphism but how can we or "should" implement it, since it’s a concept we see various forms of…
-
3
votes1
answer73
viewsIs it wrong Methods to show something to the user?
Well I’m starting now in the area of Opoo, I saw in a class I’m watching on youtube that it was wrong Methods write something on the screen, and how I would show if something bad happened in a…
-
3
votes2
answers444
viewsMVC + DAO - Which way should I choose in PHP?
In Java, in the model class I can create in the class funcionario the attribute Setor s, but PHP is not typed, as I could solve this association case? After some searches here on the site, I saw…
-
3
votes2
answers843
viewsOverwrite methods based on name only
I’m creating an abstract base class to provide a pattern for other classes. The base class methods shall be superscripted in the derived class. Now comes the cat jump. The superscript should happen…
-
3
votes1
answer514
views"toString()" returning Null when it should not
I have the class Aluno. public class Aluno { private String nome; @Override public String toString() { return this.nome; } //metodos getters e setters } Class Vetor public class Vetor { private…
-
3
votes2
answers425
viewsUse delete on allocated objects without new?
Hello, from always until today in my c++ projects with Qt, I have always used delete objects only when I dynamically allocate them with the operator new, But in my last project that was relatively…
-
3
votes1
answer554
viewsClass or the Enum?
I am designing a C# RPG game and found a design decision problem and need help to find the most flexible way to implement the desired. I’ll explain a little bit about the project: There are some…
-
3
votes3
answers182
viewsAccess modifiers in PHP
Does it make sense that I create a class, define three functions, two public and one private, and make the private function be accessed through the public method? Example: class Pessoa { private…
-
3
votes2
answers988
viewsDeclare public variables in the __Construct method
Note the example of the method: <?php #noticia_construct.class.php class Noticia{ public $titulo; // Acredito que não seja necessário public $texto; // Acredito que não seja necessário function…
-
3
votes2
answers383
viewsAbout method chaining. Why are you giving nullPointerException?
I got the class Request: package teste; import java.util.ArrayList; import java.util.List; public class Pedido { List<Item> lista = new ArrayList<Item>();; Cliente cliente; public Pedido…
-
3
votes1
answer219
viewsWhat is the "real" meaning of the key word 'extends' in Java?
First of all, I know how to use and work the keyword extends, my real doubt lies in the meaning of that word, more precisely because extends and not inherit or something like that? The only thing…
-
3
votes2
answers1007
viewsHow do I display what’s on the list?
I have this method that adds things to the list: public Pedido adicionarPedido(int quantidade, String nome){ lista.add(new Item(quantidade, nome )); return this; } And I’ve entered that class into…
-
3
votes1
answer454
viewsShould I use abstract class or interface?
I have a class that connects to Windows machines. I’m making it a little more generic so I can repurpose it to other systems. Soon I was able to identify four methods "generic": connect status…
-
3
votes1
answer191
viewsHow to show data from two tables in c#?
I built a webservice in c#. With a table it was easy to display but what if I have two tables how would it look for me to display this data? I did so it’s the easiest way: [WebMethod] public String…
-
3
votes2
answers88
viewsI cannot invoke a Setter or getter in Javascript
I was doing some object orientation exercises and in the solution the teacher used set and get. I realized that even if I do it like the teacher, it doesn’t work. I can solve it without get and set,…
-
3
votes1
answer1021
viewsI would like to understand the use of an DTO with an Entity
I wonder if my reasoning is correct regarding the use of a DTO Following this logic, I am correct in using a DTO? @Controller @RequestMapping("/") public class CadastroController { private final…
-
3
votes2
answers276
viewsHelp with Java Exercise
I’m having a little problem in a JAVA exercise, I can’t fix it, although I’m pretty sure it’s pretty simple. It’s a simple crud: Below is the main code import java.util.Scanner; public class Crud{…
-
3
votes2
answers60
views -
3
votes0
answers57
viewsWhat are the disadvantages of immutable objects?
It is notorious the advantages of immutable objects, such as: they are more reliable because they are never changed; they are thread-safe, as they have no problems with synchronization when several…
-
3
votes2
answers675
viewsRequest a form with Standard not working
I’m making a request from my controller for a form in the view, is giving this error. I tried several methods, but none solved. Controller: public function store(Request $request) { $NomeDaEmpresa =…
-
3
votes1
answer165
viewsShould I create a class for each "input", or are only methods of a "form" class enough?
Well, I’m having a logical question. I started learning PHP OO recently, so this question is more for educational purposes than anything else. My goal is to create a class "form" that will build…
-
3
votes1
answer998
viewsException class creation and implementation
I am having problems implementing an Exception class. The explanation of the program is: Vector strings must be initialized with "", not null. The vector capacity shall be capable of being changed…
-
3
votes1
answer104
viewsIs there any relevant difference between "Object-oriented programming" and "Class-oriented programming"?
I was reading a post that member @Maniero indicated, and I came across a response from another member that raised more questions and decided to search. In the answer was the following phrase:…
-
3
votes2
answers3386
viewsHow to call a nonstatic method within a static class?
I have the following method/function and need to call the method/function criaTimerTendencia that is within the class TagAnalogicaAtiva. private static void VerificaEnvioDeMensagensSignalR(object…
-
3
votes1
answer462
viewsAlternative to multiple inheritance
It is not possible to inherit more than one class in C#, so I come here looking for suggestions for my problem. I am building a small game using Unity. In Unity the game objects (GameObject) inherit…
-
3
votes1
answer84
viewsNavigation Properties - Domain-Driven Design
Hello, I am studying DDD and came across the following question: There is the Aggregate (Aggregate), a set of related objects that have an Aggregation Root (Aggregate Root). So far so good, I…
-
3
votes2
answers447
viewsPython assignment and OO
Studying about object orientation in Python I was told that a difference of such language in the instance and assignment of a class is, when we do Darth = Pessoa ( 'Darth Vader' ) The name / surname…
-
3
votes1
answer171
viewsHow to do mathematical operations with a struct?
I have the following structure: public struct vetor { public float X, Y; public vetor(float X, float Y) { this.X = X; this.Y = Y; } } And this code: Vars.vetor _visao; Vars.vetor _recoil; //Os 2…
-
3
votes2
answers59
viewsHow to change the way a class/structure is printed?
I have the following structure: struct cores { int r, g, b; public cores(int r, int g, int b) { this.r = r; this.g = g; this.b = b; } } If I had a new structure printed, it would look like this:…
-
3
votes1
answer2575
viewsInheritance with builders
I need to create a base class animal and 3 other hereditary classes of other animals. Each class must have its own function emitirSom. They should be invoked polymorphically through a vector. I…
-
3
votes0
answers103
viewsForce sequence of methods to have their call set to default?
I have a framework that is used basically in building forms and events HTML/jQuery with PHP, an example call: $VIDB_input = new \vidbModel\inputElement(); $documentos_date_action = 'triggered';…
-
3
votes1
answer434
viewsHow are modifiers implemented in Typescript?
Typescript supports all functionality present in Javascript (proper Ecmascript 6), and has modifiers such as: private, protected and abstract. However, in ES6 there are no such modifiers. To…
-
3
votes2
answers204
viewsBetter structuring of object-oriented code
I came across a problem with code structuring and I needed some help. I made a diagram below with two different methods of structuring the same code (I couldn’t create the code yet) and wanted to…
-
3
votes2
answers169
viewsOnly one class can instantiate another class, how do we do that?
Hi, I’m doing an UML on an exercise, but I can’t do a part of it. The exercise says that only the administrator class can create another contributor, I wanted to know how I could implement this.…
-
3
votes1
answer106
viewsClass definition within a function or another class
I’ve seen in some scripts definitions of classes within other classes or functions like this: class Grok(object): class Foo(object): ... ... What is the reason for this practice? It is only to not…
-
3
votes2
answers148
viewsHow do you model a role in object orientation?
How one normally models a role (role) object-oriented? It is by means of a composition, correct? For example, to model that a Pessoa executes the paper of a Cliente or Fornecedor, it is modeled that…
-
3
votes1
answer1994
viewsHow to resolve "Fatal error: Uncaught Error: Class 'User' not found"
I created this class (starting now with POO) in the file Funcionarios.php, there it works: class Funcionario{ public $departamento; public $salario; public $dataEntrada; public $cpf; public function…
-
3
votes1
answer101
viewsWhy is the "private" access modifier letting me change the attribute outside the class?
Well, I have this class with the attributes private class Conta { int numero; // Atributo private double saldo; Cliente user = new Cliente(); private double limite; } From what I understood of the…
-
3
votes1
answer511
viewshow to import classes referencing each other in python?
I have a problem when it comes to importing classes into Python. See, there are 4 files: main: from classeB import ClasseB ClasseB() class A: from classeModelo import ClasseModelo class ClasseA():…
-
3
votes1
answer92
viewsDoubt about Python classes and attributes
I have a question about classes, attributes and objects in Python. For example using the class below: class Car: drivers = ['João', 'José'] def allowed_drivers(self): print('The list of allowed…
-
3
votes1
answer118
viewsCompiling an inherited class in C++ gives constructor error
I need to create a class for chess pieces. I created the class Peca and her derivative, Bispo. When I try to compile the bishop class, the compiler returns reset error. How can I resolve? #ifndef…
-
3
votes1
answer134
viewsVariables and methods in the abstract class, where to put?
Cliente and Fornecedor has name, phone and email in common what is the best way for me to treat this, should I create these variables in common in the abstract class? or is there a better way for me…
-
3
votes1
answer116
viewsProblem to use a "System.out" on an object
I’m trying to give a System.out.println on an object I have (even with the toString() in class) I’m getting: Predio [name=LS, aptos=[[Lmodel.Apartamento;@7ba4f24f, [Lmodel.Apartment;@3b9a45b3,…
-
3
votes2
answers1285
viewsHow to define private attributes in a constructor function using javascript
In javascript we can have the constructor functions that are of type Function, with them we can instantiate objects as in the following example: function Pessoa(nome="Usuário Anonimo", idade = 00,…
-
3
votes1
answer86
viewsIs it correct to use a static method of an abstract class?
During a work assignment I came across the need to use an abstract class method to avoid code duplication. In this case, I came to a question whether it is correct to use a method of a class, which…
-
3
votes1
answer117
viewsHow to access static methods of a class included in the consign in Nodejs?
Hello. I am building an application with nodejs and I need to authenticate users by registering a new user and logging into the application. I’m using consign to perform autoload of my scripts, as…
-
3
votes1
answer81
viewsIs it correct to use an object to call a method where it will be the parameter?
I am creating a small project in without Entity Framework and I have a question at the time of passing an object as parameter, it is correct to pass the same object that calls the method as…