Since your code works you'll want to post it on codereview.stackexchange.com. They review working code and suggest improvements, whereas Stack Overflow is for help fixing broken code. — John Kugelman15 secs ago
No worries. It's a subtle distinction I'll admit. The reason for it is that here we like questions that allow for direct, focused answers. Code review tends to lead to broad answers that cover a multitude of improvements and suggestions. That's why a separate site was set up, and why your question was closed as "needs to be more focused". Cheers! — John Kugelman51 secs ago
I often see nested loops as a solution to the bubble sort, but my solution involves a recursive function. Is the following solution less efficient than the traditional method?
public static int[] BubbleSort(int[] arrayOfValues)
{
var swapOccurred = false;
for (var i = 0; i < arrayOfV...
I have been trying to learn c++ for the sake of being comfortable with a second language. I found a project that seemed relatively easy, although it may not be implemented perfectly, it was a simple project.
I create a std::map<double, std::string>, which will represent the tax rate as a double, ...
I have been building an application to scrape prices from a "rooms for rent" website and average them to help out new movers.
All the work is done, however, currently the code only scrapes the one page I gave it, I'm trying to get it to scrape the next page and so on until it has all avaliable pr...
I've started to get far more familiar with C (and coding in general) and the way to use function to my advantage to create more complex programs. As a way of doing something actually useful instead of my "Starting Programming with C: For Dummies" book I decided to make a simple program to help me...
Thanks for the feedback, @LaurenzAlbe. So far, the only real concern has to do with data leakages because of cross-schema queries. It's not really a concern as it can be mitigated by good code reviews, but the possibility that it could happen still exists. Perhaps the only real question here is the second one, as the first question seems to be the right way to go about it. When we have data that is meant to be shared, does it make sense to duplicate it or use a cross-schema query? — John58 secs ago
How does the following look to list the directories on a posix system? This is actually the first piece of C code that I've written where I've actually been able to use for a real-world problem!
#define _GNU_SOURCE
#include <dirent.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#inc...
Code Review Stack Exchange may be more suitable for a “how to improve this working code” question. But without asking about specific improvement, this is off-topic everywhere. What exactly do you want to improve? Why? What’s wrong with having two functions? If each does the job described by their name, then everything is semantically correct. — Sebastian Simon15 secs ago
I am a total beginner in Python and I am trying with the modules Turtle. I am currently trying to code for 3 sliders (R, G, B) for adjusting the colors of the turtle screen. However, I found parts of my codes filled with redundancies, could anyone please tell me how to trim the code to make it mo...
I've created a simple lambda function that polls a few websites periodically to see if something changed. One way it does this is by making a hash of the page and seeing if it different than the original hash, provided by a json file, like so:
{
"check_type": "hash",
"url": "https://www.h...
I am trying to write a benchmarking tool from scratch in python. Unfortunately, no matter how I try, my code can not reach the performance of other benchmarking tools like wrk/wrk2. Using wr2 I can make 42k reqs/s while my code can create only up to 2200 reqs/s. I have tried multiple ways to para...
I’m voting to close this question because this question ask for code optimization which is on topic for Code Review but not so much here on SO — Roman Vottner51 secs ago
I am trying to find a N number of leading zeros from the output of the sha1 hash function. I would like N to go up to 10 or 9. Currently I can get to 7 in about 7 minutes (even though is not always that fast), but already 8 takes forever. The input to the sha1 must be a combination between an inp...
My hero! Defaulting to unknown was a very bad idea, I will avoid it in the future. I am eager to find ways to reduce the amount of type-annotation code I need to write, or to find type-level reusable abstractions, for it distracts me a lot. We just turned a one line obviously correct abstract function into a ~10 lines long non-trivial concrete function, not to mention that unit test should double-check everything we did. I expressed a similar discomfort in code review here if you want to have a look. — geoffrey33 secs ago
I’m voting to close this question because this question probably belongs on Code Review, another site in the Stack Exchange network. — AndrewL6419 secs ago
@AndrewL64 The question doesn't search an array so the question is off-topic on Code Review. — Peilonrayz48 secs ago
The second form is great and could be improved by making the 3 a const int defined in advance, making it very flexible. The first form is a total mess and would hard-fail most code reviews. — tadman57 secs ago
@Peilonrayz I emphasise on the word "probably" cause I wasn't too sure if the question is relevant for Code Review but doesn't search an array so the question is off-topic on Code Review. <- What does searching an array have to do with Code Review? — AndrewL648 secs ago
@AndrewL64 Code Review is not a migration target because Stack Overflow does not know CR's rules. Please do not close questions because CR exists. Otherwise we get into situations where on-topic SO questions are closed and the user is told to post an off-topic question CR. Pretty toxic. Code on CR must be working as intended, and the code doesn't, "I need to search an array that has 4,000 objects". — Peilonrayz14 secs ago
This is an updated version of my first question:
Chess game in Kotlin
I wrote the following Chess logic in Kotlin and am looking for feedback to make the code cleaner and follow good software design principles. I tried to adhere to object-oriented design.
Some notes and questions I still have:
• ...
I created a contact form with flexbox. It uses the mobile-first approach so everything inside the media query is for large screen.
:root {
box-sizing: border-box;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
body {
margin: 0;
padding: 0;
}
.contact-container {
max-width: 120...
@CaptainObvious @Peilonrayz Does this question work as expected and is it only a performance review which means it is a legit code review question? It is currently in the Close Vote Queue.
@pacmaninbw The code should run fine. (I have not run the code) So the question being CNWAI is not correct. The code isn't really a 'benchmark library' but the code is benchmarking a bunch of requests. Overall I don't believe the CV for CNIONWAI is correct.
And as you've said; code not working with regard to performance is allowed on CR.
I have the following bit of code in a service worker that checks to see it the url contains any of the values in an array and if so it breaks out of the function. As it is run for every asset on a webpage, it can be run a lot of times so I was wondering if this was the best way to do it or if it...
I'm currently creating a terminal-based RPG like Pokémon as a learning project so my programming skills are limited. My main problem right now is stat management of the player.
My code works like this:
I have a Player class which creates characters. Its constructor has parameters for character i...
To improve my Python knowledge I started a small coding project: A telegram chat/quiz bot that is based on official questions about basketball rules. The bot reads them from one or multiple .csv files.
I tried to seperate game logic and chat interaction as good as possible, but failed somewhat.
I...
I am making a simple file explorer with tkinter Python.
This is the file repository on github.
I know that this is pretty much long code and it took that much time to write but i have somehow added the comments.
And I want someone to test my code.
Also the additional mechanisms are not here and t...
@Mast: Stack Overflow (and StackExchange in general) have a reputation for being a bunch of A-holes who care more about enforcing arbitrary rules than actually helping anybody. In particular, demanding that beginners learn lots about the structure of SO/SE, how questions should be asked, etc., before answering questions. This question clearly doesn't fit here so it should be closed. But demanding that the OP jump through (what they see as) flaming hoops to get help is bad too. IMO, the optimal route is to help them, then close the question (and advise them what to do next time). — Jerry Coffin11 mins ago
@pacmaninbw I'm not convinced it is CNWAI... I see the title originally had a "how to" question in it that has since been removed... but then in the description it contains this question "How can I manage stats in a clean way with my approach if it's possible? Otherwise I will refactor."
I am developing a system for runtime macro executions in an automatic test environment. Macros are defined in an xml and are for configuring multiple devices/DUTs for a specific use case.
The xml parsing of these macros is outside of the scope of this question.
For building the macros in code I c...
After I have been doing some improvements from my Previous code review. I have taken the knowledge to upgrade and be a better coder but now im here again asking for Code review where I think it could be better.
The purpose of this code is a monitoring that checks for a special site every random 3...
i am kind of new to low level designing, need your feedback on this design of Chess game.
dont go inside the core logic, just provide your comments based on the design part.
the class 'Chess' receives calls from the UI to move the Pieces. this class has a Board object and 2 Player objects.
the Bo...
@afreelunch You are asking what is recommended. Different people recommend different things for different reasons. The question is off-topic as opinion-based because you have not provided an objective metric by which to answer your question. Stack Overflow likewise does not deal with theoretical problems, but rather practical ones that you are actually facing. If you want input on whether your programming style/habits are good, consider softwareengineering.stackexchange.com instead. Or, for a full, stylistic review of working code, codereview.stackexchange.com. — TylerH24 secs ago
Currently working on a pre-solve collision library. My goal is to have it be potentially usable in potential video game projects of mine, so time constraint is small as this should be used in a game loop: this algorithm currently takes too long. I am aware of broadphasing, but I believe there is...
The purpose of this code is to use it to calculate some number theoretic function efficiently for the numbers from 1 to 1000000, but I am not sure if it will be really useful. The main purpose was to program a piece of C++ code because I have almost no experience in this language. So it would be...
Improve hash Set List filtering
UI Data that gets saved as a HashSet.
These respond to the PriorityCode values of 1-9 in the database.
This code all works fine and is according with the business rules, but however. This seems to be a terribly inefficient way to do this. How can this be improved?...
@Rocker2102 I might not be the person to ask that, and even if I were, I'd probably need to know a fair bit about what you're trying to do and what 'ok' would mean for this code. If you don't think a question about that would fit stackoverflow maybe take a look at codereview.stackexchange.com and see if your question would fit that site. Sorry for not being more helpful. — Ben Stephens32 secs ago
I have this code:
Sorted=False
while not Sorted:
Sorted=True
for x,y in enumerate(List[:-1]):
if List[x]>List[x+1]:
List[x],List[x+1]=List[x+1],List[x]
Sorted=False
However the use of
Sorted=True/False
being repeated is quite ugly and it would be much nic...
Been looking into some simple algorithms, I came up with the following piece of code in C to implement the Euclidean algorithm iteratively (I like to be clear here, I don't want the recursive implementation for now).
I've seen various other implementations and in fact most books prefer a differen...
@Jamiec Code Review is not a code rewriting service, and the current question as-is is not reviewable, as a lot of context is missing. If the context gets provided, it might be on-topic. — Zeta26 secs ago
@Segma Short answer: context. Where does this code run? What are its goals? Is the code in the question complete, or are critical details missing? Long answer: this post. — Zeta59 secs ago
@Zeta As a long-time Code Review user I don't really understand your comments. "Context", unfortunately, has a very specific meaning on Code Review. Are you talking about questions needing an explanation of what the code does? Because otherwise the question looks fine to me. — Peilonrayz7 secs ago
I have a problem. It seems very bulky and bad to me and I have to reduce it. I often repeat one and the same function..who can simplify this?
private enabledButton(filterData: any) {
if (this.checkEqualsDate(filterData)) {
return this.removeDate(filterData)
}
if (this.checkEq...
What is your question? If you are looking for a code review, There is a stack exchange site for that. — Paul Rooney19 secs ago
@joanis - the script is working, though. I still think that codereview is its rightful home. — tink14 secs ago
This may be a better fit for Code Review. I deliberately linked to their asking help pages so you can make sure your question fits their requirements before posting. — user458130137 secs ago
If you need a code review I had one for you but question is closed now. — Xaqron11 secs ago
I implemented a key:value format file parser in C, or something that comes close to it as there is no such thing as dynamically creating structs in C.
Assumptions: we are creating a C program that needs some config options (e.g. the number K of threads in a concurrent server that handles requests...
Welcome to SO - Please take the tour and read How to Ask to improve, edit and format your questions. This isn't really the place for suggestions and explanations. Code Review. Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Stackoverflow is more on-topic for questions about problems and algorithms. — lorem ipsum55 secs ago
If there are not specific issues and just want to know the "right-way" this question seems more inline with Code Review. Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Stackoverflow is more on-topic for questions about problems and algorithms. — lorem ipsum33 secs ago