Posts by Piovezan • 15,850 points
395 posts
-
1
votes0
answers49
viewsQ: Two observable watching each other? Or something different from that?
Consider a class ServidorTcp (I don’t know if this is the right abstraction; it would have two operations, iniciar() and parar()). Inside there’s a field socketServer whose type is SocketServer (a…
-
1
votes1
answer51
viewsQ: Are requirements found or created?
There is talk of Requirements Survey or Requirements Elicitation (make appear). Also Requirements Collection. It’s an investigative task. It is not clear to me whether requirements are found (exist…
-
5
votes1
answer42
viewsQ: In Java Swing, should I extend Jpanel and top-level containers like Jframe?
Has in the Soen but I was not satisfied with the answers, and temporarily I am not able to ask IF.. Top-level containers like the JFrame I guess there’s no need, but a JPanel kind of made to be an…
-
1
votes0
answers21
viewsQ: Observers can be injected into the observable?
It’s a half-ass question whose answer might be "make the most sense of the code," but it doesn’t hurt to ask. The pattern Observer suggests that an observer register (via…
-
2
votes2
answers176
viewsQ: Is Scrum an incomplete methodology? Or: Does Agile Need UML?
Scrum and Agile are very popular, but what do they offer in benefits? In the case of Scrum I see continuous improvement (retrospective), proximity to the stakeholders (the action of product Owner),…
-
0
votes1
answer89
viewsA: How can I take a private variable in another class in Java?
The shortest and laziest answer is, you create a public method getNumero() in class Inicio which returns the private number, and calls this method in the class Final. But this is wrong. In object…
-
3
votes1
answer1135
viewsA: What is Static in Java? And How to use it?
Drawn from here. In Java, you can have 3 "Static" things: boot blocks, variables/methods and internal classes. First you need to understand the following. Static is the same thing as "class", not…
-
1
votes2
answers61
viewsA: Do generic Helper/Utility classes hurt the Single Responsibility Principle (SRP)?
In object orientation, which I am assuming to be the case, the implementation of a method may depend on data (fields) of a given object. It may also depend on other objects, which there involves…
-
0
votes1
answer851
viewsA: Error adding students to a class 'The Given id must not be null! '
In this passage: Turma turma = turmasRepository.getOne(codigoTurma); aluno = alunosRepository.getOne(aluno.getCodigo()); Or codigoTurma or aluno.getCodigo() is void (null). Avoid passing id void, as…
-
0
votes2
answers543
viewsA: How to generate random numbers without rethinking in Java?
A possibility: quantidade = ???; Set<Integer> numeros = new HashSet<>(); Random rnd = new Random(semente); while (numeros.size() < quantidade) { numeros.add(rnd.nextInt(60) + 1); }…
-
0
votes1
answer69
viewsA: How to connect Oracle to Java? This error appears "Error while registering: oracle.jdbc.driver.Oracledriver"
Probably the driver is not in the classpath. How to add to classpath will depend on your configuration (Eclipse, Netbeans, Intellij Idea, Maven, Gradle, files. jar added in hand, etc...).…
-
1
votes2
answers116
viewsA: In Java, what is the purpose of calling interface methods on objects from other classes?
The method eval() (which means evaluate, i.e., evaluate) the interface Node really does nothing because it’s just a contract. It’s there to force whoever implements this interface to implement this…
-
2
votes1
answer121
views -
5
votes3
answers464
viewsQ: What is a Guard clause?
What is a Guard clause? Possible translations and synonyms: Custody clause Guard status Sentinel clause Prevention clause Protection clause Fuller definition. What are its advantages? The code is…
-
1
votes2
answers67
viewsA: How to pause Thread while Alert runs within Platform.runLater - Javafx Java
The solution, taken from here, is to pause the thread using the communication resources between Java threads, in this case FutureTask: System.out.println("inciando Thread, executa tarefas "); String…
-
0
votes1
answer267
viewsA: What parts of a project are part of the infrastructure layer?
If you apply to layered architecture (Layered Architecture) in its application, then the infrastructure is one of the logical layers (in the sense of non-physical), called infrastructure layer…
-
2
votes1
answer139
viewsQ: In the CPU time equation (Tcpu) what are the number of instructions (IC) and cycles per instruction (CPI)?
Of a slide about computer organization: Performance of instructions A particular programme shall require: a number of machine instructions a certain number of cycles a certain number of seconds…
-
2
votes1
answer45
viewsQ: How far do you try to predict the future when designing an application?
How far can we or should we try to predict the future when designing an application? Be it architecturally or in design. What makes a rugged change-face design without being overly planned? It is a…
-
2
votes2
answers1221
viewsQ: Code revision of the CPF class in Java
You can review the code of my CPF class? A point of criticism is the use of regex which may be unnecessary. But in my view it makes the code shorter. Another point is the adoption of a class for…
-
1
votes3
answers3586
viewsA: In programming, what is an object?
I translate and comment here the definitions of Wikipedia in English, with a point to improve in the definition referring to object orientation. In computer science, an object can be a variable, a…
-
0
votes1
answer89
viewsA: Should I use Thread.Sleep() for my program not to occupy the processor?
This tick count is unnecessary. As Maniero said, the architecture is wrong. Also this thread there is unnecessary. It is only necessary to call (schedule) repaint() in the Event Dispatch Thread…
-
1
votes1
answer24
viewsA: (Java) Error while continuing to traverse TXT lines
See if it makes sense to you. Remove the condition total_min < 720 if and in place of antes_almoco.add(linha) place: if (total_min < 720) { antes_almoco.add(linha); } else if (total_min >…
-
4
votes2
answers108
viewsA: Why don’t files show your bits?
From 8 bits to 8 bits form a byte, each byte in extended ASCII encoding is shown as a character (or in some other encoding; the number of bits representing the character may vary). Or trying to…
-
1
votes1
answer59
viewsA: (Java) Read TXT (input) and generate TXT (output) with organized information
You can test if the line is null before calling linha.toLowerCase(). while (linha != null) { linha = lerArq.readLine(); System.out.println(linha); String trinta_min = "30min"; boolean sao30min =…
-
2
votes1
answer94
viewsA: How to use the Scanner class to read two inputs separated by a Java space, and by two different variables?
Just use one scanner and apply split(" ") to the String returned by him: input = s1.nextLine(); String [] palavras = input.split(" "); for (String palavra : palavras) { System.out.println(palavra);…
-
4
votes1
answer44
viewsQ: Heap things on a function x DRY
That bold bit taken from here it wasn’t very clear to me: DRY solves what? Some may still be thinking that DRY is to reduce typing. Or at least gain maintenance time. It’s even in the latter case,…
-
1
votes1
answer21
viewsA: How to add "" to an input
That line: scanf("%s\n", p); should be: scanf("%s\n", &p); But if you want to fit a word will not fit, only one character fits. To fit a word use array.…
-
0
votes1
answer138
viewsA: My application is done in webview and by clicking back with the android phone button it shows the msg Auncher stopped
You are creating and initiating a local variable called webView not the instance variable of the same name. You should initialize the instance variable. In other words, change that line: WebView…
-
5
votes1
answer142
viewsA: Prototype of python application
The algorithm for registering the password is wrong. You have to ask twice for the password and confirm if it is the same, if you don’t have to error. The code does not use loops (loops), such as…
-
0
votes1
answer44
viewsA: Use cases for color guessing game
No, they are not well defined. The system should not be his own actor. The player makes sense to be an actor and their two use cases are correct, bring something of value to the same: play game and…
-
1
votes1
answer44
viewsQ: Use cases for color guessing game
In order to practice APOO I am trying to apply use cases to a simple game of guessing a color. Here it would be it visually. The user can try to guess as many times as he wants, or restart the game…
-
3
votes1
answer2002
viewsQ: What is Java 8 Optional for? How to use it?
What is the use of Optional Java 8? How to use this feature? The best answers I found on the site were these... What is the difference between the orelse() and orElseGet() methods of…
-
6
votes2
answers119
viewsQ: C# properties for those who know Java
What a Java programmer needs to know about basic properties (properties) in order to read code written in C#?
-
3
votes2
answers77
viewsA: Using integers as Java Locks
The Integer in that case it is not treated as anything in particular other than being an object. So much so that it could be a Object in his stead. Virtually any object can be used as lock for…
-
0
votes1
answer71
viewsA: Java - Thread Synchronization Questions
I’ll be brief that I’m on the cell phone. With Join() it’s wrong because threads run one at a time and that’s not what you want. Your code has two other errors. First, the Synchronized block is…
-
1
votes1
answer48
viewsQ: Cardinality of MVC on desktop
What should be the cardinality of the desktop MVC? Models: typically one, there may be more. Views: how many are observing the model, or a tree, representing approximately the GUI? Vision should…
-
2
votes1
answer164
viewsQ: In what order to dispose the methods of a Java class?
In which order to dispose the methods of a Java class? Whereas a class can have: constructors, static methods, private methods, public methods, abstract methods. For example: public class Classe {…
-
4
votes1
answer59
viewsQ: How to deal encapsulated a field that is a list of immutable elements?
Imagine that you have an object and one of its fields is a list of immutable elements. You want to make this field available to the clients of this object in a controlled way, after all a list can…
-
0
votes2
answers101
viewsA: MVC desktop - where is the Controller?
The role of the Controller is to receive the inputs from the user from the View, validate the data if this is the case and pass to the Model. Then notify the View of changes to the Model if the…
-
0
votes2
answers101
viewsQ: MVC desktop - where is the Controller?
I modified it this example of MVC to try to make it more like my MVC vision (in which the role of the Controller is not very clear). I ended up with a program that only has Views and Model, without…
-
5
votes1
answer92
viewsQ: Why are certain domains easier to model than others?
I have heard about certain domains, such as Guis and games, which are more "abstracted", or are already abstractions, or are "mechanisms", in short, have a distinction in relation to other domains.…
-
7
votes1
answer140
viewsQ: Is the purpose of the inheritance reuse?
Many say that the goal of object-oriented inheritance is to promote code reuse, but I believe this is a mistake. I remember (or think) reading that the goal is NOT reuse but I don’t remember now…
-
2
votes1
answer86
viewsA: What is the purpose of the Servlet protected void service method and why can’t you override it?
You are in contradiction because first you say that you cannot overwrite the method service() and then says he calls it superscript. It may be overwritten, but that’s not necessary. As says the…
-
0
votes2
answers87
viewsA: Insert Widget into a list with Defaultlistmodel [JAVA]
Try to overwrite (override) the method toString() class Cargo to make it return the value you want to appear. It should work. This code that is currently being returned is the default return of…
-
1
votes1
answer302
viewsA: How to run commands in the Maven plugin for Eclipse?
I found out. 1) Right click on pom.xml 2) Select Run As > Run Configurations... 3) Open a window Create, manage and run configurations. 4) Left hand side below Maven Build is the list of settings…
-
0
votes1
answer302
viewsQ: How to run commands in the Maven plugin for Eclipse?
I use the Maven plugin for Eclipse but I don’t know much about technology. You can run Maven commands (even typing: mvn compile for example) without having to install Maven separately? The answers I…
-
1
votes1
answer81
viewsA: Java competition, simple example, multi-threaded hash map not secure
You don’t need to sync the HashMap nor adopt ConcurrentHashMap. Just synchronize the methods that access it: public class SimpleVoteCounter { private final Map<Integer, Integer>…
-
15
votes3
answers2559
viewsQ: What is the difference between software, program, app, and system?
Obvious question that escaped long of being asked here at Sopt. Software Program Application / application App Information system What’s the difference? I believe I know the answer, but let’s see if…
-
9
votes2
answers650
viewsQ: What is Separation of Interests (Soc - Separation of Concerns)?
I noticed that we don’t have a question about this topic. Separation of Concerns (Soc), also known as: Separation of interests Separation of concerns Separation of responsibilities Separation of…
-
1
votes1
answer88
viewsA: capture duplicity error in mysql with java
You are using Try/catch in the wrong place. The exception is thrown in the following line: pst.executeUpdate(); You can use the catch below to capture the most specific exception you want: } catch…