|
22 Eargesplitten posted:I'm trying to start unit testing, and I'm not sure what to use for my test cases. Should I figure out the possible cases for each button the user could push, and then test each one of those? Or am I making more work for myself than I need to? Follow your intuitive sense for what mitigates the most risk for the least amount of work.
|
# ? Feb 1, 2016 23:56 |
|
|
# ? Jun 1, 2024 22:38 |
|
I'm working on a personal project for my portfolio, something to show developers as I don't have much work experience; part of this project involves a fair amount of text manipulation by the user, and as such I'm in the process of implementing undo and redo stacks - something I haven't done before in a project. The approach I've taken is to, when a user performs an operation that changes any textual element, push a node on to the undo stack that contains an opcode, the original text values that are going to be changed (and ONLY those text values), positional data, and a boolean 'more' flag in case I want the undo/redo operation to affect multiple items in the stack. Performing the undo operation will likewise generate a node (or series of nodes) which are pushed onto the redo stack, and vice-versa when the redo operation is performed. My question is this: what is an ideal way to handle a user performing a new operation while items are on the redo stack? Should those items be dumped? This seems to be how some text editors (this is not what I'm making) handle things like this. JawKnee fucked around with this message at 19:47 on Feb 2, 2016 |
# ? Feb 2, 2016 19:41 |
|
The one time I was tasked with writing a text editor, yeah I believe that's what I did. Any time a new command was generated, the redo stack got flushed. That behavior seems relatively standard. Star War Sex Parrot fucked around with this message at 19:47 on Feb 2, 2016 |
# ? Feb 2, 2016 19:45 |
|
I can't think of a redo stack I've used that didn't behave that way.
raminasi fucked around with this message at 01:07 on Feb 3, 2016 |
# ? Feb 2, 2016 22:30 |
|
Cheers. I'm mostly concerned with implementing behaviour the user expects to see, so if that's typical then that's great.
|
# ? Feb 2, 2016 22:32 |
|
People have tried to implement branching undo (e.g. there's a vim plugin for it), but no one's figured out a UI for it that makes it actually useable.
|
# ? Feb 3, 2016 06:20 |
|
I would say you need to be careful with what you class as an undo / redo node. For instance if you stored 100 undo nodes and you tracked each letter as its own node you would lose a lot of the undoability. Most people implement typing (any amount) as one node.so undo undoes the last section of writing.
|
# ? Feb 3, 2016 08:42 |
|
TheresaJayne posted:I would say you need to be careful with what you class as an undo / redo node. For instance if you stored 100 undo nodes and you tracked each letter as its own node you would lose a lot of the undoability. I've noticed that most text editors will start a new undo context when you start a new line. So if you type "foo bar" an undo will remove the whole thing, no matter how long you take to type it. However, if you type "foo<return>bar" it only undoes "bar". Visual Studio also has some more sophisticated rules. For instance if I'm in a C# file and type "public void" and then Ctrl+Z it only removes "void". On the other hand if I type "public foo bar" and undo it removes "foo bar". It looks like it creates a checkpoint of sorts every time you type something syntactically valid.
|
# ? Feb 3, 2016 11:16 |
|
LOOK I AM A TURTLE posted:I've noticed that most text editors will start a new undo context when you start a new line. So if you type "foo bar" an undo will remove the whole thing, no matter how long you take to type it. However, if you type "foo<return>bar" it only undoes "bar". StackOverflow on the other hand seems to override the browser's undo/redo functionality with really lovely over-aggressive node combining that makes it nearly useless. Just checkpoint/combine on word boundaries at most. Don't be Stack Overflow.
|
# ? Feb 3, 2016 16:00 |
|
TheresaJayne posted:I would say you need to be careful with what you class as an undo / redo node. For instance if you stored 100 undo nodes and you tracked each letter as its own node you would lose a lot of the undoability. Luckily this is how my program is handling it by default, though that is more because it isn't in any way a text editor (In abstract the program involves a linked list where each partition in the list contains a vector<string>, and those strings can be operated on, with only operations that change those partitions being considered for undo/redo). Now another, possibly frustratingly vague question; I'm nearing the point where I want to do an initial release of this program, in such a way that anyone can download, and fairly easily run it. I understand this means each new user will have to compile and link the code to any libraries or files I've included, but I've never had to do this before nor been taught how to go about it. I think I should I be packaging not only my own files and any custom libraries I'm using, but also any libraries that may only be included in development environments (as DLLs?) along with some sort of script to handle the compiling and linking for the user. Is this correct?
|
# ? Feb 5, 2016 00:16 |
|
JawKnee posted:Luckily this is how my program is handling it by default, though that is more because it isn't in any way a text editor (In abstract the program involves a linked list where each partition in the list contains a vector<string>, and those strings can be operated on, with only operations that change those partitions being considered for undo/redo). What platform(s) are you releasing for, and are you targeting other developers (i.e. people who will be using your product to build larger pieces of software) or end-users?
|
# ? Feb 5, 2016 00:37 |
|
end-users and I'm aiming for desktop platforms (so Windows 7 and later, and the main Unix platforms - although I haven't had a chance to test on any OS-X machines yet)
|
# ? Feb 5, 2016 00:46 |
|
JawKnee posted:Now another, possibly frustratingly vague question; I'm nearing the point where I want to do an initial release of this program, in such a way that anyone can download, and fairly easily run it. I understand this means each new user will have to compile and link the code to any libraries or files I've included, but I've never had to do this before nor been taught how to go about it. I think I should I be packaging not only my own files and any custom libraries I'm using, but also any libraries that may only be included in development environments (as DLLs?) along with some sort of script to handle the compiling and linking for the user. Is this correct? Unless your program is intended specifically for use by developers -- ideally, developers who are already using the language and toolset your program needs to build -- distributing it as source is nowhere near "anyone can download and fairly easily run it". The minimum threshold for that is usually "a zip or tar.xz files that contains everything you need to run the program in precompiled form, just unzip and run". Extra credit is "an installer or deb/rpm file that lets people install and uninstall the program properly". E: for windows, this generally means the zip needs to contain your program EXE + all DLLs it needs in order to run
|
# ? Feb 5, 2016 00:52 |
|
ToxicFrog posted:Unless your program is intended specifically for use by developers -- ideally, developers who are already using the language and toolset your program needs to build -- distributing it as source is nowhere near "anyone can download and fairly easily run it". The minimum threshold for that is usually "a zip or tar.xz files that contains everything you need to run the program in precompiled form, just unzip and run". Extra credit is "an installer or deb/rpm file that lets people install and uninstall the program properly". Okay, that's helpful, thank you. I haven't been in a position to do this before, so I'm kind of picking it up as I go.
|
# ? Feb 5, 2016 01:04 |
|
What's the future for JS engines in browsers? I don't really know much about how they work, but I remember a lot of articles and the like when stuff like V8 and the monkey engines came out. So, whats the future hold? Are there any big theoretical technologies to come out or is a matter of no one has figured out the next big thing?
|
# ? Feb 5, 2016 01:47 |
|
ES6 support and WebAssembly are the next major things.
|
# ? Feb 5, 2016 01:52 |
|
Suspicious Dish posted:WebAssembly quote:Q: Doesn’t this mean other languages will take over? Won’t this cause fragmentation?
|
# ? Feb 5, 2016 03:02 |
|
There's already a ridiculous number of languages that compile to JavaScript as is. A low-level bytecode designed for that makes sense.
|
# ? Feb 5, 2016 04:18 |
|
Thermopyle posted:What's the future for JS engines in browsers? Microsoft recently open sourced their new JS Engine (Chakra), and has also made it (or almost done) work with Node.js.
|
# ? Feb 5, 2016 04:51 |
|
ToxicFrog posted:Unless your program is intended specifically for use by developers -- ideally, developers who are already using the language and toolset your program needs to build -- distributing it as source is nowhere near "anyone can download and fairly easily run it". Ehhh, to this day it's not totally unusual for projects intended for Linux or Unix end-users - not programmers - to do source releases. Most Linux users should be conversant with ./configure ; make ; make install. Windows or Mac not so much, not least because your installation instructions then become 'First, download Visual Studio/Xcode'...
|
# ? Feb 5, 2016 13:52 |
|
feedmegin posted:Ehhh, to this day it's not totally unusual for projects intended for Linux or Unix end-users - not programmers - to do source releases. Most Linux users should be conversant with ./configure ; make ; make install. Windows or Mac not so much, not least because your installation instructions then become 'First, download Visual Studio/Xcode'... I don't think it's some above and beyond thing to include .deb/.rpm installers for software. There's more to installing an application than just spitting out a binary.
|
# ? Feb 5, 2016 17:30 |
|
feedmegin posted:Ehhh, to this day it's not totally unusual for projects intended for Linux or Unix end-users ... to do source releases.
|
# ? Feb 5, 2016 17:54 |
|
JawnV6 posted:I'll admit it's pretty hard to choose between JavaScript and lesser languages for my hard real time embedded codings. Somebody dig up that article where the guy was proud of the fact that he was able to toggle a pin at speeds as high as 2kHz using javascript.
|
# ? Feb 5, 2016 18:06 |
|
Perhaps I should have mentioned that I'm using C++ for this application; if it would be better for me to take this to the C++ thread let me know - I had thought this would be more of a general question but it's seeming more and more that it isn't really. If I'm providing precompiled headers, the rest of the code I provide will have to be compiled using the same compiler binary; this seems to indicate that I'll need to ensure the user has the right compiler (or am I misunderstanding the use of precompiled here?). How do I go about doing this? I think I need to put the requirements in a configure file, but I'm uncertain.
|
# ? Feb 5, 2016 18:17 |
|
ExcessBLarg! posted:For the time investment it takes to figure out how to make a precompiled release that's tested and works on a variety of distributions, it's probably easier to just build and maintain the packages for Debian and Fedora, so users can install them directly from their package manager. Everyone else can use the source release. If people actually use your software then someone else will do the distro packaging for you.
|
# ? Feb 5, 2016 19:08 |
|
JawKnee posted:Perhaps I should have mentioned that I'm using C++ for this application; if it would be better for me to take this to the C++ thread let me know - I had thought this would be more of a general question but it's seeming more and more that it isn't really.
|
# ? Feb 5, 2016 19:09 |
|
The Laplace Demon posted:There's already a ridiculous number of languages that compile to JavaScript as is. A low-level bytecode designed for that makes sense. fritz posted:Somebody dig up that article where the guy was proud of the fact that he was able to toggle a pin at speeds as high as 2kHz using javascript.
|
# ? Feb 5, 2016 19:19 |
|
JawKnee posted:Perhaps I should have mentioned that I'm using C++ for this application; if it would be better for me to take this to the C++ thread let me know - I had thought this would be more of a general question but it's seeming more and more that it isn't really. Yeah, you don't ship a precompiled header, you just ship your project file along with your source. (The "right" way to do multiplatform source releases is with CMake, but that's a whole other toolset you'd have to learn.) But again: You said your target audience wasn't developers, but just people who want to run the program. Shipping Windows source in this scenario is extremely unusual. raminasi fucked around with this message at 19:54 on Feb 5, 2016 |
# ? Feb 5, 2016 19:44 |
JawKnee posted:Perhaps I should have mentioned that I'm using C++ for this application; if it would be better for me to take this to the C++ thread let me know - I had thought this would be more of a general question but it's seeming more and more that it isn't really. Try copying just the EXE file onto another computer, one without any of your development tools installed. See if it runs fine. Otherwise figure out what to do to make it run. If you don't have another computer handy, learn how to set up a virtual machine. VMs are a very valuable tool when working on software.
|
|
# ? Feb 5, 2016 19:51 |
|
GrumpyDoctor posted:Yeah, you don't ship a precompiled header, you just ship your project file along with your source, and the "right" way to do multiplatform source releases is with CMake, but that's a whole other toolset you'd have to learn. Right, for the Windows version using a compiled .exe which has been statically linked works (even if it is inelegant). I was referring to the approach to releasing on Linux type systems, sorry for the lack of clarity in my previous posts, and also the application was written on a Linux system, so I'm actually trying to ship to Windows from non-Windows source. I'm trying to find some resources on how to go about doing this (specifically with respect to Unix now) but I seem to be searching for the wrong things and asking the wrong questions. I've found this blog post fairly informative though I still can't quite make the jump in what the procedure is here. It seems like the user will need to compile at least some code no matter how aggressively I link libraries and push down requirements on standard libraries - and that I need to make this compilation part of the install process.
|
# ? Feb 5, 2016 19:58 |
|
If I have eight chars in an array vec, but the value represented is actually 55.0 (float). How to I get the float 55.0 out?code:
code:
code:
lord funk fucked around with this message at 20:25 on Feb 5, 2016 |
# ? Feb 5, 2016 20:13 |
|
nielsm posted:Try copying just the EXE file onto another computer, one without any of your development tools installed. See if it runs fine. Otherwise figure out what to do to make it run. This is what I did for Windows but I was under the impression this approach wouldn't work for Unix machines and I can't seem to get a straight answer on whether or not I can just port a compiled binary and have it work provided the linking is all correct (ie: all the needed libraries are either provided with the binary and linked against, or suitable versions are found on the target machine and linked against; my understanding is that the latter would require recompiling the code on the target machine, is this wrong?
|
# ? Feb 5, 2016 20:19 |
JawKnee posted:This is what I did for Windows but I was under the impression this approach wouldn't work for Unix machines and I can't seem to get a straight answer on whether or not I can just port a compiled binary and have it work provided the linking is all correct (ie: all the needed libraries are either provided with the binary and linked against, or suitable versions are found on the target machine and linked against; my understanding is that the latter would require recompiling the code on the target machine, is this wrong? In theory you can make a fully statically linked binary that depends on nothing but the kernel system call interface, that would work on any system with a compatible kernel ABI. You could also make a few more assumptions, such as the libc version and make a semi-static build, or you could even ship a tree with your own builds of various libraries. That's more or less what commercial closed-source software does, they ship a packaging of binaries for some common system configurations and anything outside those is unsupported. In practice, the best way to go is to set up a build system that detects the system configuration and builds and links against the specific library versions found on the machine.
|
|
# ? Feb 5, 2016 20:29 |
|
lord funk posted:
That gets the bits represented as an int32. Maybe use a union? code:
|
# ? Feb 5, 2016 20:37 |
|
lord funk posted:If I have eight chars in an array vec, but the value represented is actually 55.0 (float). How to I get the float 55.0 out? Is there some particular reason why you're doing manual bit twiddling instead of using your language's number parsing functions? Your method is going to break as soon as you try to read an actual float rather than an integer as you're doing now. Recommend you instead construct a string from your chars and pass that to the appropriate library method depending on language (e.g. in Java it'd be Double.parseDouble(str)).
|
# ? Feb 5, 2016 20:51 |
|
TooMuchAbstraction posted:Is there some particular reason why you're doing manual bit twiddling instead of using your language's number parsing functions? Your method is going to break as soon as you try to read an actual float rather than an integer as you're doing now. Recommend you instead construct a string from your chars and pass that to the appropriate library method depending on language (e.g. in Java it'd be Double.parseDouble(str)). He's edited in a solution, the printf was just to show what value was in x, and fritz solved the right problem the right way. How did you read an array with values 0, 92, 66, 0 as being ascii characters that represented "55.0"?
|
# ? Feb 5, 2016 20:54 |
|
I'm doing some ugly stuff with the guts of Pd (Pure Data) by exposing tables' arrays by their address. Pd is a spaghetti tangle of C structs and unions and typedefs upon typedefs with code like this:code:
I recognize what I'm doing with it is hacky, and not for production, just research.
|
# ? Feb 5, 2016 22:04 |
|
JawnV6 posted:He's edited in a solution, the printf was just to show what value was in x, and fritz solved the right problem the right way. How did you read an array with values 0, 92, 66, 0 as being ascii characters that represented "55.0"? Sorry, my bad: I saw "char" and leapt to thinking about strings instead of remembering that it's another term for "byte". It's Friday and I'm, evidently, more tired than I'd realized.
|
# ? Feb 5, 2016 22:31 |
|
Fun fact about unions: writing to one field and then reading off the other is technically "undefined behaviour," even though it'll probably work in most modern compilers. Here's some random post I found on the internet which basically concludes that the memcpy solution is the best one.
|
# ? Feb 5, 2016 23:40 |
|
|
# ? Jun 1, 2024 22:38 |
|
lord funk posted:If I have eight chars in an array vec, but the value represented is actually 55.0 (float). How to I get the float 55.0 out? Use the opposite of whatever put them in that way in the first place. If you use a union or a memcpy, then your solution is platform-specific, and entirely appropriate if the behavior that put them that way was the platform-specific opposite. Your question is really really weird because a float is 4 bytes and and an 8-byte buffer is 8 bytes (sorry). And if casting it to float is working for you, your number is not a double, because a float has 8 exponent bits but a double has 11. The only value 4 of those bytes could possibly have would be to tell whether you should round up or down. Edit: Oh poo poo, oh yeah okay. quote:
The four unused bytes are above the mantissa and your float is represented little-endian. So yeah, you've got four unused bytes. If you want to be ultra-portable you could reconstruct the value mathematically, treating the mantissa as an integer in [0, (1 << 23)), likewise get the exponent, and doing the floating point math right. And handling NaNs the right way and yuckish stuff like that. sarehu fucked around with this message at 02:58 on Feb 6, 2016 |
# ? Feb 6, 2016 02:42 |