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
-
16
votes3
answers3152
viewsWhen to use Setters and Getters?
I’m studying OOP and in the encapsulation part I had a question about when to use getters and setters, besides being able to validate the parameter passed, what is the usefulness of using? I could…
-
16
votes2
answers450
viewsGetters and Setters can only "walk" together?
I am studying object orientation and am having some doubts in the encapsulation part. For example: Class Url { private $url; public function setUrl($url) { if (filter_var($url, FILTER_VALIDATE_URL))…
-
16
votes2
answers898
viewsAre business rules always related to validation?
Since I started studying object orientation I hear a lot about business rules. Basically, from what I understand until today, an object must have methods encapsulated the rules of business and the…
-
16
votes1
answer1022
viewsThe use of immutability
Immutability What are the advantages and benefits, when to use and why to use immutability in my projects? The complexity of the implementation x time, worth it? When I should not use immutability…
-
16
votes4
answers14217
viewsHow to create/maintain "global variable" in java? To log in
I’m making a desktop application in Java. This application has a login screen (Jlogin) and one with the main application (Jprincipal) and I have a Login class with methods for database query and…
-
16
votes4
answers4276
viewsShould I initialize strings (or objects in general) with null?
I have noticed that a common practice among programmers is to initialize an attribute of a class with null. Is this good practice or not? Is there a difference between initializing with null or not…
-
16
votes4
answers1876
viewsWhat is the sense of an attribute being private and Static at the same time in a class?
I’m studying about the design pattern singleton, and in a code snippet on java, I came across a situation where I was in doubt. Below is the excerpt of the code: public class Conexao { private…
-
16
votes3
answers675
viewsWhy can’t I declare an attribute using the var keyword?
The keyword var allows me to declare typed variables, and allows variables to be defined implicitly. Example: var i = 10; The compiler will assume that my variable i is of the whole type int.…
-
16
votes4
answers276
viewsWhy is object orientation not suitable for most scenarios?
Citation maniero: It’s the biggest problem we have in our area, and it’s getting worse: something very good is created and it serves 1% of the problems, maybe 10%, but people want to use it for 100%…
-
15
votes2
answers2572
viewsMain purpose of utility classes
What is the real function of utility classes? Would only reduce maintenance and repetition of code or would go beyond these functions? Would have some way (convention) to use these classes…
-
15
votes5
answers1643
viewsDifference between private and final methods
Studying methods and final classes in Deitel’s book "How to program in Java 6 ed." I came across the following proposition: The declared private methods are implicitly final because it is impossible…
-
15
votes2
answers7197
viewsAdvantages of using Object-Oriented PHP? Where to use?
Lately I did a mini social media and practically did not use object orientation, except for one class I did for CRUD with PDO and ready-made Github libraries. Would this concept be applied more to…
-
15
votes1
answer703
views -
15
votes4
answers332
viewsIn relation to object orientation, should queries have a class of their own or can they stay in a specific class?
What I have is this: a user class and a connection class with the bank. I need to insert a user into a database, the query "insert into usuarios values (..)" should be in my user class or in the…
-
15
votes4
answers314
viewsHow do I know if I am programing procedurally in object orientation?
How to know if I am programming in a procedural style in an object-oriented language?
oop encoding-style software-project structured-programmingasked 7 years, 4 months ago Piovezan 15,850 -
15
votes6
answers2755
viewsIs it bad practice to use only static methods in a class?
I was studying further sinking the OOP, learning more advanced concepts such as Polymorphism, Override, Classes and final methods, abstraction, namespace and etc... I learned about static methods,…
-
15
votes1
answer170
viewsWhat is the use of "= delete" in the declaration of a constructor in C++?
I came across a builder declared as follows: State(const State& em) = delete; Does anyone know what the = delete at the end of the signature of the manufacturer?…
-
15
votes1
answer605
viewsQuestions about analysis and structured and object-oriented design
Software process, involves various activities, among them, analysis and design. Among the options of methods to perform these activities, we have the structured and object-oriented. Regarding both,…
oop modeling software-engineering encoding-style structured-programmingasked 5 years, 8 months ago renanvm 3,797 -
14
votes4
answers2252
viewsWhat is the advantage of hiding the class constructor in favor of a static method (no .NET)?
My leader uses this pattern in ALL his classes (I’ll give the examples in C#, but it goes for any . NET language): public class MeuTipo { private MeuTipo() { } // esconder o construtor public static…
-
14
votes3
answers21251
viewsWhat is a virtual class, attributes and methods?
What is a class, attribute and virtual method? public virtual class nomeclasse { public virtual int id { get;set; } public virtual void metodo() { } } What difference? When to use?…
-
14
votes2
answers511
viewsWhat are nesting guys for?
I know that C# supports nested types, that is, it is possible for me to declare one class within another. For example: public class A { // Propriedades e métodos da classe A public class B { //…
-
14
votes2
answers3077
viewsWhy in class statements in Python should we extend Object?
In the Python, when we declare a class, we extend object. class StackExchange(object): def __init__(self): pass I do not know if I am mistaken, but I had the impression that in some versions this is…
-
14
votes1
answer1047
viewsWhat is the cardinality between a request and the services included in it?
I have the class Solicitacao and the class Servicos. After insertion in the database I intend to recover in a query all the services associated with that request. For example, on a screen I insert…
-
14
votes2
answers481
viewsWhat are the Types of Ioc?
Reading the Book "Pro Spring Security" by Carlo Scarioni of Editora Apress, 2013 edition, I came across the following text that left me confused about Ioc: The basic idea of DI, a type of Inversion…
-
14
votes6
answers1655
viewsHeritage and Polymorphism
I have the class Funcionario. private String nome; private int idade; public function vender (Funcionario f) { ... } I have the subclasses Gerente and Professor that inherit (extend) from…
-
14
votes2
answers3182
viewsWhat is the difference between Simple Factory, Factory Method, Abstract Factory?
What are the main differences between these design patterns? In which situation can one pattern be better than the other?
-
14
votes2
answers329
viewsDomain-Driven Design and Requirements Survey
When we use Domain-Driven Design an important part of the development process is to contact business experts to have a good understanding of the domain in question. This can be done, for example,…
oop software-architecture ddd software-project requirementsasked 9 years, 1 month ago SomeDeveloper 18,074 -
14
votes1
answer5228
viewsWhat are the differences between overrideing and overloading in Java?
What are the main differences between overrideing and overloading in Java? What is the relationship between these terms and Polymorphism?
-
14
votes2
answers1408
viewsHow and when should we use Interface to document systems in PHP?
I always wondered exactly, if it is a good practice, to make a system always making use of Interfaces, or this is not necessary? Interface People { public function getName(); public function…
-
14
votes2
answers2108
viewsAre function and method the same thing?
When we talk about methods and functions, we are talking about the same thing? For example: function blablabla blabla That is a method?
-
14
votes3
answers1710
viewsWhat are the limitations of the object-oriented paradigm?
My experience is more with the object-oriented paradigm. Ok, "if all you have is a hammer, all the problems look like nails". And I say: it’s a complicated paradigm, full of good practices,…
-
14
votes1
answer368
viewsWhat is abstraction and how does it influence the creation of functions?
I was reading a answer about Python user’s @Cool in which he mentions the term abstraction in relation to complexity, functions and object orientation, see: What you can do if you can’t change the…
-
13
votes3
answers711
viewsExtend classes with private constructor
Because I can’t extend classes with private builder? Consindo the classes To: public class A { private A(){} public static void limao(){} } and B: public class B extends A { private B(){} public…
-
13
votes2
answers1065
viewsObject orientation in R: S3, S4 and Reference Class
R has, among others, three main forms of object orientation: S3; S4; and, Reference Classes. What are the main differences between the three methods? And how to implement them (preferably provide a…
-
13
votes1
answer8955
viewsInheritance in relational database
one of the great challenges in developing object-oriented software is to abstract the data from its base to power-like objects better manipulate them, today the available ORM frameworks make this…
-
13
votes3
answers1131
viewsOpen/closed principle - how to understand this?
In object orientation there is SOLID and one of the principles is the open/closed one that I learned as follows: "software components must be open for extension and closed for modification" and…
-
13
votes6
answers1170
viewsWhy is it not possible to define an interface with static methods?
I would like to force some of my classes to be implemented in Singleton, but I came across the following situation. interface ICharacterSingleton{ static Characters getInstancia(); } public static…
-
13
votes2
answers477
viewsJava Performance of methods-filled and empty classes
If I create a class whose goal is to group a number of related methods. Suppose a Class Boi{} and it has several methods but no element. For example: public class Ruminante{ public String…
-
13
votes1
answer1710
viewsExchange messages between objects, what does it mean?
What is the term message exchange between objects in Object-Oriented Programming?
-
13
votes4
answers570
viewsExtend x Superscript, what’s the difference?
Researching on concepts of Object Orientation, I came across the following comparative, Extend (Heritage) versus Superscript. I found the following statement for this comparative: Extend: When we…
-
13
votes3
answers600
viewsWhat does this() do alone in the builder?
In the code: public Livro(Autor autor) { this(); this.autor = autor; } public Livro() { this.isbn = "000-00-00000-00-0"; }
-
13
votes1
answer568
viewsWould it be right to leave the attributes of the abstract class as private or protected?
I don’t know how I should leave these attributes.
-
13
votes1
answer924
viewsWhen does it make sense to have only static methods and attributes in a class?
Studying about static methods and attributes in OOP, I came across the following question: because in some codes we have ONLY classes with static attributes and methods? Is there a design pattern…
-
13
votes2
answers460
viewsWhat is Closure Object and how do I get the anonymous function return as parameter?
Let’s say I have a class, and in that class i have a method, and in a parameter that method it is possible to use a anonymous function thus: Class and method: class Classe { private $exemplo = [];…
-
13
votes3
answers1372
viewsWhat is "Object-oriented" and what other methods?
I work a lot in AngularJS (Javascript) and with version 2.0 knocking on the door, which will have as main change the use of ECMAS6 I read a lot about Object-Oriented Programming. If you can keep the…
-
13
votes1
answer1093
views -
13
votes1
answer1859
viewsReasons to use private class
When I started in the area, in a course of POO (Object Oriented Programming) the teacher explained about access modifiers... I remember that on this very day he said that it would be possible to…
-
13
votes3
answers818
viewsSOLID is all that they say?
Related: What are the SOLID principles? I ordered my "Agile Principles, Standards and Practices in C#" by Robert C. Martin and one of the reasons is SOLID. But I’m reluctant about SOLID. I don’t…
-
12
votes2
answers1221
viewsWhere should I declare an instance variable in Javascript?
I’m having doubts about creating instance variables in a Javascript constructor class/function. I have read in several places that the declaration of an instance variable is made within the class…
-
12
votes2
answers5287
viewsHow to implement the Repository Standard in C# with EF?
I want to make an implementation of the standard Repository where I will be using the Entityframework and have the following: Interface IRepository: public interface IRepository<T> where T :…