Your code looks really good, and there's very little I can see here that can be improved, nonetheless, the show goes on.
with open(file_path, "r+") as code_file:
return code_file.read()
I can't see that you re-use code_file, other than to open, meaning plain r is acceptable, over r+.
...
I have implemented a heap data structure for Coursera's algorithms course. The problem I have to solve is :
The goal of this problem is to implement the "Median Maintenance" algorithm. The text file contains a list of the integers from 1 to 10000 in unsorted order; you should treat this as a str...
Just completed this. It was a very fun and thought provoking problem, and I'm quite proud of the way I was able to pull it off. I broke it down into 2 parts, testing and comparing
Testing each group of cards for a playable hand. This returns a boolean value
depending on if the cards meet the cr...
I have wrote this simple code to learn more about processes. my goal was to fork 4 process A, B, C and D and send message from each one to the parent. When I run my program the parent can only gets two messages? What happened to the others messages? This is my code:
int main(int argc, char *argv...
There are many tutorials where explains about socket server/client sides, but all them are very trivial. Is there any tutorial for production ready code? I'm new in sockets. There is a client, that sends strings to server. I must create the server side. in server side I read string from client an...
I want to change the input's which are stored in the mysql database as the language other than English.
I have searched and got some of the steps like
Creating the @fontface as a regional font and changed the whole body of the webpage.
using the tags like:
<meta http-equiv="Content-Type" cont...
@Mast Hmm actually I'm not entirely sure I understand the Code Review requirements. To me this is a working piece of code, with a request about whether it is good practice or not. — Adam Houldsworth30 secs ago
@QPaysTaxes Crazy... though I'd be hard pressed to detect code like that. I wouldn't just assume Foo means close if the code itself is concrete and makes sense to demonstrate a structure (naming and other code review elements wouldn't play a part in all CR questions, surely). — Adam Houldsworth43 secs ago
I copy addresses from the endpoints to an array that should only hold the endpoint addresses. This works but it seems so old school :/
Can I make this faster, better, more sexy (LINQ)?
public static EndpointAddress[] Find()
{
EndpointAddress[] endpointAddresses = null;
var discoveryCli...
For an assignment I had to write a simple Http server (multithreaded) with the help of Sun's HttpServer. This server has to handle 4 resource (/login (GET), /cards (GET), /send (POST) , /list (POST))
I have never used Sun's HttpServer before (I used to use jetty which is way more flexible). I...
My son, who is currently 9 years of age, tells me that life is absolutely meaningless and that "we're all here to waste time".
When he first told me this, I felt both angry and depressed.
And no, this is not because I am religious. I am an atheist, but I think his outlook on life is detriment...
@barq ",it shows cannot resolve symbol 'in'and i'm not able to understand where am i missing a semicolon or a curly brace in the second error i marked" indicates that the code doesn't work correctly, so no, it does not belong on Code Review — Simon André Forsberg19 secs ago
I am working on writing a Code Golf King of the Hill challenge, the details of which can be read here. You can read the full code here.
Briefly, the game proceeds in cycles of night then day. There are two mafia, who collectively kill one person at night, and five town sided players (some of who...
public abstract class Player {
...
static ArrayList<Identity> Identities = new ArrayList<Identity>();
public static int numTown, numMafia;
public int hat, role; //hat is basically the players ID number, unrelated to the players actual role in the game.
Player otherMafia;
Identity pub, priv;
String Role;
public Player() {...
}
Here's what I don't even remotely like about the question
> I have put ... in place of some methods which aren't terribly important for this question.
When it's not clear that the blocks of code containing the ... are not up for review, then it sounds as if he has decided what is or isn't important, which we don't ordinarily allow.
I have this implementation:
class Vertex(val label: Char) {
var wasVisited: Boolean = false
//...
}
class Edge(val source: Vertex, val destination: Vertex) {
//...
var weight: Int = 1
}
abstract class GraphA {
var vertices: List[Vertex]
var...
@nhgrif I highly doubt what you are saying there, if I have a Player class that is being used by other classes in my code then I can include that class but only leave in the relevant parts
It may have tons of methods (arguably a bad design) which are totally irrelevant for that review
You can do whatever you want for context. In which case we really just need the publicly accessible parts of that code (like just the .h in languages like C, C++, or Objective-C)
So we know what the object we're consuming looks like.
But you can't cut out sections of a class you deemed uninteresting and expect that class to be reviewed.
@skiwi The question needs to find a way to make it clear. I usually prefer the quote blocks. rolfl will regularly edit questions and mark sections as context code.
@skiwi They could be reviewed, but if you're asking for a review and you've cut out sections and replaced them with ... or // ... then this is part of the reason why we have the 2nd off-topic close reason.
@nhgrif If it's the only code in question then it becomes doubtful, but as far as I'm aware it is a normal practice in bigger questions that consist of multiple classes
Hypothetical code makes poor Code Review questions, which produce poor answers.
For example, here is a code excerpt that made a poor Code Review question:
bool f(const string& key, const string& value)
{
// some codes for input check
exec_cmd("cmd %s %s", key.c_str(), value.c_str());
...
We have never let the asker decide what parts of his code is important or unimportant. For context code, that's fine, just mark it as contextual code (as I did with the quote blocks)
public abstract int nightMafia(int i, int mafiaChoice);
... //Various methods such as isPlayerDead,
... //etc. which will give players information
... //about other players statuses easily.
}
I have heard site regulars often scoff at oop and its usage.
Is oop a meta tag that has until now slipped under the radar?
If not, when is it appropriate to use oop? What sorts of questions should use this tag? What sorts of questions should not?
I don't have a case for its removal necessary...
In this case, those comments are acceptable because the Player class is only there for context. It's apparently the competitors in the competition which submit the actual implementation of this class.
So with that said, the Player class in this question isn't even actual code, but rather part of a set of contest rules.
But the Player class is here as context, which is fine.
But in this case, the // ... comments are being used to eliminate actual contextual code. It's especially egregious here as there is a request for a refactoring...
If he only wants the dfs method reviewed, he can simply post that (outside of the class, clarifying that it is part of the class) and then tell us about whatever context is necessarily (which might necessitate posting actual code snippets of the context parts).
... I just got a "Too Broad" close vote on that meta question? Really?
If you have a case for its burnination, you're welcome to make that case in an answer.
I want to talk about the tag. If no one can explain what sort of question it should legitimately be used on, that's a case for burnination as far as I'm concerne.d
I don't understand the downvotes on my question either. I haven't stated an opinion. Normally a meta downvote is a sign of disagreement with the question's premise. Are people disagreeing that I don't understand oop?
I understand downvotes, how they work, and I know not to take them personally. That's not what I'm doing.
Usually a downvote means the question isn't a good one. On meta is sometimes simply means "I don't agree". I don't see anything to agree or disagree with in my question (and I intended for there not to be, so if I missed that I need to fix it).
> Are people disagreeing that I don't understand oop?
Probably this
It's probably better, if you have a problem with something some asked, to disagree in the comments, or a chat room rather than cowardly downvoting without explanation
Not enough downvotes.
The only questions I see with a negative score are questions that are either on hold, closed, deleted, or accumulating close votes on their way to being put on hold.
Frequently, I'll find that my downvote is the only downvote on a post.
Often times, I feel that a post's s...