def get_range_list(amount, val, end):
('flcon1:DataValue~Osiris_Test_Data_' + str(i + 1) + end, randint(0, val))
for i in range(amount)
You're only interested in the value of amount, not in the variable it produces itself. Have you tried using xrange instead? xrange is much faster than range.
Afar from that, I cut-out the ...
Start using New IO
The java.io packages have been replaced for a reason. They don't integrate well into what the language tries to become and are at best unwieldy. Instead you should rely on the new IO or nio packages, that work on Paths instead of Strings and have some other advantages.
Loading your properties can be simplified to:
Low hanging fruit
Most of this will come down to reading PEP8, however I'll state them here anyway.
From the top down:
If statements don't need brackets, so don't put them around them.
Functions at module level should have two new lines between them and other things.
Rather than one as you have now.
You should use snake_case for functions and variables.
I'd wrap the <Component>s in a <Components> tag. Maybe you want to add more attributes to spells later. In fact, I'd probably make <ItemComponents> and <SpellComponents>.
I'm also thinking you might be better off here and there by using some sort of "quantity". Lets say a spell had 10 components (for some arbitrary game design reason)...
They're right. While "</Whatever>" is hard to read itself (YMMV), the constants make it even worse.
Magical constants in a code are bad and should usually be extracted as you did. But if there are many of them and each gets used just once, it's counterproductive.
The best solution would be something like
There are .NET Naming Guidelines which state that methods should be named using PascalCase casing. You haven't done this for buildString().
The InnerXml property returns a string hence there is no need to call ToString() on the property.
Because all methods are public you should do proper parameter validation. At least you should check if ...
You need to use the two Streams as, well, streams: read a manageable part of the input, transform it, write it to the output and repeat.
int bufferSize = 4096; // or whatever
char characters = new char[bufferSize];
using (var reader = new StreamReader(inFile))
using (var writer = new StreamWriter(inFile + ".NonAsciiChars"))
To keep your xaml looking clean, I reccommend using self closing tags
Explicitly set properties instead of using the > content area < of a tag. Doing such more explicitly shows what the content is used for.
<Label Grid.Row="0" Grid.Column="0" Content="First ...
StringWriter and XmlWriter are both IDisposable hence their usage should be wrapped in a using statement
The prefixing o of your local variables smells a bit of hungarian notation which generally does not convey a lot of useful information.
The encoding has already been mentioned in the comments. In .NET strings are UTF-16 so you use should that instead.
I wasn't originally going to post this answer as it seems like petty things, but alas, here it is. I mean no offense by any of it, sometimes I tend to type things out to seem that way, but it's all in good spirit. :)
I was reading through your code and couldn't figure out why it was so hard to read, until I realized you seem to be trying ...
Firstly, I'm not familiar with the JavaFX nor PostgreSQL technologies, so my comments will be aimed more at Java-specific code practices. See also the answers by Vogel612 and Antot.
Java makes memory management simpler, because it is a garbage-collected language. However, main memory is not the only resource your program will use....
Before anything, I reckon you should have a look at PEP 8 which is the usual Style Guide for Python Code. Among other things, your names for variables and functions does not follow the lowercase_with_words_separated_by_underscores convention.
def checkAllVersions(self, currentVersion, allHist):
historyLength = len(allHist)
for i in range(...
Josay's answer is excellent. Just wanted to add one more detail:
In your code, you use large blocks of comments above your functions to describe what they do. You should consider using docstrings instead.
So, for example, your first function would look something like...
def loadAllVersions(self, hist):
Load all version numbers into a list. ...
XML based configuration structures often tend to change during the development-cycle of the product. It is good to plan ahead, but you should also expect to run in to something that needs a format change.
First though, the structure you have for your XML appears clean, and good. The presentation you have is good and neat. That makes it nice to review.
Initializing should be done automatically from your constructor. Right now you're exposing it as a public method that may or may not get called: this will guaranteed cause problems when someone forgets to initialize. Considering it doesn't add value in the first place I would just call it automatically in your constructor.
Use comments to convey why you're ...
public static final String RUBBERDUCK_PATH = "RetailCoder.VBE/UI";
This value shouldn't be compiled into the binary. It should be a configurable setting that's modifiable without needing to recompile.
"RetailCoder.VBE" is a relic of the original project, before it was even called "Rubberduck", when the Mug formerly known as @retailcoder was mucking around ...
I totally agree with Vogel612's observations.
Since there is a lot of code for this review, I'd like to add a couple of items.
In getConnnection() method, there are three issues, two of them are quite serious:
There is a careless call of System.exit(0). I'll just recall a sentence from the good old Hardcore Java about it:
If you ...
Overall, it’s pretty good. I can follow what you’re doing fairly easily, and the docstrings make it easy to see what each function does (even though I’ve not used this module before). Here are some suggestions for how you could make your code more “Pythonic”, and more compact:
Take a look at PEP 8, which is the style guide for Python. Two obvious ways in ...
I don't know what the standards are for Layout Naming on Android, but I can tell you that these names are not very good.
none of these accurately describes what they do.
you should probably look for naming schemes on Google.
btn_distance_walked doesn't tell us what the button is going to do. What is it going to do ...
@svick's approach is the right one, given these considerations
the input file can be as big as 4 GB
the data may all be on two lines
However I would suggest that regular expressions are the wrong tool for the job, and you will find it faster to use a StreamReader with a specified encoding.
There is a method Encoding.GetEncoding that does the ...
Try this query instead on your data and tell how it performs. Not sure it will return exactly the same as your query but it should be close enough so you can adjust to what you want.
O.Value as OldValue,
N.Value as NewValue
from dbo.Cases as C
cross apply (
First of all, I'd split the convert method out into it's own thing - separate from the loading and saving:
// Load xml
XDocument xDocument = XDocument.Load(FilePath_CSVToXML);
string data = Convert(xDocument);
// Do whatever it is you want to do with the results
var testpath = AppDomain....
Two of the specific requirements on the server side are:
server must run until Ctrl-c is pressed.
it must process commends in a queue in a separate thread.
These two requirements indicate that they want a 'standard' server system, and probably a standard Executor service.
I would expect to see code that looks something like:
ServerSocket serversocket = ...
First, some basics:
Vector is a class that is deprecated.... actually, not deprecated, but discouraged....
As of the Java 2 platform v1.2, this class was retrofitted to implement the List interface, making it a member of the Java Collections Framework. Unlike the new collection implementations, Vector is synchronized. If a thread-safe implementation is ...
Here's a nice recursive solution, that creates <key>value</key> from 'key'=>'value' entries in your hash. If the value is an array, it instead recurses, using the key name as a wrapper element.
array.each do |hash|
xml.send(label) do # Create an element named for the ...
At a first glance, it seems to me that you have over-engineered the stack concept. Do you really need different stack implementations? That would be the only justification for the virtual interface. std::stack would certainly be enough for your needs, and it is most likely more efficient too, as it doesn't utilize virtual dispatch, like yours.
You have in total three functions over 300 lines, so ~100 lines to a function. This is 5-10x too few functions for this amount of code.
A lot of your formatting looks like you've used a C-like language and can't handle writing Python. Stuff like
# end if
which should just be
You even have
which actually just means
Comparing strings case insensitively is done by using the proper overload:
string.Compare(str1, str2, StringComparison.OrdinalIgnoreCase)
By calling .ToLower() for each string to compare (4 times for each iteration), you create 4 new strings each time. If you have a lot of (long) strings, this will create a lot of garbage for no reason.
In your case you ...
Your code seems simple and how it works is clear enough. I only have a few remarks:
This line seems a little bit off:
Generally speaking, in C and C++, libraries provide an include dir that has to be added to the search directories so that we can write:
While it certainly does not make your code ...
Dependency Inversion Priciple
The smell is that your code violates the Dependency Inversion Priciple which reads
Entities must depend on abstractions not on concretions. It states that the high level module must not depend on the low level module, but they should depend on abstractions.
This meas that your API depends on the Load method of the ...