Posts by Caffé • 17,429 points
254 posts
-
12
votes5
answers13505
viewsA: Difference between Object and Instance
Your reference 3 is a super accurate and correct definition: "An object is an instance of an object type". You see right away that instance is the technical thing that allows the existence of an…
-
7
votes1
answer105
viewsA: Lock optimistic; why not fire exception?
The exception is not made for two reasons: 1) No change has been made to the entity in either the first or the second context in which it was obtained and persisted, so there can be no conflict in…
-
13
votes1
answer339
viewsA: What allows a method to be intercepted in C#?
Do you mention the Castle Windsor, which is for injection of dependency, but the content of your question is even related to the Castle Dynamicproxy, which as the name suggests is for the creation…
-
2
votes2
answers560
viewsA: Windows form integration with html page
Using only Html is not possible. You can include in your Html page applications developed with Flash and Silverlight, for example. There was a time when it was very common to also include components…
-
3
votes1
answer270
viewsA: Consume entity repository directly from the application layer
In DDD, the layer of Applying knows how to consume the objects of the Domain to meet the above layer requests (Interface); and in DDD repository is a type of domain object. Now, if the Application…
-
2
votes1
answer107
viewsA: Method with many if and Return
The name Put does not reveal what the method does, so you could write all the code in a new method with an expressive name and call this new method within the Put. Just for having one expressive…
-
2
votes2
answers466
viewsA: Comparing words from a text to an Enum’s list
One option without needing to capture exception: public boolean checkTipo(String texto) { List<String> palavras = Arrays.asList(texto.toUpperCase().split(" ")); for (TipoPokemon tipoPokemon :…
-
4
votes2
answers188
viewsA: Is it possible to return a variable from an object-oriented class without using a function?
Implement in your class: public String toString() { return side; } The rest of the code can stay as it is. What happens is that the method toString() is called to convert your object to string when…
-
4
votes2
answers4529
viewsA: What is the concept of Stubs and Drivers in integration tests?
What is the concept of driver and stub in integration tests? Driver and Stub are stuntmen (doubles, also known as mocks), whose function is to replace a component during automated or non-automatic…
-
1
votes2
answers1269
viewsA: Save without accents and uppercase SQL Server
The collation SQL cannot help in this case. It will define at most that the accentuation and the marry (uppercase/lowercase) should be ignored in searches. To make the conversion and in fact persist…
-
6
votes4
answers549
viewsA: Problem with polymorphism
The @Maniero response is quite simple, but it doesn’t solve a AP requirement that is to avoid using if. To meet this requirement, it is necessary to go a little further, eventually using interfaces…
-
2
votes1
answer274
viewsA: How to generate compiled classes and maintain the. java in Maven?
Include the following Resource in the pom.xml: <resource> <directory>${basedir}/src/main/java</directory> </resource> See more or less how it would look in the general…
-
12
votes4
answers4928
viewsA: How to estimate development time?
There are basically two methods to estimate software development cost: to) Guess how much will it cost. b) Measure how much will it cost. All estimation methods are derived from these two basic ways…
software-engineeringanswered Caffé 17,429 -
6
votes1
answer640
viewsA: How do you know when Brooks' law applies?
There are several different views on each aspect of a software project; and many of these points are very well grounded. All this diversity can bring the notion that this is a subjective subject…
-
4
votes2
answers321
viewsA: Are static classes shared by threads?
Classes, methods, and static properties are shared across application threads? Yes, but not only static members but also any class member, static or otherwise, can be shared between threads. Is…
-
4
votes2
answers90
viewsA: In C# is there variadic Arguments (infinite arguments)?
Yes, there is. Example: string.Format(string format, params object[] args); Consumption: string.Format("Meu nome é {0}, eu tenho {1} anos", "Caffé", 36); The difference is that in C# the typing is…
-
3
votes2
answers116
viewsA: How to create a template with just a few table fields?
Using ORM, it is always complicated to define more than one entity for the same table. But because of this limitation we end up discovering that we don’t need to do this; that doing so increases the…
-
6
votes6
answers2755
viewsA: Is it bad practice to use only static methods in a class?
It is bad practice to use only static methods in a class? No, it’s not bad practice. A completely static class can make sense even in a very well organized code. Completely static class evades OOP…
-
5
votes5
answers1775
viewsA: Why is it bad practice to have int attributes?
Competition If this class can be instantiated by more than one thread, declare the counter as Atomicinteger to ensure its integrity. Example: private static AtomicInteger contador = new…
-
2
votes2
answers137
viewsA: Development in three layers
Both ways are valid in 3-layer development. Just aligning the concept of three layers (despite being a classical, ancient and consolidated definition, one may not be familiar): the layers are…
-
3
votes4
answers835
views -
3
votes1
answer206
viewsA: Make Java Application Run as a Service
You can’t make a Java application run as a service on Windows using only Java. You will need to make another application, in another language (.Net, C++...) encapsulating yours. This other…
-
11
votes2
answers1839
viewsA: Switch Alternative Inside Switch
In fact the command switch-case is enough ugly and almost always expendable. Instead of using this command or long chains of if-elseif-elseif..., you can use dictionaries. In your case, you would…
-
6
votes1
answer865
viewsA: Locate in the Delphi
The method Locate position the cursor on the first record whose specified column is equal or (partially equal) to the specified value, returning false if you do not find registration under these…
-
8
votes1
answer86
viewsA: Class Rectangle, is there a circular class?
Yes, there is. It’s the Ellipse2d You can use your methods contains and intersects to check collisions. Of course an ellipse is not necessarily a circle; but an ellipse with height and width of the…
-
4
votes3
answers118
viewsA: Code repetition in the same method
The Re-factoring for duplicate code deletion is quite simple: 1) Declare a new method (it will receive the code that generalizes the solution that today is duplicated). 2) Traverse the code of the…
-
3
votes3
answers6231
viewsA: How to compare the structure of two SQL Server databases?
You can make a tool for it yourself; it’s very simple (and it’s even simpler because you only have one type of database server involved). Just consult the database metadata in order to list tables…
-
1
votes1
answer197
viewsA: Adodataset Delphi Edit
Standard approach The general practice is: when one wants to edit the result of a query involving multiple tables and update the database, one recovers in a separate query the records only of the…
-
3
votes5
answers440
viewsA: What would an Agile Development Process look like?
An Agile development process is one that observes the Agile Manifesto, that is: respects its values and applies its principles in search of his goal. And the goal is given by the first principle of…
-
3
votes2
answers80
viewsA: Where to create a database without privileges
Microsoft Excel. In it you can also create forms, program in VBA and persist in the Access model, using SQL, without dependence on other software. You don’t have Access "Wizards", so it takes more…
-
1
votes2
answers17826
viewsA: How to select in date format?
Responding, the error in the Insert is given because you try to inform the date in a format not expected by the bank, and the unexpected result in the select is for the same reason. Explaining: the…
-
2
votes1
answer2729
viewsA: How can I browse and edit a txt file in Java
The code below loads all lines of the text file into memory, changes characters 8 to 15 of the first line, and saves back to file all lines, including the altered line: import java.io.IOException;…
-
1
votes1
answer329
viewsA: Pick string from a textarea and populate an object
I solve this by making my own library based on class annotations. It’s very simple to do! The idea is declare the different layouts of TXT files as Java classes, and then use a generic parser that,…
-
0
votes3
answers1305
viewsA: List records that are in a table and those that are not in the same table
It works: select user.id, user.name, ponto.dataPonto, ponto.entrada01, ponto.saida01, ponto.entrada02, ponto.saida02, case when ponto.dataPonto is not null then 'sim' else 'não' end bateu_ponto from…
-
2
votes3
answers410
viewsA: Call a method automatically via a partial class on . NET
Don’t forget that your property Handle has a getter, where you can write any code, including by doing this getter return function result makeHandle(): public string handle { get { return…
-
1
votes1
answer118
viewsA: Saturation of Foreign Keys?
Foreign Keys in the database are optional, you create them if you want to leave with the database server the guarantee of relational integrity; for example: the bank will not let create a record…
-
4
votes3
answers342
viewsA: Where should I put a calculation method? In the entity itself or in the business class?
In the object orientation paradigm, an object in its most basic form has behaviors. If an object has no behavior, it is nothing more than a data structure (whose Java statement and instance have the…
-
2
votes2
answers454
viewsA: Hide screen options if user does not have permission
You can use namespace facelets security Spring to conditionally render JSF components (including Primefaces), as authorized by the current user. The namespace is…
-
5
votes1
answer468
viewsA: Why use unless in Laravel instead of a no if denial?
I don’t program in PHP, I know the unless for programming in Ruby. As you may have noticed: unless is the inversion of if, so instead of you making a if on a denied condition, if it makes more sense…
-
1
votes1
answer465
viewsA: Competition with thread and database inserting duplicates
One option is to search for the incremented value within the Insert command itself, more or less like this: insert into item_cupom(cupom_id, nr_item) values(?, (select max(nr_item) + 1 from…
-
8
votes1
answer738
viewsA: What is Application Rules and what are the differences with Business Rules?
The layers of a system Ordinary software, such as a web application, for example, can be divided into a few conceptual layers: Interface App Business Infrastructure There are systems in which some…
-
1
votes1
answer61
viewsA: How to bring the name of the fields and type of an oracle table in c#
This query returns the field names and types of a table: select COLUMN_NAME, DATA_TYPE from ALL_TAB_COLUMNS where TABLE_NAME = 'NOME_TABELA' Just run it using your standard SQL query engine and read…
-
14
votes3
answers10118
viewsA: Where should the business rule be in the MVC standard?
Where the MVC standard business rule should be? If there really is business logic, and especially if it is complex, it should stay in the Model. The concern that the creation of Pattern MVC (back in…
-
1
votes2
answers215
viewsA: What are Git mod sets really?
What are modification sets in Git "Set of modifications" is to Changeset, that is unrelated to how Git stores changes. Changeset is a core concept of Git and is also present in several other source…
-
2
votes2
answers1199
viewsA: Where to close Entitymanager
Separation of responsibilities Most systems can be divided into some conceptual layers: Interface or presentation: screens/forms/pages or service facade for external consumption. Applying: receives…
-
2
votes3
answers4914
viewsA: Run VBA code from text file
The solution is to use VBS instead Excel VBA, as said by @Miguel Angelo. Below follow more details (I was complementing his reply but it ended up getting too long). First program in VBS - create a…
-
4
votes1
answer310
viewsA: Abstract class and C#properties?
You’re experiencing a very common problem that happens when we see in inheritance a solution for code reuse: it is difficult to find in the hierarchical chain the right class to publish an attribute…
-
8
votes4
answers2243
viewsA: Alternative to CPF (Foreign Users)
Depending on what "controlling the user" means, it depends on the customer’s business requirements. The user’s CPF is useful to the client’s business or you only need it for technical reasons…
-
1
votes2
answers854
viewsA: Error on close executable
At startup, the application created the forms and kept reference to them in order to be able to destroy them later, when it was closed. The code of Button3click destroys the forms created by the…
-
5
votes4
answers607
viewsA: Object orientation - How to find the right abstractions?
Although many people simply interpret the verse "Object Orientation helps represent the real world", the fact is that it is exactly this idea that will help you find the right abstractions.…