in a game loop, why do you need a separate update and draw call? [closed] - draw

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
most likely a dumb question, but can't you both update and redraw everything at once in a single function rather than calling two functions back to back, what's the advantage of updating then drawing?

Update is not meant for drawing or any output like this,
but instead for game logic etc.etc.
One of the benefits of separating this two things
(other than cleaner program structure and so on) is, for example,
that if the game is too slow, Update can be called multiple times
before a Draw. The game graphic will probably lag,
but at least the logic behind will be in time.

both update and redraw everything at once in a single function
You can do a lot of things in a single function. But you shouldn't. It gives the function too many responsibilities, too many dependancies, and makes it a lot less re-usable.
Updating game state is a responsibility of the game logic. Re-drawing the screen is a responsibility of the user interface. Both should be kept very separate. This allows them to change independently of one another without affecting each other.

Related

What is "overkill"? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Programmers often wonder if the use of a certain library or programming style is overkill. They also often claim that this is the case (and they are often believed).
What does "overkill" mean in the context of programming?
"overkill" is typically used to mean deploying overly flexible and/or over-engineered solutions to solve what is ostensibly a simple and highly localized problem. The canonical example is FizzBuzz Enterprise Edition.
The term "Overkill" literarilly (if there was ever a literal use of it) refers to the action of killing something or someone, with more resources than necessary. Something like shooting a deer 50 times to make sure it dies.
In programming it applies for the same principle: making use of more resources than necessary or to find an overly complex solution to a simple problem.
Some simple examples are
for i=1 to 100
x[i]=2^z[i];
y=x;
end
Where copying the entire array x in every iteration step achieves the desired result but you could also copy it elementwise y[i]=x[i] saving you some 900 operations and is thus an overkill.
Using the OpenCV library to threshold an image is definetley possible but uses many more resources than strictly necessary and is an exagerated example of an overkill.

Voting system on NoSQL [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Is it possible/reasonable to have a voting system on NoSQL database ?
For example how would be possible to store StackOverflow question into the NoSQL database.
I can easily imagine almost everything except how the relation will work between question/vote/user. Everything else can be stored in one document, like tags, comments(assuming there are relatively small amount of comments on posts, in my case I will not have comments anyway), user information, etc... but can't imagine how to store user votes as document will become huge. One of the options is that I can have votes stored in separate collection/document, but it will mean that while loading a question there will be a need to send another request to check if the user have voted for a question or not.
A good reference is the MongoDB documentation on Embedded documents vs Referenced documents, since those are what you seem to be referring into your question. There's no perfect solution, as both have their trade offs. You just have to make the best decision based on the type of operations/queries and their frequencies that you're expecting to be run on your database.
Honestly, until your database starts getting some serious traffic, the difference between SQL and NoSQL won't matter. Pre optimization can end up doing more harm than good, so I would just go with the one that is easiest to get deployed and you're more comfortable with to begin with.

recommended http response size [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am programming kind of social-network application and struggling with one particular decision. I have quite large json structure (300KB at least) for markers on a map and I wonder whether it is allright to render that into html or if I rather should use ajax to serve it by pieces. Is there any rule of thumb about recommended size of response (what is allright and what is already not)? Because the ajax solution on the other hand is more complicated and increases number of requests to my server.
What's probably most important in your situation is perceived performance (how fast the site feels to the user).
I can't provide a rule of thumb on file size, but I can tell you that your average user gets impatient if a pages appears to take more than 500ms to load.
It might be best to load something (i.e. your map) quickly and then to use ajax requests to progressively add your pieces (geographic markers). The improved perceived performance of things "loading" on the page as the user watches will outweigh the decrease in actual performance caused by making multiple calls to the server. Otherwise, your user will be staring at a blank screen for the second or so that it takes to load the entire html file.

Automatic bookkeeping for exception retries [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Do any languages that support retry constructs in exception handling track and expose the number of times their catch/rescue (and/or try/begin) blocks have been executed in a particular run?
I find myself counting (and limiting) the number of times a code block is re-executed after an exception often enough that this would be a handy language built-in.
This is a really interesting question. I did a little research and apparently there is a design pattern called the circuit breaker pattern which was developed to handle such things. I have never heard of the pattern before and can't find much information about it.
There is a library which handles retrying an event for .NET available, might be worth a look. Heres a link to an article about it:
http://www.tobinharris.com/past/2009/1/26/net-circuit-breakers/

Are there any conventions for flowcharting that distinguish a switch from a if-else chain? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I had to do a overview for a customer meeting, and they requested flow charts. It had never occurred to me that there was no switch symbol in any of the flow charting I've seen. I know functionally they are similar, but documentation should represent the code you've written or are planning too. Maybe I'm just being picky, but it seems like a common enough construct that it would have "representation."
Pete
My impression is that diamonds are the correct symbol for switches (multidirectional branches) as well as binary decision points — i.e. the diamond is any conditional. One just gets the idea that diamonds are for either/or because that's their most common use.
The difference between a series of if's and a switch is irrelevant at the flow chart level. Both are a series of conditionals. If you want to document your code down to the if/switch level, just print out the code.