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
votes3
answers1298
viewsPerform table insertion with foreign key
include_once 'acesso_bd/conexao_bd.php'; class PropriedadeDAO { function inserirPropriedadeBD($propriedade) { $nome = $propriedade->getNome(); $endereco = $propriedade->getEndereco();…
-
4
votes3
answers280
viewsHow do I block access to setting parameters in a class?
import math class Circulo(): def __init__(self): super() self.__raio = None def get_perimetro(self): return 2 * math.pi * self.raio def get_area(self): return math.pi * self.raio ** 2 @property def…
-
4
votes2
answers76
viewsHow to instantiate $Pdo = connect() without repeating?
For example I have a class called user: class User { public $nome; private $email; protected $senha; public function __construct(){ } public function insert($email, $senha){ require_once…
-
4
votes2
answers540
viewsPHP POO error Polymorphism
When developing a simple PHP POO application, I came across an unexpected error, and I have no idea why. I’m starting now to study object-oriented programming and only have a small C-base#. The…
-
4
votes2
answers1903
viewsHow to convert Lowercase String to UPPERCASE?
My question is in switch (opcao). To perform one of the cases it is necessary to enter with capital letters. Is there any string or Java character conversion function from lowercase to uppercase…
-
4
votes1
answer261
viewsHeritage in object-oriented programming
I was reading that article today and I came across the following statement: "Inheritance refers to the ability of an object to access methods and other properties of another object." Inheritance…
-
4
votes1
answer255
viewsWhat is the need for an interface to have abstract methods?
We know that in an interface the methods do not have implementation, only signature, ie only the definition of their methods without the body, we conclude then that all are already methods Abstract,…
-
4
votes2
answers220
viewsStandard implementations in C#interface
I was reading about the new features of C# 8 and came across the Default Interface Implentations, i.e., standard implementations in interfaces. The code below exemplifies public interface…
-
4
votes1
answer1006
viewsOverload method is polymorphism?
I’m having trouble understanding the concept of polymorphism in Java, I read two articles of the same portal now and I was more confused, because for my interpretation they contradict each other:…
-
4
votes2
answers79
viewsHow to create hierarchy functions? Ex Console>Error>Writeline()
My question may seem confusing so I’ll explain. Imagine that I have three class: Program, Controle.cs, Volume.cs. class Program using System; namespace ConsoleAppPOO { class Program { static void…
-
4
votes2
answers123
viewsHow does a method with the same name return more than one object type?
I am implementing the Google Drive API and I came across the following situation: var fileMetadata = new GoogleDriveAPIV3.Data.File() { Name = "folderTest/testeUpload.jpg" };…
-
4
votes3
answers290
viewsHow to make compatible objects coming from two different classes, derived from the same interface?
I have an interface (I’ll call it ICliente) which is used as a contract between an application and a DLL. public interface ICliente { int Id {get; set;} string Nome {get; set;} ... } This interface…
-
4
votes1
answer296
viewsImplementation Doubt in Object Orientation
I am implementing the whole book set exercise deitel 6th edition: Create the class IntegerSet. Each object IntegerSet can store integers in the range of 0 to 100. The set is represented by an array…
-
4
votes2
answers76
viewsclone, copy, changeable object on getter for security
In many articles and books it is cited that for security the correct is always deliver via getter a copy of mutable attributes. It can be a clone or a new instance containing the same values as your…
-
4
votes1
answer59
viewsHow to deal encapsulated a field that is a list of immutable elements?
Imagine that you have an object and one of its fields is a list of immutable elements. You want to make this field available to the clients of this object in a controlled way, after all a list can…
-
4
votes1
answer44
viewsHeap things on a function x DRY
That bold bit taken from here it wasn’t very clear to me: DRY solves what? Some may still be thinking that DRY is to reduce typing. Or at least gain maintenance time. It’s even in the latter case,…
-
4
votes2
answers242
viewsObject orientation: what defines the identity of an entity?
I know that the concept of identity, in this context, is abstract and it is precisely to make it more tangible that I asked this question. Follow the questions: Only database id defines an entity’s…
-
4
votes1
answer291
viewsComposition of objects in Python
In this case, I’m trying to understand how the connection between two classes and their objects. Since, when creating an object, a space in memory would be reserved for it, this space includes the…
-
4
votes1
answer94
viewsRepositories can manipulate and "transform" data?
I’m implementing two video service Apis (Youtube and Vimeo), and because it’s a layer of data, I thought it was ideal to create repositories for each one, with the API being the "source" of the…
-
4
votes1
answer95
viewsValidation test works with numerical values but not strings
My inheritance code works normal, what I wanted to do is if the nome and the pseudonimo are null the code would stop, the code only stops running when idade, altura or peso sane null. import…
-
4
votes1
answer77
viewsCan I use Object.assign to assign properties to this in Javascript?
I’m learning about objects now and I’d like to know if it’s possible to use Object.assign to assign all properties to this of a class in Javascript. Example: class Foo { name; email; phone;…
-
4
votes2
answers67
viewsIs there practical application in write-only properties?
In object-oriented programming, a property is a member of a class that provides information about the object. That is, properties expose attributes. Properties can also be "write only". An example…
oop characteristic-language software-engineering property language-independentasked 3 years, 7 months ago vinibrsl 19,711 -
4
votes2
answers96
viewsA class is an instance?
Considering the example, one can say that p1 is an instance of Pessoa, which is the class: class Pessoa end p1 = Pessoa.new() # => #<Pessoa:0x00000001268ee528> However, it is not often said…
-
3
votes2
answers2185
viewsTransparent java background
I have a problem with background transparent of a JTextField, by changing the content of JTextField it seems to superimpose the text and get all mixed up: I’m setting the background like this:…
-
3
votes1
answer631
viewsHow to cast between base and derivative classes?
I have an exercise that says I have to create a foundation. This base has two derivatives. I have to cast the derived class(1) for the derived class(2) and the derived class(2) for the base class.…
-
3
votes1
answer442
viewsClass creation in C++
I am developing a project and need to create an internal class. I am obliged to create a . cpp and a . h?
-
3
votes1
answer491
viewsWhat is the difference between Controller and Helper methods?
Architectural and conceptual doubt: I own a model Item who possessed attributes nome_ptbr and nome_en. I did the following method: def display_nome nome_ptbr || nome_en end Where should I put these…
-
3
votes2
answers239
views -
3
votes2
answers134
viewssubtraction of two double properties[]
I have a class called functions.Cs I need to create a property that stores the initial X,Y and final X,Y values, I thought: public double[] PosicaoInicialXY { get; set; } public double[]…
-
3
votes3
answers7392
viewsCreate an object from another class
I own the class Endereco and the class Cliente, I built 2 builders for the Cliente, and in one of them is to be inserted the name of the client and an object of type Endereco, which works perfectly,…
-
3
votes2
answers403
viewsPass list of objects between files
How to pass a list of objects through two Javascript files? I have a list: var elementsList = []; And this list is populated with N objects: var oElement = { elem: "", emin: 0.0000, emax: 0.0000 } I…
-
3
votes1
answer419
viewsDoubt about static methods and classes
I have a question about methods and static classes, given the code below: static List<MaterialRCM> mr = new List<MaterialRCM>(); [Authorize] public void AddMaterial(int Qtd, int Id) {…
-
3
votes1
answer716
viewsHow to communicate between classes?
I’m starting at Javafx and I’m having doubts. The main class creates an Hbox with a button. This button has the action of creating a TableView in the Center of bdPrincipal. Only they are in…
-
3
votes2
answers23592
viewsUsing a class function within another PHP class
I have two classes, which is the correct way to call a function of another class, the way below returns error class DB { public function __construct($user, $password, $database, $host) {…
-
3
votes1
answer1312
viewsDefinition of non-generic method?
In public partial class frmAltInfo : Form Error occurs: Extension method must be defined in a non-generic Static class I don’t understand what it can be or how to fix it. Here was the mistake:…
-
3
votes1
answer576
viewsError making dynamic PHP Insert
The code that is causing the error: public function Inserir($tabela,$sql){ ksort($sql); $Campos_nome= implode('`, `', array_keys($sql)); $Campos_valor= ': '. implode(', :', array_keys($sql));…
-
3
votes2
answers101
viewsMany Relationships for Many in Restful Service
I’m starting to work with Restful Services and I’m having doubts about many relationships for many. For example, suppose I have two entities Cliente and Fornecedor and that Cliente has a list of…
-
3
votes2
answers60
viewsInnerclass object is created at what point?
I have a class which contains an Innerclass, I wonder if at the moment I give new ClassePrincipal() Innerclass is also created?
-
3
votes3
answers606
viewsCorrect Inheritance in Entity Framework
I have a mother class DadosClientes and two child classes DadosClientesPF, and DadosClientesPJ. Instance DadosCliente has the field: Nome, Telefone Instance DadosClientePF has the field: CPF…
-
3
votes3
answers4208
viewsIs it possible to create an object dynamically in JS without using Eval?
I have the following code: Arr = ["meu", "objeto", "dinamico"]; Val = 100; Eval = ""; obj = {}; for(i in Arr){ Eval += "['"+ Arr[i] + "']"; eval("obj"+Eval+"={}") } eval("obj"+Eval+"="+Val); As you…
-
3
votes1
answer307
viewsUse of equals and inheritance
I have a parent class and in it I have a equals and I have other daughter classes of this father class and in them I want to overwrite the equals to compare particular attributes of these daughter…
-
3
votes4
answers15572
viewsWhat is the super() function for;
I am studying Java and I need to understand the logic of a code here. I wanted to know what this piece of code does: public class UsuarioController extends HttpServlet { private DAO dao; public…
-
3
votes4
answers164
viewsFather class with the same responsibility of the daughter class
I got my class Item public class Item { public string Nome {get;set;} public decimal Valor {get;set;} public ICollection<SubItem> SubItens {get;set;} } public class SubItem { public string…
-
3
votes1
answer90
viewsWhat is a lightweight class?
I am looking for a concise explanation for this question a while ago. What I found were confusing and didactic texts.
-
3
votes1
answer257
viewsInheritance with Repository Pattern
I’m studying and trying to implement the Repository Pattern in C# however I am having some difficulties in solving certain problems with inheritance among my classes of Repository, for example the…
c# oop entity-framework pattern-design inheritanceasked 10 years, 1 month ago Pablo Tondolo de Vargas 5,444 -
3
votes1
answer2607
viewsCan I declare a builder in the child classes when the mother class is abstract and already has a builder?
My question is this: If I can declare a constructor in a class abstract and also in the child classes. And also how to access their values. For example: abstract class Animal { private $nome;…
-
3
votes2
answers12630
viewsHow does Java Builder Heritage work?
In Java when one class inherits from another it is necessary to initialize the constructor of the parent class, right? using the super() and passing to this super() the parameters the parent…
-
3
votes1
answer350
viewsAPI’s web, REST and Object Orientation
I’m starting to study web Apis a little more in depth and I was a little bit in doubt with the following question: I work with ASP.NET Webapi and therefore with object orientation. I have in my…
-
3
votes2
answers870
viewsHow best to reuse code between modules
I am developing a tool using Angularjs, but I am constantly picking it up, I need to reuse code from different modules and files, but it is not working properly. With pure javascript, it’s easy to…
javascript angularjs oop dependency-injection angular-moduleasked 9 years, 3 months ago Victor Siqueira 638 -
3
votes3
answers162
viewsRelationship Have-one in C#?
I tried to do a have-one relationship in C# and I’m not getting it and I don’t even know if it’s recommended to do. Follow my error code: System.Nullreferenceexception Undefined object reference for…