@SimonAndréForsberg Do you know if it is possible to intercept log messages and provide own functionality? (Like writing to a XML file in a background thread on INFO messages)
I don't really know for which terminology I should search
I've used Log4j for a long time and I've always wondered why there isn't a newer version than 1.2.x... after that I found Logback which is developed by the same guy
I'm currently having this code & looking for a simpler and shorter way of showing, hiding & disabling my elements...
$("#chReportData").click(function(){
if($(this)[0].checked){
$("#reportDataOptions").show();
} else {
$("#ReportDataStatusO...
I consider fatal errors to be when your application can't do any more useful work. Non-fatal errors are when there's a problem but your application can still continue to function, even at a reduced level of functionality or performance.
Examples of fatal errors include:
Running out of disk spa...
Since my project is getting bigger every day and I am just a starter in the wonderful world of makefiles, I need some help improving mine because, although it works (almost) as I wish, it really started looking like a mess. So it would be nice if someone could help me with it (and of course, advi...
I currenctly have a class which does several requests to a database with several methods (called from main method) sharing this pattern :
public int getSomething(String id, File file) {
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
int lines = 0;
...
Now I think it is time to actually start working on next step of the project :P
I'm converting a prototype application to a live one
Does anyone have advice on how to build a layered application?
Currently the whole application is file/directory-based (moving files to other directories), and every stage is a standalone application taking file from input, processing, writing to output.
Let's say... the prototype version where all functionality was practically in one project... became a mess.
I'm sharing C# code with a fellow programmer who is more use to writing C++. He uses #if and #endif directives (which I do not tend to use) and when they occur they have no indentation, for example
private void dumpToDisplay()
{
#if false
ushort[] ScanStatus = new us...
I have been trying various formats of namespaces and modules patterns, however I have not came across a solution that I would use for all my projects.
I've been developing the following, that would allow me to separate my application through applications, modules, functions and global variables....
Here's the first functional version of my Python 2 script for processing comments in C++ source files. It's a personal project, I expect to expand it later with more advanced options (mainly about replacing comments with whitespace or marking their original positions in the comment-only output).
...
You are given a polynomial of degree n. The polynomial is of the form P(x) = an x n + a n-1 x n-1 + … + a0, where the ai‘s are the coefficients. Given an integer x, write a program that will evaluate P(x).
You are provided with a function named power( ) that takes two positive integers x & y a...
btw @SimonAndréForsberg nothing against your review at codereview.stackexchange.com/questions/45015/…, but I haven't accepted it yet as I heard that @rolfl was also going to answer it, so I'l still wait.
Also, you suggested the use of Executors.cachedThreadPool() there, but I cannot seem to find the possibility to set the upper bound
@skiwi There might not be an upper bound for that one, are you really sure that you need to set one? I'll take a look at the executor methods though to see what I can find
I have to agree with Praveen's comment that you should open a connection when you need it and close it when your are done with the Database operations.
But first I have to make a serious objection to this statement:
ps = conn.prepareStatement(SQL_QUERY.replace("?", id));
That is not the way y...
@FunctionalInterface
public interface SupplierWithIO<T> extends Supplier<T> {
@Override
@Deprecated
default public T get() {
throw new UnsupportedOperationException();
}
public T getWithIO() throws IOException;
}
So I am trying to refactor the following code:
/**
* Returns the duration from the config file.
*
* @return The duration.
*/
private Duration durationFromConfig() {
try {
return durationFromConfigInner();
} catch (IOException ex) {
throw new IllegalStateException("T...
Overriding, Deprecating and defaulting a method at the same time hurts though.
Hmm actually... I wonder if I should declare a new interface here, as I just looked into the Supplier interface and it does not have any other methods as get().
I'm the maintainer of the following library on github: https://github.com/edi9999/docxtemplater/blob/master/coffee/docxgen.coffee
I want to maintain a library that works on node and in the browser, however I don't want to have to update two separate repositories.
The ugliest code looks like thi...
@SimonAndréForsberg my guess is because The requested object does not exist on the server. The link you followed is either outdated, inaccurate, or the server has been instructed not to let you have it.
I have always suffered with too many conditionals in some of my methods. The following is a pseudocode/skeleton of one of my method like that:
private List<ReturnType> DoSth(string name = null)
{
List<ReturnType> names = new List<ReturnType>();
for (int i = 0; i < somearray.Length; i++)...
This is an interesting challenge... The config of the program needs to be able to be modified realtime, and I'm using an ExecutorService with a fixed amount of threads :)
Does using Class and Class.getConstructors() fall under reflection, or is it somewhere in between norma usage and reflection? As you ought to be wary of using reflection.
@konijn I don't know that it's fixed yet: it's locked, but the version which you reviewed hasn't been restored yet. In summary, I suggested that Jamal could do this but he has delayed doing that until he gets your agreement.
@FunctionalInterface
public interface CheckedSupplier<T, E extends Exception> {
public T get() throws E;
}
I wonder if there is any reasoning behind as to why Java does not have default values for methods instead of the current method overloading... (Though method overloading should surely stay!)
I've got a Python script which is meant to launch several other shell scripts with the appropriate setup and parameters. I construct the file paths from other variables so that it's easier to change one setting and have it apply everywhere, rather than hardcoding everything. So, for example:
H...
@konijn I also dropped the HTML tag in Favor of the Javascript tag which should help you find it in your searches. it had two JavaScript Libraries in it, should have had that tag to begin with
An alternative to resorting to AOP, could be to extract a IFileReader interface, and to decorate the FileReader with some LoggingEnabledFileReader - note that sealed explicitly prevents your code from being extensible, I'd drop it (un-sealing a class shouldn't be a breaking change). This solution...
I been working on getting the SocketAsyncEventArgs to work the way I want it to work. Now I was wondering is this going to work how it should work?
/// <summary>
/// The settings to use with this ServerSocket.
/// </summary>
ServerSocketSettings Settings;
/// <summary>
/// The buffer manager fo...
I was asked the following interview question over the phone:
Given an array of integers, produce an array whose values are the product of every other integer
excluding the current index.
Example:
[4, 3, 2, 8] -> [3*2*8, 4*2*8, 4*3*8, 4*3*2] -> [48, 64, 96, 24]
and I gave the following an...
Interesting... Java 9 possibly will try to solve Java on the GPU, Erasure vs Reification, Primitive vs Reference types (without performance cost), new JNI, and of course the delayed custom profiles.
I currently have an ExecutorService where I want the following:
No new tasks should be accepted.
Current tasks should still keep on executing.
All currently queued up tasks should be returned.
The issue I am facing is that the shutdown() will not return any non-executing submitted tasks (in f...
@ChrisW all I'd have to say would relate to the tight coupling going on in the constructor, the multiple responsibilities of the Init method, and the off-putting naming UserToken being of type Connection... I guess I could make an answer out of that...
@Mat'sMug You could. Again, IMO those aren't the topics that the OP wanted answered; but yes I know that reviewers are free to answer/comment on any aspect of the code.
@Mat'sMug Mostly the OP's fault / a hard question. Knowing what APIs result in best performance and predicting whether / how well they scale is difficult e.g. requires specific previous experience. And attacking the Zombie list implies you're trying to answer questions other people found unanswerable.
I still find it unanswerable (as far as OP is concerned), it's just that I do see some things that could be worth mentioning, from a code review perspective. Writing a short answer right now.
I think it's a question best answered by performance/load testing, and/or by researching the literature. The best a code review can do is verify style (maintainability), testability, and inspect for edge-condition (e.g. race condition) bugs.
There is a difference here between HTML and XHTML. XHTML are more strict.
While old regular HTML does not enforce it for all tags, all tags in XHTML must have an ending tag** to validate. Even <br> and <img> is often written as <br /> or <img ... /> to specifically give them ending tags.
XHTML ...