I've got a nasty looking bit of code that I was hoping to clean up somehow, first thing that came to mind was switch statements, but I can't figure a way to implement them in this case, as each check is unique. Could you please provide another alternative or let me know if there is any other bett...
@skiwi Here it is a little of an issue. Since we have to cut on costs, and getting money is hard, some resort to stealing. Portugal is in deep deep sh*t economically. Also, some kids steal just to look cool or for the thrill.
I am a little confused over which layers my filters should be contained in with an n-layer web application.
I've got 4 layers:
Presentation layer
Application layer
Business layer
Infrastructure layer
The Presentation layer can only talk to the Application layer and the Infrastructure layer. ...
Problem:
Pascal’s triangle is a useful recursive definition that tells us the coefficients in the expansion of the polynomial (x + a)^n. Each element in the triangle has a coordinate, given by the row it is on and its position in the row (which you could call its column). Every number in Pasc...
I've been an active member of StackOverflow for more than two years, and have a decent amount of rep on some other SE sites like Programmers, Code Golf and here. But the one type of question that still haven't figured out where it goes is the following question:
I did XYZ. It worked. Is it a ...
@Mast @Pimgd did that on a couple of JavaDeveloper questions. I wasn't a big fan of it myself but he did "get away with it"
@Mast I agree that it's a bit against the spirit of the site
@IsmaelMiguel I don't know. Don't even know if I will ever do it. Today I think I will post a question of my StackSTV implementation though, after I've refactored a bit
I think it is as stable as it's gonna get now. I might make improvements to the script, but there's nothing that will break by that. And if something breaks, restoring it will be as easy as checking out an older git commit and uploading that version of the PHP file
no wait... when using a mode, the background depends on the state on the question. red for unanswered, orange for answered but no accept, green for accepted answer
haven't decided what answer to accept, and haven't implemented many of the suggestions still
Continuation of this question:
I have tried to refactor code according to PEP 8.
I tried to raise some errors instead of just print and sys.exit, as was suggested. (should I define much more exceptions for every function and so, or are general ones enough?)
Code is not complete, there are a few...
:define --> keyword to create variables, functions, objects, ...
:static --> datatype - equivalent to an int
:~0 --> variable name
:store --> used to set a value to a variable
@:cons@12 --> creates a constant of type 'static'
That's still a valid block
The idea isn't for the code to be written by humans
I would recommend the Repository and Unit of Work Pattern, although I can't find a decent article, it has been mentioned a few times on code review. — Mike Eason52 secs ago
> a count of people with a specific combination of votes For example, in the first line: 1 1 2 3 0 that means that one person voted with the combination first-choice candidate 1, second choice candidate 2, third choice candidate 3. The 0 represents the end of that line. Note that combinations can be duplicated, potentially.
Reposting my question.
I've created a simple ServiceFactory class, which runs other Service classes, stores and gets instances. The same ServiceFactory object is shared between both the View object and Controller object.
The Controller changes the state of the Service:
class User extends Contr...
You could probably post your code on the code review Stack Exchange; I think it can be improved quite a bit in terms of elegance and readability. — Joachim Breitner56 secs ago
@JoachimBreitner CodeReview is about reviewing fully working code. As the O.P. posted, the code isn't working as expected, which makes it off-topic and extremelly likely to be closed. — Ismael Miguel37 secs ago
Side note: are you sure you want to make everything asynchronic? There are serious development costs involved with making everything async as discussed here. — Steven33 secs ago
I am working on to find the kth smallest element in min heap. I have got a code for this whose complexity is O(klogk). I tried to improve it to O(k).
Below is the code.
struct heap{
int *array;
int count;
int capacity;
}
intkthsmallestelement(struct heap *h,int i,int ...
I wasn’t suggestion to move the question of how to fix the code there, but rather how to improve the code with its current functionality. After all the code is fully working – it’s just not doing the right thing, but that is orthogonal to a code review. — Joachim Breitner29 secs ago
BTW, where did my comment suggesting that the code could use some CodeReview go? — Joachim Breitner51 secs ago
@JoachimBreitner - Code Review scope defines "working" code as "code that does what you want, and what you expect". If it is missing features, the code is considered incomplete, and not yet working. It's a Code Review thing. Not trying to suggest you change your definition, just that you understand why Code Review is not the place to recommend for people asking: How could I rewrite the function, so it would return a list of strings? — rolfl26 secs ago
@JoachimBreitner I don't know where it is, but your suggestion isn't helpful, as it will generate bad content. The code, to be reviewed, must be working. With it's current functionality, the code is broken. The O.P. expects a list, and instead he gets a string. That is clearly broken code. CodeReview doesn't do reviews on broken code. You can read it in the FAQ. — Ismael Miguel54 secs ago
Code Review is becoming well-known on Stack Overflow.
The folks over on Code Review are happy about that.
The only problem is that there are a lot of questions redirected to CR which don't belong there.
So I want to ask that the users who direct askers to CR (or request migration of questions...
What IDs? I'm not seeing what you are hoping to simplify. Also, code review requests should be made on codereview.stackexchange.com — forgivenson41 secs ago
I have been working the some project and I'm struggling to find the answer.
Right now I'm coding with angular and there some codes that makes me write twice.
Here is my array there only two of them now but if I have lots of arrays the code will be really big. The thing makes me stop always that I...
I wanted to be sure if the following lines of code are correct.
I am trying to plot a 3Dplot of a linear regression with two variables.
My linear model
ls = lm(mpg ~ disp + qsec, data = mtcars)
The minimum and maximum values to predict
mmd = min(mtcars$disp):max(mtcars$disp)
mmq = min(mt...
I am writing a code where a filepath is split and then joined to form path in proper format
_filepath = 'Home\\filename.txt'
fileparts = _filepath.rsplit('\\')
filepath = os.path.join(*fileparts)
My question is, Is this good practice to keep variable with underscore prefix such as _filename ...
I'm fairly proficient in C and Python, but want to learn some skills for administrating my new Linux machine. I wrote this simple address book app to teach myself shell scripting. This is the first script I've written longer than a couple of lines.
The address book is a plain text file stored in...
@chillworld I wasn't sure if you were offline sleeping or something... I didn't want to ping you if you weren't really here. I don't like being rude, is that rude to ping when for curiousness sake?
Problem:
Pascal’s triangle is a useful recursive definition that tells us the coefficients in the expansion of the polynomial (x + a)^n. Each element in the triangle has a coordinate, given by the row it is on and its position in the row (which you could call its column). Every number in Pasc...
People who had their childhood in the 90's tend to make references the the teenage culture back then and to remember it as the best period to be a teenager. And since nobody else seems to understand why it was better than what we've had since, the meme "only 90's kids will understand" is born.
I would say that it is okay to have a new version of the code as a new question, and leave the old question out there as well. someone made 60 reputation helping him make it better, I wouldn't take that away from them