language-agnostic

What does the "static" keyword mean in OOP?

For quite some time, I have been unsure about what the Keyword "Static" does while it is used in OOP. I know that if we define a static variable, the value remains the same through out all instances of that class, what does it do when it is used with class or method. I mean, What is a static method and Static class? On what condition...

Static and dynamic scoping

Hi All, I always get confused between the static and dynamic scoping and hence need someone to examine my evaluation. Following is the example code: int x = 1; procedure P(i) { int x = 1; i++; Q(i); } procedure Q(j) { j = j + x; } P(x) print x In static scoping, we always look at the placement of the function/procedure to underst...

Why GetHashCode is in Object class ????

Why GetHashCode is part of the Object class? Only small part of the objects of the classes are used as keys in hash tables. Wouldn't it be better to have a separate interface which must be implemented when we want objects of the class to serve as keys in hash table. There must be a reason that MS team decided to include this method in O...

Crawling and Scraping iTunes App Store

I noticed that iTunes preview allows you to crawl and scrape pages via the http:// protocol. However, many of the links are trying to be opened in iTunes rather than the browser. For example, when you go to the iBooks page, it immediately tries opening a url with an itms:// protocol. Are there any other methods of crawling the App Store...

The Travel Tickets Problem

You are given a stack of travel tickets for various transportations that will take you from a point A to point B via several stops on the way. All of the tickets are out of order and you don't know where your journey starts, nor where it ends. Sort the tickets in the right order to complete your journey. tickets = [ {from: "Barcelo...

Code vs. configuration for game object library

I'm working on a small online game where there is a need to store a reasonable amount of information about many (100+) different kinds of game objects. I'm trying to decide whether to have this data generated by code or stored in some configuration file. Data generation approach would be something like (in java-ish pseudo code): (wit...

Is To Manually Assign An Entity's IDs A Good Idea?

We're developing a system to replace an old application from our clients. Actually there are many entities (like merchants, salesmen, products, etc) that must have a manual assigned ID -so they can be integrated with other existing systems. i.e. accounting. We think the best solution is simply allow the user to assign the entities IDs ...

name for a function that transforms assignment statements to expressions

update Since one effect of these functions is to provide a way to use method chaining on methods that would not normally support it *, I'm considering calling them chain and copychain, respectively. This seems less than ideal though, since the would-be copychain is arguably a more fundamental concept, at least in terms of functional pr...

A code that is a word forwards & a different word backwards

Hello! For a present, I am trying to create a code that reads as a certain word forwards and a different word backwards. An example (0,1,2 are the available symbols): D = 02, E = 01, H = 201, L = 1, O = 211, R = 10, W = 11 Then the pair "HELLO"/"WORLD" would be 2010111211 HELLO 1121110102 WORLD I would like to generate a code ...

Private Variable Instantiation: When Defined or Within Constructor?

I don't know if this has been asked before, but we're having a discussion about it today at my job. Should private variables (that are shared/static) be instantiated when they are dimensioned/defined, or is it a better practice to do this inside of a constructor? For example, this seems perfectly fine to me... Public Class IpCam ...

Webhost that allows outbound connections...?

Does anyone know of a host that would allow this kind of code to run (any language): socket.open( "69.128.34.54", //any ip address basically 5555); // also any port //write to socket... //get response... socket.close(); I am looking for pretty much any outbound IP, and pretty much any standard port (1024-65535). Note: these ar...

Programmers dictionary/lexicon for non native speakers

I'm not an English speaker, and I'm not very good at English. I'm self thought. I have not worked together with others on a common codebase. I don't have any friends who program. I don't work with other programmers (at least nobody who cares about these things). I guess this might explain some of my problems in finding good unambiguous ...

Are input sanitization and parameterized queries mutually exclusive?

I'm working updating some legacy code that does not properly handle user input. The code does do a minimal amount of sanitization, but does not cover all known threats. Our newer code uses parameterized queries. As I understand it, the queries are precompiled, and the input is treated simply as data which cannot be executed. In that cas...

Rationale behind fuction name of Foo()

Possible Duplicate: Using Foo and Bar in examples This may not be really a meaningful question but just like having names Dirty and Clean what was the rational behind having Foo() function name ...

Object allocation inline on the stack....

What does that mean when it says 'object allocation inline on the stack'? Especially the 'inline' bit ...

What is a "value" array?

In C, the idea of an array is very straightforward—simply a pointer to the first element in a row of elements in memory, which can be accessed via pointer arithmetic/ the standard array[i] syntax. However, in languages like Google Go, "arrays are values", not pointers. What does that mean? How is it implemented? ...

Open sourcing a commercial site

I am building a 'software as a service' website that will be charging users a small monthly fee. I am considering changing the Github repository over from Private to Public. Essentially open sourcing it. Is this suicide? I would like the community to be able to benefit from the code. It is unlikely that I will accept any push request so ...

OpenGL Newbie - Best way to move objects about in a scene

I'm new to OpenGL and graphics programming in general, though I've always been interested in the topic so have a grounding in the theory. What I'd like to do is create a scene in which a set of objects move about. Specifically, they're robotic soccer players on a field. The objects are: The lighting, field and goals, which don't cha...

Repeated application of functions

Reading this question got me thinking: For a given function f, how can we know that a loop of this form: while (x > 2) x = f(x) will stop for any value x? Is there some simple criterion? (The fact that f(x) < x for x > 2 doesn't seem to help since the series may converge). Specifically, can we prove this for sqrt and for log? ...

How should I design a method that allows for optional operations?

For example, suppose I this: class Gundam00 extends Gundam implements MobileSuit { ... public void fight(final List<MobileSuit> mobiruSuitso, final List<Gundam> theOtherDudes, final List<Person> casualities) { .... } } Suppose theOtherDudes and casualities parameters are optional. How can I make this method as cle...