Most voted "classes" questions
In object orientation, a class is a structure that abstracts a set of objects with similar characteristics. A class defines the behavior of its objects through methods and possible states of these objects through attributes. In other words, a class describes the services provided by its objects and what information they can store.
Learn more…715 questions
Sort by count of
-
9
votes3
answers388
viewsRefactoring of a java class
I have a Java class that contains 1756 lines (obviously not all code, has blank lines, many comments and some commented code in case it is needed in the future) I’m implementing the structure MVC…
-
9
votes5
answers3697
viewsHow to import a variable within a function of a class?
I’d like to take the $valortotal and take it into a function of a class as can be seen in the example below. Thank you. $valortotal = 15.00; class CreatePaymentRequestLightbox { public static…
-
9
votes1
answer1492
viewsLibraries, interface, classes and methods
What’s the difference between libraries and interfaces? For example, on the line: import java.util.Scanner; The util would be the interface and Scanner the class? Or the util would be the library…
-
9
votes1
answer574
viewsWhat is Explicit in C++?
I came across the term explicit being used in a C code++. What is the use of this keyword?
-
9
votes1
answer209
viewsStrange property initialization
While reading a tutorial on Entity Framework, I came across an example of code where there was a line that, for me, is unknown: Student stud = new Student() { StudentName = "New Student" }; I…
-
9
votes1
answer1015
viewsWhat is the purpose of __slots__?
What is this property for __slots__? Li in the documentation something about "waste of space", but ultimately I didn’t quite understand the purpose of using __slots__. What it’s for and when I…
-
9
votes1
answer1539
viewsWhy use VAR in PHP?
Why use VAR in php if we can already declare variables without VAR? We can do this: $teste then why do it? var $teste For example, it’s the same thing I do? class Caneta { var $modelo; var $cor; }…
-
9
votes2
answers687
viewsHow do I know if a class implements an interface?
In PHP, we can implement one (or more) interface in a class. Thus: interface Authenticable { // métodos } interface Model { // métodos } class Person implements Authenticable, Model { // métodos }…
-
9
votes1
answer188
viewsInstantiate a class from its name in a string, without using "Eval" and in Chrome (V75+)
I need to instantiate a class from a string. Turns out for some reason it doesn’t work the way I used to: class MinhaClasse{ meuMetodo(){ alert('Método Funciona!'); } } let nome_classe =…
-
8
votes1
answer1127
views -
8
votes1
answer12581
viewsHow to reverse engineer an android app?
As from an android app in the extension . apk, get the classes, layouts, libraries etc, ie, perform reverse engineering? Note: I used 7-zip as Bacco advised and resulted in the following file…
-
8
votes2
answers2530
viewsIs a module the same as a Python class?
A module is the same thing as a class? If not what are the differences? I ask this because according to the The Zen of Python, modules should be used instead of ifs. The problem is that after…
-
8
votes2
answers742
viewsWhat’s a destroyer for?
In some languages, classes have methods destructors. In the ones I’ve seen, he’s declared a builder with the sign ~ in front. Something like: public class Foo { public ~Foo() { //Fazer algo } } What…
-
8
votes1
answer716
viewsShould I extend from an abstract class or a concrete one?
When I need to extend a class, following the concept of Object Orientation, should I extend my code from an abstract class or an abstract class? What is the best practice to join?
-
8
votes1
answer452
viewsWhat is a type class "class Minhaclasseexample<T> Where T: new(){}"?
A class class ExemploClass<T> is a list? See the example class below: public abstract class MinhaClasseExemplo<T> where T: new() { public T value {get; set;} } Which means every part of…
-
8
votes2
answers653
viewsName collision between class and namespace
It’s wrong, bad practice or I might have problems with class like namespace? Example: namespace Cielo { public class Cielo { ... } } It’s been working, in some places it gets a little strange to…
-
8
votes4
answers635
viewsWhy can objects other than the same class access private fields from each other?
Today while I was taking a course in Udacity (Intro to Java Programming) I thought about this in the exercise Update the class Person (lesson 3 29/45). In object-oriented modeling we have the…
-
8
votes2
answers291
viewsCan I use class and struct at the same time?
I have a variable "Address", however, it is composed by "Street", "Number" etc. The way I did below is the best to be done? With class and struct at the same time? Or is there something better and…
-
7
votes1
answer5408
views -
7
votes1
answer711
viewsHow does the class constructor statement in Qt work?
I work with C and a little bit of Assembly, in Atmel AVR microcontrollers. I’m trying to understand how the framework Qt extends C++. I created a new project with Qt Creator (Widgets), and generated…
-
7
votes4
answers492
viewsIn C# is it possible to use a local alias for class or namespace?
In languages like Python or PHP it is possible to use a local alias for classes or namespaces. PHP example: use Vendor\Package\ClassName as C; use Vendor\Package as P; $class = new C; $class = new…
-
7
votes2
answers8390
viewsWhere is the constructor of the class in Python?
Definition of Wikipedia. The builder is a method which is generally responsible for allocating the necessary resources to the operation of the object beyond the initial definition of the variables…
-
7
votes2
answers327
views -
7
votes1
answer88
viewsHow to list the synopsis of classes?
I started to venture into python and am making program that lists class properties. I use obj well.dic, help(obj), and dir(obj). Someone knows if there is a command that lists the synopses of the…
-
7
votes1
answer1855
viewsWhy use const after function?
I noticed some codes from other C++ programmers that use functions like: bool CClass::isRunning() const { return this->_running; } I understood that in this way it is not possible to modify any…
-
7
votes1
answer1482
viewsWhat is the difference between __init__ and __new__?
What is the difference between the special methods __init__ and __new__ in Python?
-
7
votes2
answers658
viewsWhat does a class diagram contain?
The title is a kind of stupid question, because the name of the diagram already answers. But yesterday this question came to mind when a professor of Analysis and Software Projects asked the whole…
-
7
votes2
answers2693
viewsWhat is a domain class?
What is a domain class? Why "domain"? Are there methods that it should not have (which is not its function to have determined type of method)? It admits what kind of methods?
-
7
votes1
answer223
viewsWhy hide the implementation of a class?
This is the concept I’ve worked hard to understand, but I’ve never fully achieved. I’ll take this excerpt from a Deitel book to illustrate: It is a better software engineering define member…
-
7
votes3
answers6315
viewsHow to make an "Insert" with Dapper using a class?
I’m testing Dapper and when I try to use a class I found the error: Must declare the scalar variable Follows the code: public class Teste { public int id; public string nome; public int idade; }…
-
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 ago Luiz Felipe 32,886 -
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
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
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
votes2
answers4042
viewsGet property values of a class
I have the following codes: private PropertyInfo[] ObterPropriedades(Type classe) { PropertyInfo[] properties = classe.GetProperties(); return properties; } private string[]…
-
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
votes1
answer83
viewsAccess properties without knowing name
You can access all your settings inside the class (estates) without having their names? For example, if I create an instance of a class $classe = new Classe(), and I’m defining things in her:…
-
6
votes3
answers14381
viewsAre there interfaces in python?
In languages like PHP and Java, there are interfaces, which, when implemented in a class, requires it to contain the methods of this interface in the same way as they were declared. Example in PHP:…
-
6
votes1
answer694
viewsHow to pick up attribute dynamically
How I would make the following PHP code in C#? class teste{ public $x = 10; public $y = 10; } $n = new teste(); $a = "y"; print_r($n->{$a}); Note that dynamism is in the variable $a, in which if…
-
6
votes1
answer297
views -
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
votes2
answers204
viewsget_called_class or new Static?
I don’t remember which PHP library I saw this, but there was a code snippet where, to get a new instance of the current class, the function was used get_called_class. But PHP has the keyword static,…
-
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
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
answer3121
viewsClass and interface difference
What is the difference between class and interface and when I should use one or the other?
-
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
votes1
answer71
viewsHow to call an object within the creation of another object
I have a Person class and a Date class, the Person class creates a person the date class creates a date to use as the date of birth in the Person class, how do I create a date without having to use…
-
6
votes0
answers92
viewsIs there anything that gives you the path to CSS?
I need something to make me reference the path of CSS faster, like a feature in Google Inspect, because it’s hard to keep finding the sequences of hundreds of divs inside divs. Like something that…
-
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…