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
-
4
votes2
answers658
viewsIn C++ what is the command corresponding to Java super()?
In Java: public class Teste extends Testando { private String nome; private int numero; public Teste(String teste, String nome, int numero) { super(teste); this.nome = nome; this.numero = numero; }…
-
4
votes1
answer1345
viewsNamespace and PDO = Error
I am making a Framework using namespaces. However in PDO connection file there is a strange error for me: Fatal error: Uncaught Exception 'Pdoexception' with message 'could not find driver' in C:…
-
4
votes0
answers52
viewsObject and Procedural Oriented Programming in PHP at the same time
Guys I have a PHP system that I have been developing for over a year. It was written practically procedural, because I adapted better, and I find it simpler to work. My question is the following:…
-
4
votes1
answer551
viewsHow to do multiple inheritance in javascript
I’ve seen a lot of ways to do it inheritance in javascript, but do not know how to do inheritance-multiple I will demonstrate an example of the problem: function Transporte() { var nome;…
-
4
votes1
answer1794
viewsHow can I check if an object exists in the dictionary and return it
I am working on a solution in which I must enter on the same function with a given name of a Park. The parks are implemented in a list and each park has a name. It happens that I intend and already…
-
4
votes1
answer92
viewsHow does one method work within another? E.g: service.metodo(arguments). execute();
I’m not understanding this method within another method someone explains it to me? Another example of my doubt: ImageKeywords keywords = service.getImageKeywords(image, forceShowAll,…
-
4
votes2
answers882
viewsWhat is the importance of using java interfaces or c#?
I know how to implement and use interfaces, but I can’t understand what the real reason for them is in c# or java, since once you extend your class to an interface you need to implement all the…
-
4
votes1
answer238
viewsData Source - Best way to organize methods/classes pertaining to the entire table?
In my company we work with models based on the "Active Record" standard, that is, the model methods are always related to the operations of a unique database record, for example: Class User { int…
-
4
votes3
answers670
viewsHow to sort sql queries in the RUBY on Rails model?
I have the following method an ROR application. query_student = "SELECT name, registration, room FROM students WHERE registration = "+ params[:registration]+" AND password = "+params[:password]…
-
4
votes1
answer3427
viewsStatement const at the end of function in C++ and const before argument in method
I came across this piece of code in a material: class Foo { public: int Bar(int arg1) const //<-- qual função do const aqui? { // código a ser implementado aqui } }; [1] Like the const affects…
-
4
votes2
answers1010
viewsDoes the use of traits replace the role of multiple inheritance?
What happens if I use in a class two traits different, and both have a method with the same name, but different implementations in this method?
-
4
votes1
answer890
viewsPass data in php constructor to class
I have a question of how to send the data to create a goal, I read in some tutorials that was just put this way in PHP4: $elo1=new Elo(1300); $elo1->fc_Elo(); However the way I saw in some places…
-
4
votes1
answer92
views -
4
votes2
answers607
viewsWhat is the difference between initializing a constructor or doing attribution within the constructor?
What is the difference between the two examples below? I should also assign the value within the constructor in this class even if I initialized? example 1: class sof{ int teste; public: sof(int t)…
-
4
votes1
answer57
viewsHow to initialize objects already declaring values?
For example in this code: public class Main { public static void main(String[] args) { Point p = new Point(); } } class Point { int x; int y; } There is a way to declare values to x and y while…
-
4
votes3
answers158
viewsHow to reuse the connection in the subclass?
Colleagues, I have a connection class: class Conecta { private $Servidor = '127.0.0.1'; private $Usuario = 'root'; private $Senha = 'senha'; private $Banco = 'banco'; // Protegido protected…
-
4
votes3
answers122
viewsWhy does the code print 0 instead of 5?
Why does this code print 0 instead of 5? class B { private int b; public int getB() { return b; } public void setB(int b) { b=b; } } class A { public static void main (String[] args) { B b = new…
-
4
votes2
answers180
viewsChange of object in inheritance
I have the following classes: class Funcionario { } class Coordenador : Funcionario { } class Gerente : Funcionario { } There a certain moment a Coordinator can become a Manager. How to solve this?…
-
4
votes1
answer99
viewsTransform class with static methods into interface
I have a custom class calling for ArrayList, I created to handle objects in a small project of mine, but I’d like to abstract it further, transforming it into an interface. In this way, I could…
-
4
votes4
answers4957
viewsCall static class method by static variable
In the PHP documentation, found that code in relation to the target resolution operator :: <?php class OutraClasse extends MinhaClasse { public static $meu_estatico = 'variável estática'; public…
-
4
votes1
answer195
viewsTDD improves the design?
Some people say that TDD (Test Driven Development) is responsible for improving design of the project classes. Others say this does not happen or is not necessarily true. TDD by itself, without any…
-
4
votes0
answers51
viewsWhy is it recommended to encapsulate in POO?
Would you have small examples to show me? To understand why? I’m studying PHP, but it can be in any language.
-
4
votes1
answer310
viewsAbstract class and C#properties?
Hello, everyone! Next, I created an abstract class called Tables, where classes of basic tables of the system will inherit from this abstract class. As Neighborhood, City, States, category, etc..…
-
4
votes1
answer173
viewsInitialization of attributes
Is there any difference between initializing an attribute like this: public class Turma { private List<Aluno> alunos = new ArrayList<Aluno>(); } Or so: public class Turma { private…
-
4
votes2
answers6999
viewsWhat is generalization and specialization?
In POO, what is generalization and specialization? Would there be some explanation in some technical way and a not so technical way? Simpler to understand, etc.
oopasked 7 years, 6 months ago Lucas de Carvalho 6,427 -
4
votes1
answer142
viewsModifications to model and relational database
The requirements for the development of a system in general change over time. Several approaches to software development such as agile methods and Domain-Driven Design even encourage an iterative…
-
4
votes3
answers1519
viewsWhat is 'final' in PHP?
I was at Github and I came across a class this way: final class Noticia { [...] } What use is this final reserved word? -Can only be used in classes?…
-
4
votes1
answer167
viewsAdd elements to a List<? extends Number>
Why it is not possible to add elements to a list of type List<? extends Number>? for example : public class GenClass{ public static void main(String args[]){ List<? extends Number>…
-
4
votes2
answers1404
viewsWhat’s the "self" for?
I am studying Python to complement my programs in Nodejs. But why in Python, a language that values the speed of development and ease of code, is used the self? Simple self use example class…
-
4
votes1
answer1193
viewsCreate class inheritance
I am studying object-oriented Java programming and need to perform the following exercise: Implement the class Funcionario and the class Gerente. Create the class Assistente, which is also a…
-
4
votes4
answers569
viewsIn Object Orientation, does an inheritance violate encapsulation?
According to the book Design Standards written by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides, make a statement: "...inheritance violates the encapsulation." Below is the paragraph…
-
4
votes2
answers2263
viewsModeling for comprehensive entity registration
I am creating a registration modeling in the most comprehensive way possible. Entities are Person, Natural Person, Legal Entity, Supplier and Customer Below the entity person. I add the person the…
-
4
votes1
answer344
viewsDifferences in constructors using property vs field (field)
namespace WMB.CieloB { internal class FuncoesCielo { internal FuncoesCielo(int iDC, Boleto boleto) { IDCliente = iDC; this.boleto = boleto; } public int IDCliente { get; set; } internal Transaction…
-
4
votes3
answers138
viewsIn structures (struct) is it necessary to use getters and setters or only in classes (class)?
It is necessary to use setters and getters in structures to maintain good practice or is needed only in classes?
-
4
votes1
answer270
viewsWhat is the difference between mixins and inheritance?
Conceptually, there is a difference between a class that extends a module by mixin and a class that inherits another class (unique inheritance)? I know why mixins, a class can extend multiple…
-
4
votes2
answers110
viewsIs it wrong to have a class with only methods?
Is it wrong to have a class with only methods? Or would it be better to use namespaces to hold office?
-
4
votes1
answer349
viewsHow to implement a destructor in Javascript?
In languages such as C++, we have the possibility to declare a destructor for a class, so that certain actions are performed when an object of that class is destroyed. How to do this in Javascript?…
-
4
votes1
answer55
viewsHow to handle requirements that "mix" domain and interface?
Whenever I develop some software I try to leave the domain model without being influenced by issues relating to the other layers of the application like technologies in general and interface issues.…
-
4
votes1
answer192
viewsParallel Processing Routine C#
I would like to start a data processing method whenever I receive a String with START content through the Transceiver event.Receivelineeventhandler(); but this method will have a processing time as…
-
4
votes1
answer119
viewsError: in Builder cannot be Applied
I’m developing a simple calculator. I am checking if one of the fields is null open a Alertdialog, however I am with the error in Builder cannot be Applied, no this do Alertdialog.Builder. Can…
-
4
votes2
answers3574
viewsAbstract Python class, how to choose implementation
I’m learning python and trying to make a program where I have an abstract class and two subclasses that implement such. I need to make another class that will choose which implinking to use…
-
4
votes3
answers3129
viewsHow to list the properties of an object in php using foreach?
I have the following class: class Usuario{ private $nome; private $profissao; function setNome($nome){ $this->nome = $nome; } function getNome(){ return $this->nome; } function…
-
4
votes2
answers137
viewsIs it possible that a class attribute is the class itself?
I’m starting to learn C++ Object oriented, and I have to make an algorithm using chained lists. In C, I used a structure that had as one of the attributes a pointer to the structure itself. I wonder…
-
4
votes2
answers72
viewsVisual Studio 2015 says "this" is redundant
In the early days of my first object orientation classes I was taught to use the thiswhere it is a variable or class property. Today I understand when there is a real need to use, for example when a…
-
4
votes1
answer75
viewsWhen to use local classes in Java?
I learned that it is possible to declare classes within blocks as methods, for example: void exemplo() { class teste { } } But when local classes come in handy?…
-
4
votes1
answer395
viewsUML aggregation X composition
Studying associations in UML ( aggregation and composition) I realized that the difference between them would be only the existence or not of the parts without the whole.…
-
4
votes1
answer62
viewsWhat would be the 'right' way to declare variables in PHP OO?
I’m starting to study O and fall into the following doubt: <?php class Caneta { var $modelo; var $cor; var $ponta; var $carga; var $tampada; } OR SO: <?php class Caneta { public $modelo;…
-
4
votes3
answers180
viewsHow to use repeated methods?
I have some methods that I use in various points of the applications and I end up having to copy in each class. For example: String getStringOrEmpty(EditText editText) { String mString =…
-
4
votes1
answer79
viewsIs it possible to force a method to be extended in Java?
It is possible to "force" a method to be extensible? The statement of the exercise says exactly this: we have to create a class, within it create a method and force this method to be extended. From…
-
4
votes2
answers279
viewsIs there a difference in how polymorphism is applied in Java and C# ?
I’m studying the concepts of POO and generated me a doubt. In Java I believe I can access all methods and attributes declared as public in a subclass even when using a superclass type variable to…