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
-
2
votes3
answers346
viewsHow to make a polymorphic pointer with the this pointer in the parameter?
For example, in Qt (correct me, if the logic is wrong, I haven’t touched Qt in a while), you can do this: QLabel label = new QLabel(this); Now let’s suppose: #include <iostream> class…
-
2
votes2
answers238
viewsReturn values through a class derived from the same Parent
I have classes 1, 2a and 2b, where 1 is the main class, while 2a and 2b extends class 1. It is possible through class 2a to access values of class 2b directly or through the parent class? Basic…
-
2
votes2
answers4223
viewsDynamically create PHP class instance with Namespace
$class = ucfirst(strtolower($_GET['type'])) . "Controller"; include $class . ".php"; $item = new $class(); But I put the class name without being dynamically, for example: $item = new…
-
2
votes2
answers211
viewsDoubt about inheritance in classes
How to do the if controller return TRUE or FALSE in accordance with the check() of the Validator? Currently it returns boolean to the validate();, but I wanted it to continue until the end of the…
-
2
votes3
answers308
viewsUse of `self->` instead of `self. `
I am working on an app that was not I who started the code and I am having problems regarding the use of the command self->. At some point of the code I’m finding variables declared with…
-
2
votes3
answers5189
viewsHow to pass editText value to attribute to int type on Android?
I have a question about the value store coming from EditText for attributes of type int of a class. For attributes of the type String I do so:…
-
2
votes2
answers527
viewsArraylist in JAVA
I have a question about Arraylist Example: I made a graphical interface in Java to register players in a ArrayList. after registration, the player goes to a Jlist, Here comes my doubt. I want to buy…
-
2
votes2
answers2412
viewsHow to implement an abstract method in a daughter class?
I abstracted a method from an abstract class as well. But I’m not sure how to implement this method in the daughter class. Here’s my code, what I fix? using System; using System.Collections.Generic;…
-
2
votes2
answers765
viewsTips for turning procedural code into object-oriented?
I have a system that is totally procedural style, and I want to know what are the points I need to identify to turn this code into object-oriented.
-
2
votes3
answers4201
viewsFire an event using pure Javascript
I would like to know how to dispatch an event using Javascript. I tried using the following code: var atual = document.getElementById('teste'); atual.addEventListener('mouseover', function(){…
-
2
votes1
answer91
viewsHow to add concrete elements in Runtime in the Visitor project pattern?
I have a question regarding Design Pattern Visitor. From my studies, if you want to add a new concrete element to the pattern you should add a new abstract method in the Visitor interface and…
-
2
votes1
answer168
viewsWhat does Runtime dependencies of Objects mean?
What is the meaning of Runtime dependencies of Objects in object-oriented programming? I came across this question by studying C++.
-
2
votes2
answers725
viewsOrganization of projects in packages
I am doing a study on Java and would like to learn without using those Ides full of resources that do everything. After several attempts to learn how to use packages by creating them manually, one…
-
2
votes1
answer727
viewsWhat is the difference of implementing classes in C++ and PHP?
I am currently working in PHP and realized that when implementing classes I can’t just instantiate and then implement below the class using the scope selector ::. Example: class Lista{ public:…
-
2
votes1
answer240
viewsGeneric Locate Method, using ADO.NET and Procedures
I am looking for a solution from a generic repository to a DAL with a generic Find method, so there is no redundancy in my code. Using ADO.NET and Procedures. I found something in this link: What…
-
2
votes1
answer372
viewsProblems with RBAC permissions modeling
I’m developing a system where your user permissions will be based on the RBAC model, a user could be in several permissions rules that would give or not privileges to the system, when registering a…
-
2
votes1
answer451
viewsObject and pointer allocation
How do you allocate a pointer, which points to a class, and an object? Is there a difference? Size, etc
-
2
votes1
answer1412
viewsHow to instantiate an object of this class in C#
I’m reading Caelum’s booklet about C# and object orientation, so I put it in Account.Cs the following code: namespace Banco { class Conta { public int numero; public string nome; public double…
-
2
votes2
answers713
viewsHow to instantiate primary key in another MVC class?
I have the class Funcionario and Projeto. They both have their Ids. I want to create a class ProjetoFuncionario and would like to instantiate the primary key of the two in this class. How can I?…
-
2
votes1
answer296
viewsGridview with only one line - Asp.Net C#
I have a column in Gridview with Schedules, I made a scheme that takes from such an hour to such an hour for example: 8:00 to 8:30 and so goes to other lines. In all, until 6:00, that’s 20 lines.…
-
2
votes1
answer1754
viewsHow to modify or set a value within the class in php
I have a class in the php and need to modify the value of private $key = "valor"; out of class. How can I change the value of $key out of this class? The value I want to put in $key comes from a…
-
2
votes1
answer130
viewsWhen using recursion method returns 0
I have the following code: public int lerInt() { String entrada = ""; int saida = 0; try { entrada = input.readLine(); } catch (IOException e) { System.out.println("Falha critica."); } try { saida =…
-
2
votes1
answer628
viewsHow to use variables in a location outside the scope where they were created?
I have the following code: public class TracoActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);…
-
2
votes1
answer210
viewsWhat is the purpose of modifying protected access in Java? In what situations should I use it?
Regarding access modifiers in Java, what is the purpose of the modifier protected? What is its purpose in practice?
-
2
votes1
answer235
viewsImplement Interfaces
I have the abstract class ClasseA and 2 child classes ClasseB and ClasseC, then I have an interface IClasse which is implemented in ClasseA and ClasseB. In the interface I have the method metodo1…
-
2
votes2
answers153
viewsAlternative to the use of new when implementing methods that return this in child classes
Taking the example of the following code: public class Pai { protected string PropriedadeA { get; set; } public Pai Metodo1(int valor) { //Vários procedimentos feitos aqui PropriedadeA = "Resultado…
-
2
votes1
answer144
viewsNullpointerexception occurring
My teacher uses the technology of EasyAccept as validation of errors. In one of the tests it is necessary to use Exception. In the code below, I managed to treat in a way that I THINK is…
-
2
votes2
answers439
viewsStore modified class properties
I need to have stored in the class itself a list with (name and value) of the changed properties. However, I don’t know if the form I am using is feasible. I have the class Employee below: public…
-
2
votes1
answer508
viewsPOO using Django
I’m starting to work with Django, but I’m having some doubts about how to organize my project, I would like to know the best way to structure my projects. I’m used to the languages in which I model…
-
2
votes1
answer137
viewsHow can I make an object if 'auto-delete' in Javascript?
I tried something like: function Objeto(){ this.del = function(){ delete this; } } var a = new Objeto(); a.del(); But the variable a is still existing I know the method quoted in the @bfavaretto…
-
2
votes2
answers6962
viewsPHP How to pass attribute values between classes
I have two distinct User and Comment classes, I use the Comment class to record the comments in the bd, but I need the user attribute that is in the User class that is in the getUsuarioId() method.…
-
2
votes1
answer205
viewsFree access to database table data for third party system
Is there any way to free access to reading a specific database table for a third party system? For example, I have a table called "customers" and a competing system has an efficient ticket issuing…
-
2
votes2
answers105
viewsWhat would be a parameter call before the string in a function
I’ve seen it done over and over again: interface LoggerAwareInterface { public function setLogger(LoggerInterface $logger); } Put a parameter before the variable, in which case what it would be and…
-
2
votes1
answer97
viewsDecrease responsibility of a class
I recently had the need to work with object-oriented sessions and created the following class: https://github.com/mateusdemboski/PHPsessionManager/blob/master/src/Session.php <?php /** * @author…
-
2
votes1
answer87
viewsImplement a vector that accepts anything
I have to implement an array that is capable of storing objects of any kind. For example: V[3]= valor_int,valor_double,valor_float,valor_String. To do this I was thinking of creating a method that…
-
2
votes1
answer119
viewsIs it possible to implement an abstract class in PHP without the need for inheritance as in Java?
It is possible to perform the class instance in PHP "in the same way" CachorroAbstract in the method main down below: public abstract class CachorroAbstract { public abstract void latir(); } public…
-
2
votes2
answers557
viewsQuestion about initialized attributes in the constructor in Java
package Livraria3; public class Livro { private String nome; private String descricao; private double valor; private String isbn; Autor autor; public Livro(Autor autor) { this.autor = autor;…
-
2
votes1
answer41
viewsMethod returns instance, after setting property
There is a name for the practice or pattern, for this code snippet? Example: <?php class Pessoa { //... public setNome($nome) { $this->nome = $nome; return $this; } //... }…
-
2
votes1
answer307
viewsWhy in set methods in C++ do I have to use the parameter as a reference?
I took this class Pessoa as an example: public class Pessoa{ private: string nome; public: string getNome(); void setNome(const string &nome); }; My question is: why should I use a parameter by…
-
2
votes2
answers220
viewsHow to create an object with two or more instances in Javascript?
In Javascript I know that it is possible to create an instance of a class using 'new' new Classe And how to create an object that is instance of several classes? For example new Classe,…
-
2
votes1
answer266
views"Undefined Reference" in the constructor of a C++ function
I am creating a VS1838B name class that is composed by other instances. This is the class header: #ifndef INFRAREDRECEIVERVS1838B_H #define INFRAREDRECEIVERVS1838B_H #include "Arduino.h" #include…
-
2
votes1
answer63
viewsIs there a way to create a private class in C++?
I wanted to create a class where it could be accessed in the library that I created, how do I declare the class as private and can be called only in the library?
-
2
votes1
answer1061
views -
2
votes1
answer150
views -
2
votes1
answer79
viewscapture input text javascript value
So you guys I’m studying oop in javascript to crawling still, for this I’m trying to add on my site elements dynamically through js I am wanting to capture the value of my text field and when I…
-
2
votes1
answer62
viewsValidate method name by suggesting the correct one
I am using a framework email library class Nette. Then at some point, instead of calling the method setSubject - which is the correct method, I called addSubject, because I had forgotten the name of…
-
2
votes1
answer337
viewsWhat is the function of the __wakeup magic method in php?
I read the documentation, but it wasn’t very clear. __wakeup() reestablishes connection to the database? For example, I have a script that runs for quite a while, there comes a time when the…
-
2
votes1
answer1120
viewsInsert with Pdo and OO
I have the following class that manages bank : <?php abstract class database{ /*Método construtor do banco de dados*/ private function __construct(){} /*Evita que a classe seja clonada*/ private…
-
2
votes1
answer67
viewsShould all inherited attributes be used?
I am constructing a class diagram, where several classes have 3 equal attributes, and one or another class has only 2 of these attributes. So I thought I’d create a parent class with all these…
-
2
votes0
answers115
viewsPOO list records
Hey, guys, which of these ways is best to list the bank records? The first is the structured way and the second is the object oriented is not? Thanks. First: $sql = $usuario -> listar();…