I've been working on a 3D mathematical vector class which should be as streamlined as possible for use in numerical simulations. It will be used to model 3D-physical vectors.
Here, 3D-vector should be taken in mathematical sense, meaning a tuple (a,b,c).
I hoped to design it in a modern and fas...
The following bit of code requires a string.maketrans table that is only used inside a single function.
I have written three versions of the program that place the table at different locations in the code. The differing placement of the table results in quite varying performance in the creation ...
In this Wolves, Goats and Cabbages in Java question, Java code is presented to solve the problem.
The code requires pre-processing by a third-party tool in order to function.
The third-party tool adds a number of 'template' or 'boilerplate' methods that make the code complete. In Java terms, th...
@rolfl I think it's on-topic. Working code doesn't necessarily compile right out of the CR post. It uses methods defined in another class, in another assembly. Whether that other assembly is written by the OP, a billion-dollar company, or an obscure 3rd-party shouldn't be of interest, no?
In case you don't know, Project Lombok helps with some of the annoyances of Java with stuff like generating getters and setters with annotations and even simple JavaBean like generation with @Data. It could really help me, especially in 50 different event objects where you have up to 7 different ...
Another grey area of Code Review.
I personally don't think these kind of questions are good for Code Review right now while we are in beta. They require a reviewer to install a lot of software, and the code will usually take a longer time to review due to this. And they are very localized revi...
I have a situation where I need to store fields of differing types of some data structures along with some similar metadata (The application takes data from one of many sources, some data possibly coming from more than one source, and then does stuff with it).
The solution I came up with was to c...
I'd like StackExchange to please block the ability to ping oneself manually in chat. I've been playing with that a little lately and it crashed my browser! (Safari 5, OS X 10.6.7)
I'm pretty sure that that's what crashed Safari because I tried to edit a "self-ping" and Safari crashed. I looked ...
TBH I've yet to see a single use case where a self-reply actually makes sense, and that's why the UI discourages it. But I don't feel strongly enough about it to actually disallow it on the server side. — balphaApr 18 '11 at 20:10
Interesting. I mean it's great, but at the same time I don't feel particularly thrilled with hitting 100% answered. It would mean we're kinda too active for the flow of incoming zombies, and that we need more questions. OTOH it could also mean new users are globally posting more answers than questions. I'm sure @rolfl has a query for that...
Commentry
So, this is not working code. I don't consider code to be working if
needs pre-processing, and the pre-processor is not shipped as part of
the standard toolchain.
This code is nearly useless to anyone unless they have lambok.
If I pull the code in to Eclipse, or any ot...
What's cool is that the number of zero-upvoted-answer questions has consistently remained just slightly above the number of unanswered questions, for quite a while now.
I am quite new to C. I would like to be able to shift a letter of the alphabet 'x' number of times to create a basic cipher.
Issue 1: An offset of 1 applied to 'Z' does not wrap back to 'A'. Instead it outputs '{'
#include <cs50.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#inc...
So, my grumpiness over wolves is done... but, the asker revised his question and included all the code. @200_success I would appreciate hearing your thoughts on it: meta.codereview.stackexchange.com/q/1616/31503
What is code but instructions to a compiler?
Would we allow an obscure language that no one here has a compiler to? I would hope the answer is yes. You might not be able to answer it but another person might.
I can currently think of more than one example that we would accept but requires an e...
@Malachi it's a linq extension method (extends IEnumerable<T>). Takes any Func<bool> and returns true if any of the elements in _defeats have a true return value for the Func<bool>. Use if (!_defeats.Any()) over if (_defeats.Count != 0); the parameterless overload returns true if _defeats has any items.
essentially.... About half of the actual Java code needed to run the program, is 'compressed' in to a few lines of 'directives' telling the lombok processor what needs to be fleshed out, and how.
Specifically use `.Any()` instead of `.Count()` and `.Any(x => x.something)` instead of `.Where(x => x.something).Count()` `.Any()` doesn't need to iterate through the whole enumerable if it hasn't already.
Regards,
Particularly not see how inadequate practice. The concept, use and advantage of working with DTO is to have the flexibility to modify only be setting the data transported without changing the method signature.
hugs
I posted a question with code, which one or more people answered with a code review.
Should I edit my question, to include the changes which were suggested in the code reviews?
To show the finished code?
To avoid getting more of the same answers on the old code?
To get new reviews of the new c...
That's not what I am asking... I am saying that @syb0rg has given a fair number of suggestions for things that can be improved.... do you think they you can/will apply some of those suggestions?
Then, perhaps the best solution would be for you to make the changes you think would be beneficial to your code, and then post a follow up question.... with the improved code.
That way you have two questions, the better code gets reviewed (again), and everyone gets upvotes.
@rolfl I wouldn't want to go down the rabbit warren of defining "common" or "industry accepted". I would personally say it should be tagged as a language superset/subset and let an expert in that language flavour handle it.
@Andy Edit the question to make it so the code can compile, but so that it doesn't fully invalidate my answer. I can adjust my answer so that it compensates for the bad copy-and-paste.
@rolfl I was very confused. It is now back to the original but without the one line that was causing it to not compile. So all subsequent responses will make sense
Can someone please let me know if they see glaring issues with this code? I tested a handful of cases and it seems to work but in other threads. I often see much more concisely written versions of this. I just want to know if anything I have done is superfluous or just stylistically poor form.
...
Adding the changed code below the original is okay, but it's also best to not request review of those updates. That will just make it harder to compare the question to the answers, plus there's not telling when the post will stop being updated. It's okay to post new questions for iterative review...
I have a requirement to validate file names related to architecture after they are uploaded. Once they have been uploaded I must warn the user if the file name is not standards compliant.
What's in a name
To be standards compliant a file name must consist of 7 parts after the extension is remov...
I find it strange that the zero-length line problem has not yet been pointed out:
for(String line : lines) {
if(line.charAt(0) == '#') {
....
The code above assumes a non-empty line in all cases, otherwise you get IndexOutOfBoundsException.
This is the sort of issue that should...
Critter
Your Point class is, as @RoToRa pointed out, underused. This constructor:
Point location;
public Critter(int x, int y){
location = new Point(x,y);
}
Could be simplified to this:
Point _location;
public Critter(Point location){
_location = location;
}
Also in this snippet:...
First off, here's the code. This is a simple Pomodoro timer I wrote. Theoretically, it will run itself infinitely, alternating between timing for 25 minutes and 5 minutes.
import time
import sys
import datetime
import winsound
def ring(sound):
winsound.PlaySound('%s.wav' % sound, winsound.S...
I am trying to create a method that reverses a string that will handle every case. So far the cases I have come up with are
""
"abcdef"
"abbbba"
null
I haven't been able to handle these conditions however
escape characters
"\n"
"\t"
Not sure how to make \n or \t into a string
special char...
I have written a system for handling the dispatch of events between objects. (I need this functionality for a larger project I am working on. Objects should be able to dispatch events without knowing anything about the objects that will receive them. If this indicates that there is something seri...
Im working on an app that has flexible storage configuration.
For example:
public class Repo1:IRepository
{
public void DoSomething(int tenantId, string someKey)
{
...
}
}
This repo can be combined in Aggreagate or Composite repositories.
Also there are connectors to exter...
I've been struggling with some architectural problems which I'm having a hard time figuring out myself.
Im trying to construct a basic structure of a project with the domain model and repository pattern.
It's easy enough to construct the POCO classes and repository when I want to implement some...
I have a generic extension method for validating my entities. The main idea is to be able to specify at runtime (context related) the criteria for validating a specific entity (with the end goal of saving it in the data base).
public static Boolean IsValidEntity<T>(this T entity, List<Predicate<T>>
I am refining my reliable UDP library, its at its 3rd iteration now. It is quiet a bit multi-threaded with almost all major operations having dedicated threads. I need your opinion on the following critical worker methods.
Legend
TAgUDP : Indy UDP Server derived class.
TAgUDPPeer ...
I'm using the Game of Life Kata to help me learn Javascript. I've picked up the syntax through Codecademy tutorials, but my current skill level is Novice.
The example code has working functionality for initialising a World with live cells and asking it to 'tick'.
All suggestions for improvement...
I am building a backend to a mobile application that will be hosted on a Django site connected to a PostgreSQL database.
I have never built anything to accomplish this before and this is my first go at it. I have not studied this type of application before so please let me know if the below cod...
When running Code Analysis on my project I get the following warning:
CA2202 : Microsoft.Usage : Object 'fs' can be disposed more than once in method
I don't see the problem, and the code compiles fine and produces the expected results in all test cases.
If I remove the fs.Dispose(); state...
I am relatively new to Perl and would like to check that the code I am writing docent have any major flaws in it or any bad practices.
This is a fairly simple sub but one that gets used often. Seems to work OK. Simply reads a text file that has parameters in it set by the user.
Config.txt
#cuc...
I want to find total word count in string. I have two methods as mentioned below.
public static int Wordcount(string strName)
{
bool wordfound;
int ctr = 0;
for (int i = 0; i < strName.Length; )
{
wordfound = false;
while ((i < strName.Length) && (strName[i] ==...
I have built a custom CMS on ASP.NET.
I have a multiple sites all with a virtual directory pointing to the CMS's shared files.
For example all the sites point to the same loading page, /_includes/load.aspx.
Should I be concerned that this could cause a bottle neck?
Note: Outside users don't s...
I'm using the Game of Life Kata to help me learn Javascript. I've picked up the syntax through Codecademy tutorials, but my current skill level is Novice.
The example code has working functionality for initialising a World with live cells and asking it to 'tick'.
All suggestions for improvement...