Most voted "builder" questions
Constructing object-oriented programming languages is a method called as soon as a new instance of the object is created. Such a method is usually responsible for allocating resources needed to function the object beyond the initial definition of the state variables (attributes). If the question is not about the "Constructor", do not use this tag, even if you are using the "Constructor" in your project.
Learn more…141 questions
Sort by count of
-
3
votes2
answers8139
viewsShortcut to create constructor with parameters
Is there a shortcut in Visual Studio, which creates a constructor, with all attributes created in the class? class Alimento { public int ID { get; set; } public string Titulo { get; set; } public…
c# visual-studio visual-studio-2012 builder resharperasked 9 years, 4 months ago Eduardo F. Santos 449 -
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
answer120
viewsAre methods and builders the same?
Some sources say that constructor is a special type of method, while others say constructors are not methods. Some say, too, that although they are different the JVM treats them the same way. After…
-
3
votes1
answer125
viewsHow to pass arguments dynamically to a new call?
If I have a Javascript function and want to call it by passing a list of arguments, use apply: var x = f(1,2,3); var x = f.apply(null, [1,2,3]); For the first time, I came across a case where I need…
-
3
votes2
answers222
viewsEntity Framework and parameterized constructor
When I create domains, I usually create a parameterized constructor for the same: namespace Models { public class Unity { public string Abreviation { get; set; } public string Description { get;…
-
3
votes2
answers1064
viewsJava constructor with matrix
I am learning about constructors in java but I stopped in college exercise that seemed simple, the proposal is to create a constructor class with a matrix, and call it in another class to assign the…
-
3
votes1
answer159
viewsRun an Attribute constructor
How do I call the constructor of an attribute before the constructor of the decorated class? For example, I have my attribute: using System; namespace T.WinForm { public class TesteAttribute :…
-
3
votes1
answer690
viewsWhat is the difference between classes initialized with (and without) __init___
I’m a beginner in Python and I wanted to understand a difference. The two classes below produce exactly the same result and the variables become public in the same way in both classes: class c(): t…
-
3
votes1
answer200
viewsWhat is the real need for the "initialize" method in Ruby?
def initialize(nome = "Anônimo", salario = 0.0) @nome = nome @salario = salario end To clarify, what I can’t understand is the difference between using this method in a class and for what purpose it…
-
3
votes1
answer192
viewsIs it bad practice to do a lot of things inside a builder? Why?
Is carrying out heavy processing, such as queries to a database or consuming an API, within class constructors considered a bad practice? Why? public class Classe { private String dados; public…
-
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
answers467
viewsCall to a Member Function cadastrarDados() on null - Laravel
Good morning to all, I am developing an application in Laravel 5.6 using PHP 7.2, I am having problems using DI(dependency Injection) in the constructor, since when creating the object manually the…
-
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…
-
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
answer216
viewsIn an Activity, first open the onCreate method or class constructor?
In a scenario where you have an Activity with a constructor (public, of course) and the onCreate method which is part of your life cycle. Which of the two will be executed first?
-
2
votes1
answer571
viewsHow to call asynchronous method in class builder?
How do I call a method marked as async in a class builder?
-
2
votes2
answers569
viewsConstructors in PHP 7
I was testing a class in PHP 7, and noticed that the constructor no longer works when it is created from the class name, working only when it is created with the name __construct. Example: <?php…
-
2
votes1
answer174
viewsReact class constructor error
I have the following error when I try to use Component in this way. client?cd17:119 ./src/App/Components/AddNote.js Module build failed: SyntaxError: super() outside of class constructor (9:4) 7 |…
-
2
votes1
answer116
viewsBuild error due to lack of constructor
I have the following classes: class Disciplina: public class Disciplina { public int Id { get; set; } public string Nome { get; set; } } interface IGenericaDAO: public interface…
-
2
votes2
answers691
viewsCorrect use of Override and constructor
I was asked to create a current account class that had an attribute representing the fee charged for each transaction of two attributes of the superclass (credit/debit). And have been asked to…
-
2
votes1
answer200
viewsArray to Arraylist conversion difference with "asList" and constructor
What is the difference between these two ways of converting a array? If there is any difference, the same impact on performance? List<String> list = Arrays.asList(meuArray);…
-
2
votes1
answer404
viewsJava error "constructor 'X' in class 'X' cannot be Applied to Given types;"
When compiling the code below I get the following error: Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type:…
-
2
votes1
answer77
viewsSet Variables by Java Constructor
It is certain to "set" the variables passing by parameter directly in the constructor, equal to this code? public class Retangulo extends FiguraGeometrica{ private double largura; private double…
-
2
votes1
answer409
viewsWhat is the "super()" operator for in Javascript?
What is the operator’s functionality super() which lies within the method constructor?
-
2
votes1
answer51
viewsCopy and move constructors are called only in the creation of an object?
The builders move and copy are only called in the creation of an object? if yes, after the creation of an object, it is not possible to call either explicitly or implicitly the move or copy…
-
2
votes1
answer608
viewsWhat does the class name mean in super(). __init__()?
How the name of the classes inserted within the constructor’s parentheses works __init__( ), in the classes Telefones, TiposTelefone and Agenda? This is only an excerpt of Chapter 10 code from the…
-
2
votes1
answer171
viewsList is not being passed as method parameter
I need to implement the method RoutesBetween to trace the route between a point and another (in this case, point To and And). Test method: public void TestRoutesBetweenTwoPoints() { var links = new…
-
2
votes1
answer256
viewsInstantiating an object in the same constructor class is "inelegant"?
It is always seen as a good practice of programming if we create a class for the object, where we have the constructor and make the methods and another class where we instantiate several objects of…
-
2
votes1
answer47
viewsHow to use RAII, Constructors and Exceptions
I’m new to C++ and recently came across something that I can’t quite understand, which is: in my research, I saw that RAII is a suitable technique to be used when you need to acquire a resource in…
-
2
votes4
answers428
viewsHow to validate data passed to a constructor?
Is there a way to handle possible errors or validations by instantiating a class using the constructor? For example, this is my constructor: public boolean ContaFisica(int agenciaConta, int…
-
2
votes1
answer73
viewsHow to call the constructor within a method
I have a simple college exercise to mess with the vector. Basically these are the actions that we should do: cout << "\tMexendo com Vetor\n"; cout << "\n\nEscolha uma das opcoes para…
-
2
votes2
answers183
viewsHow to resolve "There is no default constructor in ..." error in Java?
I have an abstract class called Veiculo which has two builders: public abstract class Veiculo { // Atributos ... public Veiculo(Marcas marca, int velocidade){...} public Veiculo(Marcas marca, int…
-
1
votes1
answer200
viewsConstructor error parameterized c++
What happens when a class with parameterized constructor is created, with no default constructor, and the object of this type is called without argument in the constructor in c++? Does compile error…
-
1
votes1
answer287
viewsIsn’t it right to connect the database only once and then go through the records?
<?php class Usuario { private $login; private $senha; private $admin; //variaveis internas private $bd; //conexão com o banco private $tabela; //nome da tabela public function __construct() {…
-
1
votes2
answers590
viewsHow does creating an Array work?
When using the command new() for the creation of any object we call the constructor of the class of that object and obtain the reference to the instance created. However, what happens when creating…
-
1
votes1
answer69
viewsHow to pass the class (Teste2 teste2) as reference in the ("super") C++ constructor?
On the basis of that reply In C++ what command corresponds to super() of Java? Class Teste2{ int x; int y; public: Teste2(int x, int y){ . . . } } class Testando{ Teste2 *teste2; public:…
-
1
votes1
answer193
viewsWhat’s that part of the code called?
Let’s say I create a class... public class Teste1 { public void Teste1(){ System.out.println("Olá"); } public void teste2(){ System.out.println("Oi"); } } The Teste1 is the constructor method of the…
-
1
votes0
answers130
viewsProblem with parameters passed to Phplot by Codeigniter Controller
I’m having a doubt that at the same time is being a problem, because I don’t know what I might be doing wrong. The thing is, I’m using Codeigniter and to generate a graph I’m going to use the…
-
1
votes2
answers849
viewsCatch instance of daughter class
I have a class: class Children extends Database Soon, Children is the daughter class and Database the parent class, in the parent class I have the attribute: protected $object = null; The value of…
-
1
votes1
answer50
viewsIoc Laravel Conflict 5.3
I have the following codes: Chat Staff Service namespace Chat\Api\V1\Services\Chat; class ChatStaffService extends Service { private $chatService; public function __construct(ChatService…
-
1
votes2
answers283
views -
1
votes2
answers220
viewsHow to pass an attribute of the child class through the constructor to the mother class
I have 3 classes Mother class: Animal Child Classes: Dog and Cat I want to save the name attribute only when one of the objects is instantiated Gato or Cachorro. In the mother class I have the…
-
1
votes1
answer111
viewsWhat is the difference between the constructor method and the use of setters in Javascript object orientation?
The question may seem a little crude, but I was left with doubts and I would like to understand more deeply. The constructor feeds the created class objects, correct? Doubts are: So what use is he…
-
1
votes1
answer187
viewsJava Class Constructor Fix to Sonar
I need to correct some differences in sonar. I have these builders, getters and setters: public EmpregadoContrato() { // construtor padrão } public EmpregadoContrato(Integer id) { this.id = id; }…
-
1
votes1
answer352
viewsHow to implement a copy constructor for a two-dimensional matrix in C++?
I have the following situation: a class Matriz implemented as follows: Header: #ifndef MATRIZ_H #define MATRIZ_H class Matriz { public: Matriz(unsigned int nL, unsigned int nC); ~Matriz();…
-
1
votes2
answers270
viewsUse a constructor with multiple parameters, or create multiple sets?
Amid use a constructor with multiple parameters or give a lot of sets, which of these options is more performative for the compiler, would cost less memory and would be faster?…
-
1
votes1
answer45
viewsSyntax inside a struct that looks like a function
I was analyzing a code in C++ and came across the following structure: struct ligacao { int v_; int w_; int ComEXp; ligacao(int v, int w, int ComEXp1) : v_(v), w_(w), ComEXp(ComEXp1) {} // Minha…
-
1
votes2
answers371
viewsWhat’s the difference between initializing a variable in these constructs? And how do you set a constructor to default?
Is there a difference when initializing a variable in any of these constructor forms? And how do I default a constructor (default) in a class that has more than one constructor? Constructor 1: class…
-
1
votes1
answer33
viewsClass attribute in constructor
I can access a class attribute within the constructor scope, but outside gives 'Undefined' constructor(errorAlert){ this._errorAlert = errorAlert; } If, for example, in the code above, I give…
-
1
votes2
answers362
viewsPOO JAVA - Doubt Exercise
Good first follows down the exercise: Create a class called Date including three parts of information as instance variables: one mês (tipo int), one dia (tipo int) and a ano (tipo int). Provide a…