Posts by utluiz • 72,075 points
957 posts
-
1
votes3
answers539
viewsA: Byte separation
Setting a goal The first thing is to understand what you are doing. Basically you are creating your own protocol. This protocol defines the format in which you are creating a message and the…
-
9
votes1
answer1729
viewsA: What are the modules?
Java and its "patterns" Java is champion in misrepresenting patterns, for better or for worse. When Hibernate popularized Orms in Java, the JPA standard was created. Its adoption occurred gradually…
-
48
votes4
answers26848
viewsA: What’s the difference between DAO and Repository?
Warning: I decided to risk an answer because I found the other confused or abstract, giving room to different interpretations about the patterns. TL;DR DAO and Repository are two standards of…
-
0
votes1
answer56
viewsA: Is it possible to cancel a JDBC connection?
Specifically for the Postgresql Driver, according to changelog, at least from the version 9.3-1101 of 14/02/2014 you can call Thread.interrupt() on Thread trying to make the connection. This is a…
-
2
votes1
answer331
viewsA: Create a web application that runs Junit test cases on java files that will be submitted by a page?
Disregarding the security involved, this can be even easy. However, do not try to run within your application. Create an empty project (no classes) in some server directory that has the necessary…
-
6
votes3
answers1754
viewsA: What is called the replaceable method in the constructor?
What is Replaceable method means a method that can be superscripted by a subclass. The warning This is just one Warning of its IDE on a potential problem, not necessarily an error or something…
-
7
votes3
answers2210
viewsA: What is the purpose of the builder of an Enum?
TL;DR Enums constructors have exactly the same purpose as constructors in classes, initialize values. Enums are nothing more than a specific type of class. Enums are classes The first thing to…
-
1
votes1
answer1827
viewsA: Generate PDF report with Jasper Reports and spring
The problem is that the browser is not getting a name for the received file. I have seen systems one the "name" of all the saved reports was relatorio.jsp because this was a view that sent content.…
-
5
votes3
answers246
viewsA: Deal with exception that guaranteed will not occur
TL;DR The shape correct to deal with exceptions that should not occur is not to use them in the first place. Deducting the scenario You must have the code something like this: Produto…
-
13
votes3
answers590
viewsA: Doubt about Inheritance
On the nature of the example Avô, Pai/Mãe and Filho are terrible examples of inheritance and maybe that’s what caused confusion. If a class Gato inherits from the class Animal, we say that a Gato is…
-
5
votes2
answers960
viewsA: Technologies for Instant Messaging App
There are several ways to implement a communication application. However, I will make some considerations. Real time? No APP is exactly in real time. Who uses Whatsapp, Google Hangouts or Facebook…
-
53
votes3
answers53541
viewsA: How does the DAO Standard work?
Definition In summary, DAO is a pattern of projects where an object: provides an interface that abstracts data access; reads and writes from the data source (database, file, memory, etc.); and…
-
9
votes7
answers22208
viewsA: Is using MD5 the safest way to encrypt passwords in PHP?
The answer is simply nay, MD5 is not the safest and was not near the first placed. :) Hash != security The first thing that needs to be demystified is that encryption or hash generation algorithms…
-
5
votes1
answer3334
viewsA: Clone private repository by passing password as parameter
On an internal server, you can try using the following format: git clone -b meu-branch http://usuario:[email protected] However, keep in mind that this user URL and password will potentially…
-
6
votes1
answer1084
viewsA: Redirect System.out.println output to Jtextarea
Yes we can! Yes, it is possible to change the object System.out that usually goes to the console using the method System.setOut. Just then pass an instance of PrintStream to direct the content to…
-
6
votes3
answers394
viewsA: What does it mean to assign Math.Random() > 0.5 to a variable?
The intention of the author of the code is that each element of the vector has a 50% chance of being true and 50% chance of being false. In practice, that’s not going to be fully truth for…
-
1
votes2
answers264
viewsA: Server Side Only Rest Api
If I understand correctly, the browsers of the users of the other application will make Ajax requests to your Web Service. In this case you cannot and should not attempt to authenticate this other…
-
9
votes1
answer163
viewsA: Using Connection is polymorphism?
Yes. The type of return of the method getConnection is the interface Connection. Soon, you are seeing only the interface to not the implementation, which can be of various "flavors". Defining…
-
8
votes10
answers1739
viewsA: How to count the zeroes to the right of a number?
Java version byte rightZeros(long n) { for (byte z = 0; ; z++, n /= 10) { if (n < 10 || n % 10 != 0) return z; } } Code in Ideone Python version def right_zeros(n): z = 0 while True: n, r =…
-
23
votes1
answer782
viewsA: Create classes taking advantage of lambda
Understanding and using Java is very simple even for those who have never heard of it, as long as you have a good foundation on some aspects of the language, concept of listeners or callbacks and…
-
9
votes2
answers938
viewsA: Using hashcode as id is good practice?
Depends. Unique value It’s not good practice if the idea is to create an ID single. Hashes are a simplification of content and every simplification loses information because there’s no way you can…
-
4
votes1
answer775
viewsA: Why can’t I see Javac?
If in the question itself you say the name is JRE then it is not JDK. Therefore... Or you did not install JDK (development) but JRE (execution), which does not have the javac Either you installed…
-
1
votes2
answers462
viewsA: What technology to use to develop a Webservices for Android
TL;DR The truth is that from the point of view of the client App, it makes no difference at all in which technology the Web Service is implemented. This is precisely the idea of Web Services to…
-
0
votes3
answers1843
viewsA: PHP - How to send data from a table to a form
The simplest way to solve, without Javascript, without gambiarra, is by using hidden fields. For that, you will need a form for each line. Example: <table class="table"> <tr…
-
3
votes4
answers1784
viewsA: Confirmation of sending email?
It is not possible to know for sure if someone received or read an email, but a simple alternative is to put a link to the actual message, so you can check whether the link was accessed or not.…
-
5
votes1
answer92
viewsA: Change of environment
TL;DR In general, Java and . NET have many points in common and can achieve the same goals although with greater or lesser difficulties in different areas. Let’s go in pieces... Cost Are licenses…
-
6
votes1
answer1131
viewsA: What’s left to configure with Spring boot?
Configuring with Spring Boot If this project used spring boot, what settings would still be needed to configure in the classes? In fact, you could remove part of the settings, because the idea of…
-
3
votes1
answer254
viewsA: Replace string by holding the box (uppercase/lowercase)
You use the method gsub of the string to do the substitution using regular expression, but instead of passing a second fixed parameter, use a block of code to process each snippet found according to…
-
21
votes3
answers1989
viewsA: How do I know if the first digit of a string is a number?
If the idea is to check only numbers of 0 to 9, the simplest, fastest and efficient way is: character >= '0' && character <= '9' You can create a simple routine like this: public class…
-
1
votes1
answer87
viewsA: How to create bookmark in logback?
The problem is that your appender does not support notifications. See that in the example, he uses ch.qos.logback.classic.net.SMTPAppender, that has special implementations to send a notification…
-
4
votes1
answer1984
viewsQ: How to drag a div on my page?
How can I implement a drag and drop in div without that element messing with other elements of my page and getting over them? I also needed him to stay where he was before if I push Esc.…
-
3
votes1
answer853
viewsA: Creating doc or docx file
You won’t find anything too chewy. Directly manipulating the XML document However, depending on the purpose, if it is something simple like adding a small text in an existing file, this can be done…
-
3
votes3
answers1081
viewsA: Sort chained list with O(n*log(n) method)
Based on table linked by @Maniero, there are at least 4 sorting algorithms which, on average, are of complexity O(n*log(n)), namely: Quicksort Mergesort Timsort Heapsort Copy the data to a array may…
-
2
votes1
answer189
viewsA: How to read a return Map<String, String> Java in javascript?
To determine with certainty the problem would have to have the code that makes the call, but based on two answers of the OS with the same error message, I can assume that the problem can be fixed…
-
20
votes2
answers1527
viewsQ: What are and how do . NET technologies relate to developing web systems?
Many years ago I programmed a little in classic ASP and did not follow the evolution of products. Classic ASP basically consisted of files .asp with code whose language was a variation of Basic,…
-
1
votes1
answer348
viewsQ: How to build a relative URL securely?
A method takes snippets from a URL and needs to concatenate them coherently, but without presupposing details about each one. Examples: http://server + /path + /resource.js =>…
-
17
votes1
answer1971
viewsQ: How to carry out communication between Microservices (microservices)?
Microservices is a type of architectural pattern where an application is divided into smaller, independent applications that communicate to accomplish the complete work of the system. The common…
microservicesasked utluiz 72,075 -
10
votes1
answer247
viewsQ: What are the differences between mocks and fakes?
When we implement tests in software, Mocks and Fakes are two techniques or approaches to isolate the code being tested from the rest of the system. Without going into it: Mocks are like empty shells…
-
7
votes2
answers2050
viewsA: How to show only "x" characters in a div?
First of all, there are several ways to do this. For example: Showing partial content based on height. You set the height of the element and the "Show more" button or link simply leaves the height…
-
0
votes1
answer116
viewsA: Facebook namespace not working in JSF?
Your problem has nothing to do with the server or JSF. The first thing you should do to check what happens is to look at the source code of the online page. I did that and the tags are there…
-
2
votes2
answers1743
viewsA: Jdbctemplate - How to commit and rollback?
Activating AOP One of the things that confuses the use of annotations is that you often need to configure your framework to make it work properly. See, for Spring to be able to intercept the call to…
-
3
votes1
answer597
viewsA: Java String byte array with negative numbers
If entrada for a String, you already have it decoded and no use trying to convert it. It seems to me what you’re trying to do is convert the String in bytes and then bytes in a String again. This…
-
16
votes3
answers8112
viewsA: Is there any way to pass methods as a parameter?
TL;DR There are several ways to parameterize methods in Java: The lowest level by reflection; The traditional one using a specific interface; Directly in the most modern form introduced in Java 8…
-
6
votes4
answers607
viewsA: Object orientation - How to find the right abstractions?
I’ll risk a simplistic answer to the main question: How to find the right abstractions? Top-down approach In a personal reflection, I came to the conclusion that one of the ways to solve problems…
-
4
votes2
answers1267
viewsA: Dynamically update application
High availability Updating the version of a web application without interruption for users is a big challenge. Having a high availability means increasing costs and work. Think, for example, of the…
-
0
votes1
answer475
views -
6
votes4
answers1204
views -
7
votes4
answers4276
viewsA: Should I initialize strings (or objects in general) with null?
In Java, it is not mandatory to initialize class attributes. Primitive types receive default values and objects are null automatically. However, variables declared within the body of a method do not…
-
6
votes2
answers733
views -
1
votes2
answers1129
viewsA: How do I know if a socket client has disconnected?
One EOFException is launched if the client disconnects unexpectedly, since the socket can no longer read data means a unexpected end. You can see an example of a chat server I did to answer the…