|
csammis posted:It sounds like you're describing a situation where you update object X, object X's update also changes "other things" behind the scenes, and then object X is left holding the bag for those other things' key deletion. Exactly, the data being updated is relational. The json only represents a certain view of the database schema, depending on what you're requesting. There could be other tables that have changed and that json needs to be deleted too. Anyway after thinking about it more I think the only way to take the relationship management out of the code is to put the relational json blobs in a redis hash, and then nuke that key.
|
# ? Jul 8, 2015 20:10 |
|
|
# ? Jun 4, 2024 01:01 |
|
I have a php (laravel) class instance which does ~0.8 seconds of MySQL queries / data processing. It generates a series of queries that need to be run in the database 10 minutes later. After these have been processed, the same class then needs to do more work. My current strategy, is to add 'pending' columns to all the insert / delete rows, but there are also many fields that get incremented or changed for which 'pending' flags wouldn't work. In an ideal world, I would find a way to replicate the imagined case where START TRANSACTION and COMMIT could be run across 10 minutes with different connections, but this isn't possible! I can't do: Generate instance (0.8 seconds) ------> Wait 10 minutes -------> Generate Instance (0.8 seconds) -----> Post-DB work (<0.1 second) Because I am making two instances of the class. I am screwed? Fruit Smoothies fucked around with this message at 01:40 on Jul 9, 2015 |
# ? Jul 9, 2015 01:16 |
|
Hey goons, any suggestions on how to approach "Undo" functionality in a desktop application? I have a simple application for keeping track of files associated with a unique ID. Basically it's just a form with a TabControl on it. Add a new ID, get a new TabPage. Each TabPage just has a TextBox on it. When the user Saves the form, it just writes each TextBox to a text file. When they delete a tab, it currently deletes the text file too. I'd like for it to instead leave the text file and just remove the tab. Ctrl-Z to restore the tab (and the data on it, not what's in the file). I've been able to get this working somewhat, but if they delete more than one thing and try to Ctrl-Z multiple times it doesn't work. Restores one tab and that's it. I tried using a dictionary<string, string []> to keep track of the ID and TextBox value, but that doesn't seem to retain the correct order
|
# ? Jul 9, 2015 14:00 |
|
Sab669 posted:Hey goons, any suggestions on how to approach "Undo" functionality in a desktop application? Use a stack?
|
# ? Jul 9, 2015 14:05 |
There's two approaches to implementing Undo: A) State-based, every time you perform an undoable action, you store the complete state of the data before the action. When you then undo, you just replace the current state with the old state. If you also want redo, you can place the replaced state before undo onto the redo stack. B) Change-based, every time you perform an undoable action, you store a representation of the changes made on the undo stack. Undoing is then performing those changes in reverse. If you also want redo, you similarly place the reverse-reverse on the redo stack when the user undoes. For simple data models and smaller data sets (files), the first approach is usually easier to implement. You just need a way to make a complete clone of the data. For larger data models or large data sets, where store complete copies of the entire data is impractical, the second approach is better. It might require some more preparation work, but you need to store less data. In your case, if it's just a list of files the user created, the first approach is probably easiest.
|
|
# ? Jul 9, 2015 14:25 |
|
I've literally never had to use a stack since my Data Structures class years and years ago. Kind of forgot about them, to be honest.
|
# ? Jul 9, 2015 14:34 |
|
What language/platform are you using? There might be something in the libraries that already have the functionality (I know Cocoa/Objective-C has a built in UndoManager, for example,) since it's a pretty common function for software.
|
# ? Jul 9, 2015 15:22 |
|
C# / WinForms. Using a stack and a class for maintaining the tab key / data works perfectly though
|
# ? Jul 9, 2015 15:32 |
|
nielsm posted:There's two approaches to implementing Undo: That's a good overview. Stack vs whatever is really the smallest of issues if the data and processes are non-trivial. I recently saw this overview of how it was done in photoshop by Sean Parent: https://www.youtube.com/watch?v=bIhUE5uUFOA&t=849s
|
# ? Jul 9, 2015 15:47 |
|
Anyone have suggestions for a question (or sequence of questions / instructions) to introduce the syntax of a while loop? The format will be an in-browser JS sandbox where students edit an existing file toward completion, where completion is defined by a set of unit tests on their assigned functions.JavaScript code:
Newf fucked around with this message at 18:34 on Jul 9, 2015 |
# ? Jul 9, 2015 18:02 |
|
Newf posted:Anyone have suggestions for a question (or sequence of questions / instructions) to introduce the syntax of a while loop? The format will be an in-browser JS sandbox where students edit an existing file toward completion, where completion is defined by a set of unit tests on their assigned functions. Start by naming your function printOneToTen().
|
# ? Jul 9, 2015 18:32 |
Newf posted:Anyone have suggestions for a question (or sequence of questions / instructions) to introduce the syntax of a while loop? The format will be an in-browser JS sandbox where students edit an existing file toward completion, where completion is defined by a set of unit tests on their assigned functions. Maybe how many times a number must be halved to become less than 1. (while (x>1) { x /= 2; n++; } ) Then maybe later extend the question with, "what if the starting number can be negative?"
|
|
# ? Jul 9, 2015 19:08 |
|
Giving a way to differentiate it from a for loop might help. Can you require external functions to be called? If so, you could have something like:JavaScript code:
|
# ? Jul 9, 2015 19:27 |
|
These are good suggestions, thanks.
|
# ? Jul 9, 2015 21:17 |
|
I have no idea where to post this, but I'm hoping someone can find a video of a talk on software development. The gist of it was that no one has ever done some sort of meta-analysis of software development. There was one point where the speaker was discussing about when a complete re-write was worth it, NASA (?) realized that if you had to change more than ~70% of your code, it was better to do a complete rewrite (as far as stability goes, sanity, etc). I know this isn't a lot to go on, but hopefully someone knows what I'm talking about.
|
# ? Jul 9, 2015 21:29 |
|
CoasterMaster posted:I have no idea where to post this, but I'm hoping someone can find a video of a talk on software development. The gist of it was that no one has ever done some sort of meta-analysis of software development. There was one point where the speaker was discussing about when a complete re-write was worth it, NASA (?) realized that if you had to change more than ~70% of your code, it was better to do a complete rewrite (as far as stability goes, sanity, etc). I know this isn't a lot to go on, but hopefully someone knows what I'm talking about. Might've been: http://www.joelonsoftware.com/articles/fog0000000069.html ...or at least referring to it.
|
# ? Jul 9, 2015 22:42 |
|
CoasterMaster posted:I have no idea where to post this, but I'm hoping someone can find a video of a talk on software development. The gist of it was that no one has ever done some sort of meta-analysis of software development. There was one point where the speaker was discussing about when a complete re-write was worth it, NASA (?) realized that if you had to change more than ~70% of your code, it was better to do a complete rewrite (as far as stability goes, sanity, etc). I know this isn't a lot to go on, but hopefully someone knows what I'm talking about. The NASA study you are recalling was discussed by some poasters here and in the other forum, prompted I think by forums user MononcQc's tumblr post: http://mononcqc.tumblr.com/post/31767374324/an-analysis-of-errors-in-a-reuse-oriented-development-en Basically, they found that rewriting from scratch was a better option (in terms of minimizing defects) if you had to change more than about 25% of the code.
|
# ? Jul 9, 2015 23:35 |
|
CoasterMaster posted:I have no idea where to post this, but I'm hoping someone can find a video of a talk on software development. The gist of it was that no one has ever done some sort of meta-analysis of software development. There was one point where the speaker was discussing about when a complete re-write was worth it, NASA (?) realized that if you had to change more than ~70% of your code, it was better to do a complete rewrite (as far as stability goes, sanity, etc). I know this isn't a lot to go on, but hopefully someone knows what I'm talking about. I think I know exactly what you mean, but I can't remember enough to find it. It was a guy who's published a few books that people here rate, I think they were collections of essays or case studies from other programmers, maybe about patterns or approaches or something. The talk was to some software engineering students and he was basically saying your generation is going to be running the world soon, you're going to inherit a ton of problems, and you need to be prepared to take an evidence-based approach to solving them. The coding side of it was talking about how there's a lot of talk about 'what works' but almost no actual formal testing and assessment, like for things like agile development. He had a photo of his daughter and an XKCD 'citation needed' cartoon at one point. He was also asking people what the point of university and postgrad is. Hopefully that's enough to remind someone who knows what I'm on about, if it's even the right video! baka kaba fucked around with this message at 02:47 on Jul 10, 2015 |
# ? Jul 10, 2015 02:45 |
|
baka kaba posted:I think I know exactly what you mean, but I can't remember enough to find it. It was a guy who's published a few books that people here rate, I think they were collections of essays or case studies from other programmers, maybe about patterns or approaches or something. The talk was to some software engineering students and he was basically saying your generation is going to be running the world soon, you're going to inherit a ton of problems, and you need to be prepared to take an evidence-based approach to solving them. Yes! This is exactly the talk I'm looking for holy poo poo. I've been putting random stupid poo poo in to Google all day to find it but no luck. This will give me some more to go on though.
|
# ? Jul 10, 2015 06:21 |
|
I watched that talk several years ago as well. It's called What We Actually Know About Software Development, and Why We Believe It's True, by Greg Wilson. Here it is on Vimeo: https://vimeo.com/9270320. I find the part at the end about teaching students how to run the world to be a little pompous and only tenuously related to the rest of the content, but on the whole it's a very good talk.
|
# ? Jul 10, 2015 11:07 |
|
I've got a small programming challenge that I can't solve no matter what. The objective is to count all set bits in the numbers from 1 to 10^16. I'm on Java, so using Long.bitCount() would take hours. My plan was to start from 1, get the set bits for that using Long.bitCount, and then bitshift to the right by 1 until x > 10^16, adding the previously got number of set bits to my total for each shift. I would have stored the checked numbers in a HashSet and used if (!HashSet.contains(i)) to keep it from checking numbers that have already been counted. Welp, the problem is that HashSet can't handle anywhere near 10^16 numbers, so that didn't work. I honestly don't have a clue what to try next, so any tips would be appreciated.
|
# ? Jul 10, 2015 11:14 |
|
Don't actually generate the numbers and count all the bits. Try to figure out a pattern and calculate the sum. Like: 1 bit: 1 2 bits: 4 3 bits: 12 Is there some pattern you can use here? Think about defining each term in terms of the previous term. e:Wait, derp. You're going up to 10^16, and not 2^16? Well, you can apply the result from the problem that I thought it was to get the solution to the actual problem. Dr. Stab fucked around with this message at 11:45 on Jul 10, 2015 |
# ? Jul 10, 2015 11:21 |
|
The field of software development is definitely not evidence-based. You can espouse new methodologies and processes and practices with nothing to back it up except yelling louder than the next guy. Part of the problem is that it is impossible to quantitatively measure productivity of software development. Note that measuring productivity based on toy problems and drawing conclusions from it is inane.
|
# ? Jul 10, 2015 11:27 |
|
Kuule hain nussivan posted:I've got a small programming challenge that I can't solve no matter what. The objective is to count all set bits in the numbers from 1 to 10^16. I'm on Java, so using Long.bitCount() would take hours. My plan was to start from 1, get the set bits for that using Long.bitCount, and then bitshift to the right by 1 until x > 10^16, adding the previously got number of set bits to my total for each shift. I would have stored the checked numbers in a HashSet and used if (!HashSet.contains(i)) to keep it from checking numbers that have already been counted. Welp, the problem is that HashSet can't handle anywhere near 10^16 numbers, so that didn't work. Try a lookup table. Check the numbers in groups of 8 , 16 or whatever bits and use the table to do the sums.
|
# ? Jul 10, 2015 13:04 |
|
Dr. Stab posted:Don't actually generate the numbers and count all the bits. Try to figure out a pattern and calculate the sum. Amberskin posted:Try a lookup table. Check the numbers in groups of 8 , 16 or whatever bits and use the table to do the sums.
|
# ? Jul 10, 2015 13:48 |
|
Kuule hain nussivan posted:Yeah, I guessed figuring out a pattern would make it much more manageable, but unfortunately I just don't see one that helps :/ Take the set of all natural numbers less or equal to N. You can divide that set into two: the last N%2 and the first N - N%2 numbers. E.g. for N = 5 you'd have the sets [0..4] and [5]. Can you say anything about how often the least significant bit is set for those two sets? How could you generalize that to other bits?
|
# ? Jul 10, 2015 13:57 |
|
I'm looking to automate clicking on "Delete" and "Unlike" on the page http://m.facebook.com/usernamehere/allactivity so I can just delete all of my facebook history. Somewhat at a loss for how I could accomplish finding a word on the screen then clicking it. e; I may have figured it out with this iMacro addon for firefox, the issue was that there were different types of things I wanted to click, but by filtering what the activity log is showing by "Your Posts" I can have it clicking on the word delete continuously. Feel free to ignore this post for now. Blowdryer fucked around with this message at 16:20 on Jul 10, 2015 |
# ? Jul 10, 2015 16:17 |
|
Brute force UI automation is almost never the right solution. Facebook probably has public APIs for that stuff, and if not you can just replicate whatever HTTP request fires when you click the button. Edit: if it's just something for you to use one time then who cares
|
# ? Jul 10, 2015 16:58 |
|
Simpler still, you could probably get a long way toward your goal by just opening up your browser console and mashing something like $('.unlike_button').click();.
|
# ? Jul 10, 2015 17:15 |
|
For some reason my googleness is failing me and it's driving me crazy. What is the following Navigation scheme called and are there any JS librarys ( Angular, JQuery ) that implement it? I'd like it full screen for mobile thingys.
|
# ? Jul 10, 2015 22:06 |
|
What's the standard way of doing calculus programmatically? Specifically, how computationally expensive is it? Part of a project I'm programming might involve calculating the arc length of an ellipse in real-time, but I don't see the point of writing the code if it's going to kill my frame rate.
|
# ? Jul 11, 2015 01:02 |
|
Purple Prince posted:What's the standard way of doing calculus programmatically? Specifically, how computationally expensive is it? Part of a project I'm programming might involve calculating the arc length of an ellipse in real-time, but I don't see the point of writing the code if it's going to kill my frame rate. For this particular example (arc length of ellipse), here's some theory: http://mathworld.wolfram.com/EllipticIntegraloftheSecondKind.html and here's some practice: http://www.boost.org/doc/libs/1_58_0/libs/math/doc/html/math_toolkit/ellint/ellint_intro.html If you don't want to use a library, you can just do the line integral explicitly, parameterize the ellipse as (a cos(t), b sin(t)), choose your end points for t, and start integrating sqrt(a**2sin2(t) + b**2 cos2(t)). Gaussian quadrature with even a modest number of points should eat that thing alive.
|
# ? Jul 11, 2015 02:05 |
|
fankey posted:For some reason my googleness is failing me and it's driving me crazy. What is the following Navigation scheme called and are there any JS librarys ( Angular, JQuery ) that implement it? I'd like it full screen for mobile thingys. "sliding submenu" or "mobile submenu"
|
# ? Jul 11, 2015 04:06 |
|
How many object properties is too many? There's one Stack exchange question asking which browsers can support javascript objects with 70,000 properties. That seems.... excessive and poorly implemented. On the flip side, is 40 properties per object realistically too much? 15? 64? I realize you can break down most properties in to collections of subgroups, etc but a game like dwarf fortress, from what I can tell, each tile has it's coordinates, temp, humidity, history, language, contents, etc etc etc, basically a lot of minutae. I'm wondering a) when does too many properties begin to impact performance and b) at what point (number) does having too many properties begin to point to a possible major flaw in your methodologies?
|
# ? Jul 11, 2015 09:57 |
|
Adding properties to an object doesn't impair performance in any meaningful way in any well-designed programming language. Having a lovely design (where objects are storing a lot of redundant data) might cause its own problems, but one object holding 70,000 values is not really going to have worse effects on performance than two objects with 35,000 values each. As for when things start to indicate a lovely design, there's no hard-and-fast number to point at. To use a rather trite example, an object representing a two-dimensional coordinate would be poorly-designed if it was holding a dozen separate values - while such an object representing a coordinate in 12-dimensional space would be perfectly reasonable.
|
# ? Jul 11, 2015 10:35 |
|
Hadlock posted:How many object properties is too many? There's one Stack exchange question asking which browsers can support javascript objects with 70,000 properties. That seems.... excessive and poorly implemented. If you're using an object, in JavaScript, as an actual dictionary, accessed via x[y], there's no limit to what's a reasonable number of properties. I mean, algorithmically there might be (or there might not be), but architecturally there isn't anything wrong with huge hash tables. If you've got a bunch of named properties in an object, with specific names (like they'd be fields in a class or struct, in another language), there's maybe two ways to divide the object into smaller objects: 1. Logically, and if that's not applicable, 2. Organizationally. For example, let's say you've got a ton of fields in an object, and some of them look like this: code:
code:
The other is organizationally, where you put the weapons properties in some weapons_info object, and put the health properties in some health_info object. That's fine, but as an architectural improvement it's kind of "meh," -- there's nothing intrinsically wrong with having a bunch of independent fields in the first place. But: if you would find yourself capable of passing only the weapons_info or health_info object, instead of the entire player_info object, to a bunch of subroutines, then that's a substantial organizational win -- not "meh" at all. As for performance, it depends on the language and what you're doing. In Java objects are always behind references, and in C, C++, or C# you have a choice whether they're "flat" or not. You don't want to copy huge objects, and there could be other situational concerns, that are rarely important, regarding cache lines. * or relatively independently sarehu fucked around with this message at 10:59 on Jul 11, 2015 |
# ? Jul 11, 2015 10:52 |
|
sarehu posted:But: if you would find yourself capable of passing only the weapons_info or health_info object, instead of the entire player_info object, to a bunch of subroutines, then that's a substantial organizational win -- not "meh" at all. This is gold, thanks, I think this answers, what I think I was trying to ask This thread is awesome, I appreciate the discussion and extrapolation of questions here, I learn a lot every time someone here posts something because the people who answer are quite good at answering questions, thanks!
|
# ? Jul 11, 2015 11:35 |
|
Xerophyte posted:Take the set of all natural numbers less or equal to N. You can divide that set into two: the last N%2 and the first N - N%2 numbers. E.g. for N = 5 you'd have the sets [0..4] and [5].
|
# ? Jul 11, 2015 11:44 |
|
Try writing out the number of set bits for numbers from 0 up to, say, 15. Are there any patterns you can see? Do the first eight numbers you wrote down have any resemblance to the last 8?
|
# ? Jul 11, 2015 12:01 |
|
|
# ? Jun 4, 2024 01:01 |
|
Jabor posted:Try writing out the number of set bits for numbers from 0 up to, say, 15. Are there any patterns you can see?
|
# ? Jul 11, 2015 13:18 |