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
votes3
answers1207
viewsWhat’s the difference when calling a function with parentheses and without in.py urls with Django 1.7?
In mapping my.py urls I use from common functions to class-based views. I want to know the difference between calling the view with or without parentheses, given that if I have the input url(r'^$',…
-
3
votes3
answers294
viewsHow to relate category instance to a product instance in PHP
I have 2 classes in PHP, Product and Category. Following each other’s code. Product.php class Produto { public $nome; public $categoria; } Category.php class Categoria { public $nome; } In that…
-
3
votes1
answer335
viewsDo controllers necessarily need to be classes?
When we are developing a system using MVC from scratch, each controller needs to be a class or I can simply use a file containing some functions that will be called as the action sent by View?…
-
3
votes1
answer167
views -
3
votes4
answers142
viewsDoes calling dozens of classes in a system noticeably influence the performance of the application?
I’m starting to work with object orientation in PHP and would like to know if the amount of existing classes in a system can interfere in the performance of it or if it would have to be hundreds of…
-
3
votes1
answer1282
viewsHow to call builders with arguments?
How to define constructor values in the main class by Scanner in such a builder?. public Aluno(String nome,int idade) { this.nome = nome; this.idade = idade; } and in the main class call: Aluno…
-
3
votes1
answer367
viewsWhat does equals(Object o) mean in this method?
In that code: public boolean equals(Object o) { Aluno outro = (Aluno)o; return this.nome.equals(outro); } What’s he good for?
-
3
votes2
answers238
viewsGeneralization of parameters in Java
I am implementing a B tree for a database job in Java, so that it stores any kind of objects, be generic, so I am treating as if it were Object, but in some parts of precise code methods such as…
-
3
votes1
answer212
viewsHow to handle query results with PHP OO?
I’m creating a simple, photographic website, and I’m doing all the object-oriented PHP. I know PHP procedural, but I would like to mix PHP with HTML as little as possible. My connection and my query…
-
3
votes2
answers105
viewsData does not appear on the page
I made an OO code in PHP. I used Mysqli for the database and WAMPSERVER as the server, in which I entered data for the table "category". The collation of the bank is "latin2_general_ci". No errors…
-
3
votes2
answers402
viewsAbout Mysqli functions
I have a question about some function of Mysqli In the conventional way we would do so: public function Numrows($sql) { return mysqli_num_rows($sql); } And how I’m using extends mysqli I’m doing…
-
3
votes1
answer4507
views"error: 'string' does not name a type" when declaring strings
Follows the code class Nome { public: Nome(string nome, string sobreNome); void exibirNome(); virtual ~Nome(); protected: private: string nome; string sobreNome; }; Error error: expected ')' before…
-
3
votes1
answer234
viewsHow to override the remove() method from Iterator?
I created a repository (RepositorioObjeto) and it implements the interface Iterator on the object the repository stores (Iterator<Objeto>). So I had to override the methods next(), hasNext()…
-
3
votes1
answer561
viewsClass with more than one __constructor in PHP?
I was here studying a little more about builders in PHP. And I ran into some questions. 1 - It is possible for a class to have more than one constructor? 2 - If yes, how to know which one will be…
-
3
votes1
answer176
viewsComplex mapping Entity Framework
I am creating a class structure that follows the following form: Department -Service A department provides various types of service. A specific service can only be provided by one department, not by…
-
3
votes2
answers284
viewsHow to implement classes with private method?
I am rewriting the code of an application seeking the best use of interfaces and I came across a problem: I have a class that needs to have a private method and I want to create an interface for it,…
-
3
votes3
answers107
viewsDoubt about class inheritance in Java
I have the following code one ebook who inherits the class Livro (superclass). However, I can’t create a new ebook and set in name, when I put the main method (main) makes a mistake. Class Autor:…
-
3
votes2
answers918
viewsHow to cast a typed class in C#?
I own the class Carro who inherits from the class Objeto and another class CarroTeste implementing the abstract class TesteBase that by its implements the interface ITeste, both (TesteBase and…
-
3
votes0
answers35
viewsWhy do you put "var" before a class variable?
<?php classe Caneta { var $modelo; var $cor; } What does the var before the variable?
-
3
votes1
answer75
viewsWhen declaring an interface in the class, who should implement it?
class Gerente extends Funcionario implements Autenticavel { He meant that Gerente implements the interface Autenticavel, or Funcionario which will implement the interface?…
-
3
votes4
answers3476
viewsWhen do I actually need to use the this operator in Java?
It’s just that sometimes I think there’s no need to use the this, but as I just started to learn Java, I want someone to answer me when it will really be necessary to use the operator this?…
-
3
votes1
answer1465
viewsHow Pdostatement::fetchObject works
I am trying to set the values returned from a query to an object in another class as follows: public function select($id,Cliente $cliente) { $query = "SELECT * FROM compras WHERE id = :id AND email…
-
3
votes1
answer2388
viewsAccess attributes of an object vector of another class using C++ pointers
I am doing a job for the college in which I have to put together a program to manage a restaurant that only makes deliveries the orders are made by phone and internet using object orientation and…
-
3
votes1
answer811
viewsIs it possible to return the child class through a method in the parent class?
I’m making a Builder and I’d like you to behave as follows: abstract class ClassePaiBuilder { public ClassePaiBuilder SetAtributo(string atributo) { // codigo return this; } public string Build() {…
-
3
votes1
answer51
viewsCheck whether array is associative in a class
I have a class where I need to do certain checks on an array, such as checking whether it is associative or indexed. I know there is no native function in PHP that does this, so I could use the…
-
3
votes3
answers1689
viewsHow to make visual form inheritance in Windows Forms?
I have a form base that will be the form 'Dad, with three buttons on it. Add, Delete and Change. I’m gonna use the formbase to standardize my registration screens, so each registration screen when…
-
3
votes2
answers125
viewsImplementing relationship in C#
I have the following classes: The code is like this: public class Mae { public string Nome {get; set;} public List<Filho> Filhos {get; set;} } public class Filho { public string Nome {get;…
-
3
votes1
answer149
viewsIn what order does a class inherit from its python superclasses?
Be the code below: class B(A): def __init__(self): self.c = 16 def y(self): print("B.y") def get_c(self): return self.c class C(object): def __init__(self): self.c = 5 def y(self): print("C.y") def…
-
3
votes2
answers329
viewsselect Pdo com oo
I have this class that manages the database : <?php abstract class database{ /*Método construtor do banco de dados*/ private function __construct(){} /*Evita que a classe seja clonada*/ private…
-
3
votes1
answer141
viewsIs there a pattern similar to Singleton?
It’s really frustrating, a little interesting maybe, but frustrating above all, just yesterday I figured out how and why to use the pattern Singleton, And today, as I was about to finish a little…
-
3
votes1
answer3368
viewsImplement Runnable or Thread Extension?
In several Java projects, I’ve seen these two ways to create Threads: With implements Runnable: public class MyRunnable implements Runnable { public void run() { //Código } } //Iniciada com uma…
-
3
votes1
answer150
viewsPHP Error return function
I have the following class with the methods: <? class minhaClasse extends database { public function funcao ($iduser) { $date = array($iduser, '1'); $sql = "SELECT * FROM `tabela` WHERE 'iduser'…
-
3
votes3
answers2030
viewsHow to create an empty object in PHP?
With an array you can do this: $arrayVazio = array(); $arrayVazio[key1][var1] = "PHP"; It is possible to do this with an object: (object)$objetoVazio = ""; $objetoVazio->key1->var1 = "PHP";…
-
3
votes2
answers9108
viewsHow to insert multiple values into an array?
A student can take several courses such as "English", "Portuguese" etc. How do I put multiple course names in one array? I don’t want to set an example with ArrayList. It’s just to take a question…
-
3
votes2
answers30
viewsUse of Class.apply in the context of a specialized class
I saw an example that dealt with Class father and Class daughter where, at the beginning of the specialized class, it was like this: var ClasseFilha = function ClasseFilha (){ ClassePai.apply(this,…
-
3
votes2
answers3704
viewsHow does the equals method work?
I stopped in an exercise of a book I’m reading and in this shows an example of overloading the method equals, I even understood the concept that he compares the reference between two objects, but in…
-
3
votes1
answer302
viewsWhen to use Exceptions in PHP?
I arrived in a module of the OOP PHP workbook on Handling Exceptions, I practiced the exercises and such, but I’m still not quite sure when I should use them, and why. I did a search and found this:…
-
3
votes2
answers876
viewsIs it possible for me to create a runtime class in Python?
I wanted to create a runtime class to do some database updates, for example, but without being dependent on DBMS but using python and I wanted to know if it is possible to create these classes at…
-
3
votes2
answers496
viewsBusiness rules should be in the Entity in the DDD enclosure
Following the DDD (Domain Driven Develop) methodology, my question is whether the Entity class should receive any business rule. Just imagine the situation: We have a Carfactory responsible for…
-
3
votes4
answers543
viewsVariables operating in more than one method
I tried to make a simple console calculator, only I wanted to create several methods to make it well organized. The problem is that in the method of storing the variables, it stores, but when it…
-
3
votes1
answer9873
viewsHow to create a class with attributes and methods in C++?
In Java I know how to do it, but in C/C++ it’s little different so how to create a class with attributes and C methods++? I am using Codeblocks. When I create a class in C++ it creates two files one…
-
3
votes2
answers679
viewsUse of instanceof
Create an abstract class Conta, and two other concrete classes ContaF and ContaJ inherited from the main class. Create another class with a method that receives a list of contaF and ContaJ and…
-
3
votes1
answer1470
viewsTest connection with Phpmailer
I’ve been working with Phpmailer for a while, now I’m inserting it into a more complex Content Manager and through the panel one can insert several emails to be the Phpmailer Sender in several…
-
3
votes1
answer369
viewsWhen my class returns a modified new instance of the class itself instead of modifying it itself, is it a project pattern?
I’m developing a class that is a collection of values. In it I have several methods that filter the values contained in this collection. My intention is to return a new instance of this same class…
-
3
votes1
answer283
viewsWhen and why to use a parameterized constructor?
I am very confused. I wonder if it is better to use the default and setters to assign a value to the attribute, or if it is better to assign the values to the attributes via the parameterized…
-
3
votes1
answer277
viewsKnowing which class of daughter the parent class points to
I came from Java and I have a question about polymorphism in C++. Given these classes: class Empresa{ vector<Pessoa> pessoas; int empregados; addPessoa(Pessoa* p) } class Pessoa { ... }; class…
-
3
votes1
answer113
viewsController needs to be a class?
The controllers within an MVC, must they be classes? Because from what I’m seeing here, their only function is to take the information that the view You’re asking, play for model "solve the problem"…
-
3
votes1
answer3270
viewsStep by level in binary tree
Description of the problem I need to solve: "A level walk on a tree, first list the root, then all nodes that are at level 1 then all nodes of level 2, etc. Write a procedure to list the nodes of a…
-
3
votes2
answers70
viewsSet values inside or outside the method?
I’m studying about passing parameters in PHP. I want, for example, to use a certain method that needs to receive two values, I have the following codes: Example 1 In the class: class Exemplo {…
-
3
votes1
answer421
viewsHow do I access the contents of a Jtextfield?
In a java project no connection to Database where we have only the layers Model, View and Controller, what would be the most appropriate way to catch a String which is contained in a JTextField of a…