Posts by raphael • 2,131 points
59 posts
-
2
votes2
answers149
viewsA: Condition in PHP "if" to know if the sent Mysql command worked or not
The execute method of the class PDOStatement returns a boleano, so you can check the result of this method in if. Follow the code: $execute = $sql->execute(); if ($execute){ return true; }else{…
-
7
votes1
answer114
viewsQ: Is every anonymous function a closure?
Every anonymous function is considered a closure or only those that refer to the context where they were created are? I wish I knew that to distinguish them correctly. I know the concepts and the…
-
-1
votes1
answer267
viewsQ: What parts of a project are part of the infrastructure layer?
My goal is to know if the classes related to the topics below fit into this infrastructure category to separate them into layers within a project. Follow the topics: Database Log Dependency…
-
4
votes2
answers242
viewsQ: Object 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
answer96
viewsQ: Is it correct to read the Migrations files and the configuration file?
Files that make the database Migrations should be added in Git versioning? I am using Phinx and I have this doubt regarding the classes that represent the tables that are generated by this library.…
-
3
votes1
answer88
views -
6
votes6
answers623
viewsQ: What is the reason for the application of the concept LIFO (Last In, First Out)?
Is there an advantage in implementing the concept LIFO (Last In, First Out) or is it just a semantic question to represent an order in algorithm logic?
computer-scienceasked raphael 2,131 -
2
votes2
answers172
viewsA: Good practice with Phpunit tests
To improve these tests it is more appropriate to separate them into several methods, so everything is more organized and it is possible to have a better sense of everything that is being tested.…
-
5
votes4
answers694
viewsA: Why not comment on the code?
Good names make some comments unnecessary When the author says not to comment on the code, he refers to prioritizing a readable code that does not need redundant explanations by adding comments. No…
-
5
votes1
answer232
viewsQ: Redirect to previous page: PHP vs. Javascript
What is the most advantageous way to make the user return to the previous page. For example, in Frond-end would look like this: <a href="window.history.back()">Voltar</a> Already in the…
-
-3
votes1
answer52
viewsQ: Why do some links not inform the domain or protocol?
I would like to know more about relative navigation links and would also like to know the pros and cons of using them. For example, there are links that do not inform the domain and do not inform…
-
13
votes3
answers547
viewsA: Why does the "text-align: center" property work in image?
It works because an image is an inline element The property text-align works for elements that are inline, an image is an inline element, so text-align works in images. It’s as if these inline…
-
3
votes1
answer59
viewsQ: Different ways to do a query that performs an SQL merge
I learned to do SQL queries with joins as follows: SELECT u.NOME, e.RUA FROM usuarios u, endereco e WHERE e.ID_USUARIO = u.ID ORDER BY u.NOME As you can see, the query searches the name of users and…
-
3
votes2
answers1147
viewsA: Should I declare a variable within the "if" or separate condition?
On the use of good practice Something "Ideal" is relative when it comes to programming practices, but instead of discussing it I will try to answer objectively. I find the question of Pernambuco due…
-
5
votes2
answers273
viewsQ: PHP: How is sending email via SMTP without the mail function?
I would like to know how is the implementation of sending email with SMTP. How is this communication made if the function mail is not used? How is the communication with server in this case? What…
-
2
votes1
answer333
viewsQ: Is using Jquery still advantageous today?
I wonder if the use of Jquery is still advantageous in the development of Frond-end with the features with Ecmascript 6 and the like.
-
1
votes2
answers489
viewsQ: What are the differences between Value Objects and entities in object orientation?
I would like to know the differences between the concepts of Value Objects and entities in object orientation. NOTE: The question is not whether the use of these concepts are good or not, the doubt…
-
-2
votes1
answer343
viewsQ: PHP: Questions about front-end and back-end input validation
The questions are about how to make the validations in front-end and back-end. Basically, the doubts are as follows: If the front-end validation is disabled as the messages to the user? Validating…
-
1
votes1
answer174
viewsQ: Is "use Strict" still useful with the new features brought in Ecmascript 6?
Ecmascript 6 brings the resources let and const, that prevent variables from being redeclared and overwritten unintentionally, and limit the scope of the variables created. The question is: with…
-
5
votes2
answers449
viewsQ: Questions about block scope in Javascript
The doubts are as follows: What is the difference between block scope and function scope in Javascript? The idea of block scope arose in Ecmascript 6 with let and const?…
-
0
votes1
answer235
viewsQ: Did inverted string quote support appear in Ecmascript 6?
Inverted quotes used in strings like `exemplo` were added to Ecmascript 6? I wonder if this came up in this version. PS: I don’t believe the question is duplicated, because my question is whether…
-
8
votes4
answers711
viewsQ: Why are literal objects declared with const in Javascript currently?
Because of Ecmascript 6 I see examples that declare literal objects with the reserved word const. Code example: // Versão utilizada atualmente const obj = { x: 'example' }; // Versão utilizada…
-
4
votes4
answers2052
viewsQ: Is Ecmascript 6 supported by current browsers?
Can Ecmascript 6 features available in Javascript already be used in a way that is supported by current browsers? I wonder if this version is already supported as a whole (and not just specific…
-
3
votes0
answers124
viewsQ: Why do file names usually not carry special characters?
It is common for file names to follow patterns such as nome-imagem.jpeg (in lowercase and separated by hyphens). This practice is adopted by convention or because of compatibility with web servers?…
-
1
votes2
answers86
viewsA: Count GET parameters - PHP
You can use the function array_filter to remove the empty values and then count the returned result. $valoresVaziosGet = array_filter($_GET); $contagemVaziosGet = count($valoresVaziosGet);…
-
0
votes2
answers96
viewsA: PHP does not display Json
Use the method serialize to take the form data, so it is not necessary to take the client data manually in Javascript. $("#enviar").click(function(){ $.ajax({ type:'POST', url:'php/destino.php',…
-
9
votes1
answer119
viewsQ: How does PHP arrays work internally?
PHP handles arrays in a way different from other languages, apparently there are concepts of hashtable to associate values. How it works internally in the core language arrays?…
-
8
votes3
answers229
viewsA: Why is an anonymous function seen as an object in PHP?
How PHP handles anonymous functions In PHP, an anonymous function is an object of the type Closure. Language documentation says the following about the Closure class: Class used to represent…
-
11
votes1
answer359
viewsQ: What is type Juggling?
What is type Juggling? This concept is related only to dynamic typing languages like PHP and Javascript?
-
5
votes1
answer295
viewsQ: What is the difference between extension and library in PHP?
In PHP there are some extensions within the language. For example, the SPL, to PHAR and the PDO are some of these extensions. Basically, my doubts are as follows:: What’s the difference between an…
-
0
votes2
answers207
viewsA: PHP - Trait or Extended Class
In that case, inheriting would not be a problem if User is actually a specification of the most generic code that is in the trait. So you could turn this trait into an abstract class and inherit…
-
1
votes4
answers276
viewsA: Why is object orientation not suitable for most scenarios?
Use of object orientation Indeed, object orientation is not suitable for all scenarios. Depending on the size of the project, dismembering the problems into multiple objects generates more…
-
4
votes2
answers317
viewsQ: Why does "echo" accept parentheses in PHP?
In PHP, the echo can you receive parentheses because you consider that an expression? Apparently, some language features do not seem to be standardized and can therefore be used in numerous ways.…
-
1
votes1
answer385
viewsA: How to pass PDO to other objects in MVC OOP application
Creating the controllers Factorys can be used to solve the problem, so they will be passed to a class that will run the controllers checking if there is any Factory for their creation. The…
-
0
votes1
answer141
viewsQ: What are the advantages of using the box-Sizing property on elements?
I would like to know the advantages of the CSS box-Sizing property.
-
4
votes3
answers818
viewsA: SOLID is all that they say?
SOLID SOLID principles serve as metrics in object orientation. Applying SOLID is not like a design standard, because its concepts are not formulas, but ideas that can be applied in the code. To…
-
0
votes2
answers114
viewsA: How to check whether data already exists or has remained blank?
Removal of spaces If you are validating in Javascript with Jquery, you can do the following: var nome = $('#nome').val().trim(); // O método trim remove os espaços if(nome === ''){ alert('Preencha o…
-
5
votes2
answers1461
viewsA: Add data to a txt file
The function file_put_contents can be used to do this in a simpler way. According to the PHP documentation, this function is the same thing as calling fopen, fwrite and fclose functions: This…
-
5
votes3
answers349
viewsQ: What are the advantages of using PHP’s sprintf function?
I can see an advantage in using the function sprintf in place of concatenation: readability. In addition to readability, what are the other advantages of sprintf() in relation to concatenation? Is…
-
2
votes1
answer164
viewsA: Good practices for class that grows a lot
The validation To validate each attribute it will be better to have a validator for each value. With this in mind, if a new attribute arises it is not necessary to modify the class. Basically, the…
-
4
votes1
answer150
viewsA: Case of use of the SRP concept in a real application
In search of SRP (Single Responsibility Principle) Follow the answers to your questions. 1 - I must separate the validation logic and the CRUD part into separate classes? Yes. It is better to…
-
3
votes4
answers314
viewsA: How do I know if I am programing procedurally in object orientation?
It is difficult to say what is right or wrong, because everything depends on a context, however in object orientation there are some topics. Some things that can help are: Avoid giant classes (also…
-
7
votes2
answers310
viewsQ: Float vs. inline-block. What are the advantages and disadvantages of each?
I would like to know the advantages and disadvantages of using the properties float and display with the value inline-block. I know that both work to align elements, but I try to know the pros and…
-
3
votes2
answers555
viewsA: Difference between fetch and setFetchDP methods
In PDO, the method setFetchMode is used to define how the data is obtained, in the case of the example you posted, the constant PDO::ASSOC is used to return the data in an associative array. The…
-
1
votes2
answers994
viewsA: What are side effects?
The side effect on object orientation In object orientation, side effects are an unwanted effect that occurs on objects when their state is modified. It can occur in different situations, usually…
-
0
votes7
answers552
viewsA: What is the difference between these parameters (array) in these methods?
About each method Basically what changes is just the signature of the method, they could be doing the same thing. Method exemplo1: an array type value is expected, moreover, this method is receiving…
-
1
votes2
answers74
viewsA: Methods with multiple PHP parameters
Reducing the amount of parameters You can create an object to group all this data or use an array to do so. Each of these approaches has its pros and cons, but both serve as a better alternative…
-
1
votes1
answer150
viewsA: Are models in the MVC structure for database operations only?
Models refer to business rules The Model layer refers to anything related to the application’s business rules, i.e., it is not limited to the database. If the items you listed are part of the rules…
-
3
votes1
answer167
viewsQ: How they work and what the concept of streams in PHP is
I would like to know how it works and what the concept of streams is. I’ve used streams to get input, I also know there are others to control output. However, I would like to know the theory and…
-
2
votes2
answers202
viewsA: Is the third parameter of filter_input required in PHP?
To documentation of function filter_input says the following about the third parameter: "If omitted, FILTER_DEFAULT will be used, which is equivalent to FILTER_UNSAFE_RAW. This will result in no…