language-agnostic

Best Way For Back Button To Leave Form Data

你。 提交于 2019-12-19 03:46:32
问题 I'm creating a web page based on user input from a form. After the user sees the generated page I want to allow them to press the back button and make changes to the form. I would like to display the form as they had filled it out previously. What is the best way to get this behavior (with cross browser support)? 回答1: After the user sees the generated page I want to allow them to press the back button and make changes to the form. I would like to display the form as they had filled it out

Cube on Cube collision detection algorithm?

荒凉一梦 提交于 2019-12-19 03:46:14
问题 I'm trying to find the most efficient way to check if 2 arbitrarily sized cubes collide with each other. The sides of the cubes are not necessarily all equal in length (a box is possible). Given these constraints, how could I efficiently check if they collide? (each box has 24 verticies) Thanks They are axis alligned 回答1: Since both boxes are axis-aligned you can just compare their extents: return (a.max_x() >= b.min_x() and a.min_x() <= b.max_x()) and (a.max_y() >= b.min_y() and a.min_y() <=

How to avoid reusing identical implementation code with an interface?

流过昼夜 提交于 2019-12-19 03:39:13
问题 First of all, I apologize for "yet another interface question". I thought that this one might be worth asking, though, as it's kind of a strange issue. The project I'm using uses Actionscript 3, but this is more of a general OOP question. Here's the situation: I have a class that already inherits from a base class; it's an object in a videogame. (Let's say it's a spaceship.) In my game, I'd like to have many many many spaceships onscreen, at one time, so I've decided to create an object pool

What language will protect my source code?

假如想象 提交于 2019-12-19 03:21:49
问题 I wish to create shareware software that contains a registration algorithm. I am looking for a programming language, that cannot be easily decompiled into readable code. For example, C# can be decompiled into readable code. What are my options? Edit: I'm looking for something that can be only decompiled into assembly. Delphi, for example, cannot be decompiled like C# or Java, but from what I've heard, Delphi is dying. 回答1: Delphi is not dying, it is alive and well. As is the community, at

Possible to implement a manual increment with just simple SQL INSERT?

Deadly 提交于 2019-12-19 03:17:00
问题 I have a primary key that I don't want to auto increment (for various reasons) and so I'm looking for a way to simply increment that field when I INSERT. By simply, I mean without stored procedures and without triggers, so just a series of SQL commands (preferably one command). Here is what I have tried thus far: BEGIN TRAN INSERT INTO Table1(id, data_field) VALUES ( (SELECT (MAX(id) + 1) FROM Table1), '[blob of data]'); COMMIT TRAN; * Data abstracted to use generic names and identifiers

Whether variable name in any programming language takes memory space

那年仲夏 提交于 2019-12-19 03:13:19
问题 e.g. int a=3;//-----------------------(1) and int a_long_variable_name_used_instead_of_small_one=3;//-------------(2) out of (1) and (2) which will acquire more memory space or equal space would be aquire? 回答1: Both occupy the same amount of memory. Variable names are just to help you, the programmer, remember what the variable is for, and to help the compiler associate different uses of the same variable. With the exception of debugging symbols, they make no appearance in the compiled code.

Human Name parsing

試著忘記壹切 提交于 2019-12-19 03:08:32
问题 I have a bunch of human names. They are all "Western" names and I only need American conventions/abbreviations (e.g., Mr. instead of Sr. for señor). Unfortunately, the people to whom I am sending things did not input their own names so I can't ask them what they would like to be called. I know the gender of each person and their full name, but haven't really parsed things out more specifically. Some examples: John Smith John Smith, Jr. John Smith Jr. John Smith XIV Dr. John Smith, Ph.D. I'd

Are event handler, event listener, and event registration all referring to the same thing?

ε祈祈猫儿з 提交于 2019-12-18 21:50:03
问题 If not, what is their difference? 回答1: The listener is the object that receives notification, the handler is the method that actually handles the notification. Registration means to register a new listener to the event source. 回答2: The Event Handler is the method that gets called to handle the Event. The Event Listener is the mechanism that listens for the Event to happen. It then calls the Event Handlers. Event Registration is the process by which an Event Handler gets registered with an

Virtual functions in constructors, why do languages differ?

走远了吗. 提交于 2019-12-18 19:09:21
问题 In C++ when a virtual function is called from within a constructor it doesn't behave like a virtual function. I think everyone who encountered this behavior for the first time was surprised but on second thought it made sense: As long as the derived constructor has not been executed the object is not yet a derived instance. So how can a derived function be called? The preconditions haven't had the chance to be set up. Example: class base { public: base() { std::cout << "foo is " << foo() <<

What is the Ghost Design Pattern?

£可爱£侵袭症+ 提交于 2019-12-18 19:07:32
问题 Someone recently asked a question about the Ghost Design Pattern - I have not seen this before. What is the Ghost Design Pattern and how is it implemented? I can only find snippets on the web in reference to it. 回答1: The only reference I've ever heard to a Design Pattern and 'Ghost' is in Lazy-Loading. Since Lazy-loading involves only loading the object when it's actually needed, you can think of it as a 'Ghost' until then. You can see its outline, but can't really use it until it's loaded.