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
-
7
votes2
answers969
viewsWhat is the usefulness of the service layer in the Laravel?
What is the real usefulness of a service layer in the structure of Laravel? It’s just about separating the code from the Controller? How to use this layer correctly? My biggest question is whether…
-
7
votes1
answer84
viewsDoubt about prototype
I have a basic question in prototype in Javascript, is the following: function MeuObjeto() {} obj1 = new MeuObjeto MeuObjeto.nome = "Lucas" console.log(obj1.nome) Upshot: Undefined I am in doubt as…
-
7
votes2
answers191
viewsWhat are the main differences between prototype-oriented programming and class-oriented programming?
After learning a little more about Javascript, I realized that even though I have a building class, classes (in fact, as in C# or Java) do not exist in Javascript. This is nothing more than…
oop classes characteristic-language language-independent prototypeasked 4 years, 2 months ago Luiz Felipe 32,886 -
7
votes1
answer65
viewsA client class that registers clients in itself would be a cohesive class?
Studying cohesion. Since a cohesive class is one that has unique responsibility, it would make sense for the class Cliente own these methods? If we think in the real world, a customer cannot…
-
6
votes2
answers3255
viewsHow to perform object persistence in Delphi database?
I work with Delphi, but always in a procedural way and using Data-Aware components. I recently started reading some things about working with POO at Delphi, and did some fairly basic examples, my…
-
6
votes1
answer186
viewsPerformance in Javascript objects
By which means are obtained the best performance of Javascript objects. var Objeto = { propriedade:'valorPropriedade', init:function() { //Inicia Objetos } } var obj = Objeto.init(); or: function…
-
6
votes2
answers437
viewsHow to access jTextField statico created with swing?
So guys I got one jTextField that works normally but when I put it as static the setText no longer works, and I need it static because I pass the same to a function, I did it without the swing and…
-
6
votes2
answers375
viewsDoubt with inheritance in Java method
I have the interface below public interface BaseRelatorioDTO extends Serializable { public BaseFiltroDTO getFiltro(); public List<? extends BaseRespostasDTO> getRespostas(); } And I’d like to…
-
6
votes4
answers6284
viewsHow does an empty constructor work?
Definition: Creating an empty constructor attributes if not set will be set to the default value of guy, example: int default value is zero. Context: Use a structure that returns entities from the…
-
6
votes2
answers234
viewsHow to handle frameworks and ready-made technologies?
I’ve been having a question for a while and I think it may even be a common question. I don’t quite know how to put the question, but I’ll try. When I started programming I dealt with languages like…
-
6
votes2
answers1395
viewsDoubt in inheritance exercise in C#
I’m trying to solve an inheritance exercise and I found a question that I saw that you have a chance to show up in other places and so I thought I should ask here. The exercise asked to first create…
-
6
votes1
answer913
viewsCorrect Statement Classes Model MVC Ninject
I started using OO a short time and in all projects I see on the net, I see the following way of statement. public class Trabalhador { public int Id { get; set; } public string Nome { get; set; }…
-
6
votes1
answer368
viewsDesign Observer applied to events
I’m studying design standards and I’m trying to apply a real situation to them. And one example I did was on the event stage: In this scenario every event has participants to register. So, for that,…
-
6
votes1
answer1230
viewsWhen using __constructor magic method or set and get
My doubt is with constructor relation, for example, I have a class with name, age. the correct is to use __construct to pass values to them or use set e get ?
-
6
votes2
answers599
viewsStatic classes and classes with static methods
When I declare a class static, I am obliged to write my static methods and this class can never be instantiated. Now, I have a common class and I create my methods within it all static. Well, I do…
-
6
votes1
answer479
viewsPrivate Property / Protected JS / jQuery
Is it possible to make an object in js/jQuery where it is visible only using the method, for example get / set? An example of an object: if I give a console.log(pessoa.documeto), it will display the…
-
6
votes1
answer272
viewsInitialization of data of a class
Is there a class initialization function for C++? In Lua, using the library classlib there is the function __init, and in Python as well. EX: require "classlib" Human = class(); function…
-
6
votes1
answer319
viewsHow to have multiple addresses in one class of person?
If a person has more than one address. The code below is correct? public class Pessoa implements Serializable { private static final long serialVersionUID = 1L; private int codigo; private String…
-
6
votes0
answers53
viewsWhat is a Python metaclass?
What is a Python metaclass? On what occasions should they be used?
-
6
votes2
answers938
viewsHow to join lists in c#?
I have two classes: public class Produto { public int ProCodigo { get; set; } public string ProNome { get; set; } public int DepCodigo { get; set; } public virtual Departamento Departamento { get;…
-
6
votes2
answers509
viewsHow does the Table declaration instance work in Lua?
In object orientation, the class is usually created first and then the same. PHP example: class Test{ public function __construct() { // inicia as parada aqui } } $test = new Test; But in the Lua it…
-
6
votes1
answer235
viewsPopular via builder with Hibernate
I was reading this article http://blog.caelum.com.br/nao-aprender-oo-getters-e-setters/ and talks about using constructors to popular objects and set aside some setters. How can I use constructors…
-
6
votes2
answers733
viewsEmpty constructor without calling super()
When I do parameterized constructors, I create an empty constructor as well. In the empty constructor, should I always make the call to super()? Why? (Take into account, that my class is just a…
-
6
votes1
answer298
viewsWhat are the differences between Friend and Static classes/members?
What are the differences between classes and member variables friend and static within the definition of a class, including its applications. I only know which class members static belong to the…
-
6
votes1
answer755
viewsHow to make an interface in C++?
Java, C# and other languages have the concept of interface, which is very useful in some circumstances. How to interface or get closer to it in C++?
-
6
votes1
answer283
views -
6
votes1
answer3121
viewsClass and interface difference
What is the difference between class and interface and when I should use one or the other?
-
6
votes1
answer201
viewsWhy are you giving this Static variable error?
Why is giving this build error and how can I fix it? Cannot make a Static Reference to the non-static field service…
-
6
votes2
answers840
views -
6
votes1
answer882
viewsWhat safe way to check if an object is numerical?
I am implementing some generic functions in a module of my system, and I want to treat in a certain situation if the record is numerical (I do calculations). Then searching some way to do without…
-
6
votes2
answers166
viewsWhat is the Countable interface for in PHP?
I saw a certain class whose statement was that way: class Collection implements Countable {} I realized she was implementing Countable, but I didn’t understand what this implementation was doing…
-
6
votes1
answer87
viewsDoubt Class C++
I would like to understand why some classes in C++ have the following statement: class Bla; class Ble { .... } My doubt is about the Bla class, it has no meaning as far as I could see.…
-
6
votes3
answers463
viewsWhat is the correct option to instantiate a PHP class?
What is the correct option to instantiate a PHP class? Whereas the class is under discussion if call Atleta: 1) $atleta=Atleta; 2) $atleta= new Atleta(); 3) $atleta= Atleta(); Which of the 3 options…
-
6
votes2
answers141
views -
6
votes1
answer111
viewsIs it incorrect to change the arguments in an extended class in PHP?
It is incorrect (or "semantically incorrect") to change the arguments in an extended class in PHP? For example I created this class: class Bar { public function __construct($message, $code, $timer)…
-
6
votes2
answers322
viewsWhy can’t I use $this within a Static class?
As an example below, I was wondering why I can’t use $this within a Static class? <?php class A{ public static function hello(){ echo 'hello'; } } class B extends A{ public function ok(){ echo…
-
6
votes2
answers982
viewsCalling function from its name in a PHP class
I am creating an application where I need to call the function based on its name within the class. the intention to use this way is that I can call these functions through ajax and the server will…
-
6
votes2
answers190
viewsClass properties difference vs Instance
What is the purpose of creating attributes in the class if I can create in the instance itself?
-
6
votes1
answer56
viewsObject state invariance check between private methods execution
In this reply to the question How to test private methods in C#? is referred to The maximum that can be interesting is to have an object state invariance check between the execution of private…
-
6
votes3
answers268
viewsHow do Javascript functions behave in relation to the scope?
In Javascript, functions are objects and can be passed as parameters to other functions. But what about when a function with dependencies on an object, such as variables and other functions, is…
-
6
votes3
answers246
viewsDeal with exception that guaranteed will not occur
Here is an example of a method to illustrate the context of my doubt: public void comprar(int numeroLoja, int numeracaoProduto, String nomeMarca) throws LojaNaoExisteException,…
-
6
votes2
answers555
viewsDifference between fetch and setFetchDP methods
I understood the difference between fetch and fetchAll, but now, what is the difference between those and setFetchMode? Looks like it’s the same thing... (at least when it comes to riding). I can do…
-
6
votes2
answers6436
viewsClass, Superclass and Subclass
Regarding inheritance by code reuse in C# I have the following doubt: What’s the difference between classes, superclasses and subclasses? This changes something when doing code reuse? Additional…
-
6
votes3
answers709
views -
6
votes2
answers3155
viewsHow does Python overload polymorphism work?
I recently learned POO in Java and am now learning in Python. There is overload polymorphism (implement methods with equal names in the same class, which depending on the parameters you deliver to…
-
6
votes1
answer279
viewsObject-oriented PHP encapsulation
I have two models User and Post. When editing a post, I want to know if the user is the author of post (the post has an attribute user_id) to authorize the edition. If I have a method within the…
-
6
votes2
answers614
viewsInterface and inheritance for the Java connection class
Considering the object orientation, would the use of inheritance and interface in this way be correct? But in this way, any request for connection to the database will need a new object. Would have…
-
6
votes2
answers48
viewsNew instance overwrites old values
Take a look at this class: class Signal: point = None view = { "x": None, "y": None, } def __init__(self, point): self.point = point self.set_position() print(self.point + " -> " +…
-
6
votes1
answer4099
viewsDefinition and use of @Property
Good afternoon, I’m starting to study object orientation and I’m not getting a very good understanding of what the function is and when to use @Property. But from what I understood up to the moment…
-
6
votes2
answers2537
viewsWhen should I use a Property instead of a Python attribute?
If I set the class Person down below: class Person: def __init__(self, name): self.__name = name In this other way: class Person: def __init__(self, name): self.name = name self.kind = kind…