language-agnostic

Most elegant way to write a piece of code that handles ramping up and down?

I have the following code in my microcontroller project: if (newThrottle < currentThrottle) { for (int set = currentThrottle; set >= newThrottle; set--) { // Perform actions to set the throttle } } else { for (int set = currentThrottle; set <= newThrottle; set++) { // Perform actions to set the thrott...

Code Golf: Conway's Game of Life

The Challenge: Write the shortest program that implements John H. Conway's Game of Life cellular automaton. [link] EDIT: After about a week of competition, I have selected a victor: pdehaan, for managing to beat the Matlab solution by one character with perl. For those who haven't heard of Game of Life, you take a grid (ideally infinit...

Enterprise Architect Certifications

Hello, I've been a java developer for quite a while, I want to advance towards a position as software architect. Since I'm quite young (26) and my business (consulting) is rather hierarchically organised, I considered starting out with the SCEA - since I'm already SCJP I'm confident about my learning techniques and the ability to deal w...

In what cases should public fields be used instead of properties?

Possible Duplicate: Public Data members vs Getters, Setters In what cases should public fields be used, instead of properties or getter and setter methods (where there is no support for properties)? Where exactly is their use recommended, and why, or, if it is not, why are they still allowed as a language feature? After all, t...

Where to store the state in a MVP architecture

In other MVP-related questions on SO, people talk about the Presenter keeping the state information (could be session state or UI state). What I'm wondering is, since state is basically "transient data", and the Model's purpose is to encapsulate data access, can't state be kept inside the Model? Are there any rules of thumb or pros/cons ...

Model-View-Presenter lifecycle management in a plug-in based GUI

When a GUI is composed of several subcomponents that I treat as individual Views with their own Presenter and Models, is there a pattern for gluing them together? Some subcomponents are persistently on the screen while others would get swapped in and out. What would be a good factory pattern for instantiating the respective MVP triad f...

Modifying generated code

I'm wrapping a C++ library in PHP using SWIG and there have been some occasions where I want to modify the generated code (both generated C++ and PHP): Fix code-generation errors Add code that makes sense in PHP, but not in C++ (e.g. type checking) Add documentation tags (e.g. phpDoc) I'm currently automating these modifications with...

application of AI/neural networks/machine learning in stock market trading: looking for a book(s)

Hello. I'm looking for a book(s) about practical application of machine learning, artificial intelligence and neural networks to stock market trading (automated trading or as an assistance to human, mostly automatic trading). I'm not afraid of "heavy reading". What I'm interested in: 0. How can the problem (how to achieve goal dependin...

How should I have users specify the "Next Item"?

I'm writing an application where an admin user will create a sequence of items. When a user creates an item they need to be able to specify what the next item in the sequence will be. My problem is that users will probably create items in order and, since the next item doesn't yet exist i'm not sure how to have them specify what they...

Cancelling some data processing with return values or exceptions. What pattern is more suitable?

I have lots of code which is doing some data processing (in C# to be more specific). Very often the data may be only processed, if some criteria are met. Since the criteria can be rather complex, they are checked in a lazy fashion. They are not checked beforehand. Thus: If during the processing some criterion is not matching, the process...

What exact happens in the process of Recursion ?

Can anyone tell me what exactly happens in a Recursion Program.. ?? ...

Multivariate Bisection Method

I need an algorithm to perform a 2D bisection method for solving a 2x2 non-linear problem. Example: two equations f(x,y)=0 and g(x,y)=0 which I want to solve somultaneously. I have very familiar with the 1D bisection ( as well as other numerical methods ). Assume I already know the solution lies between the bounds x1 < x < x2 and y1 < y ...

What are magic numbers?

What is meant by magic numbers from a programming point of view. ...

Free professional development software

I've just stumbled on a Microsoft program that offers Visual Studio Professional, among other things like SQL Server and Windows Server 2008, for free (as in beer). The catch is that you have to be a student. Anyone know any other places where you can acquire software like this for free - legally that is. ...

Sampling random nodes from a DAG

I have a large directed, acylic graph (DAG) from which I would like to efficiently draw a sample node according to the following criteria: I specify a fixed node A that must never be sampled Nodes that directly or indirectly refer to A are never sampled All other nodes are sampled with equal probability Nodes are stored as objects wi...

Code Golf: Regex parser

The goal Today's Code Golf challenge is to create a regex parser in as few characters as possible. The syntax No, I'm not asking you to match Perl-style regular expressions. There's already a very reliable interpreter for those, after all! :-) Here's all you need to know about regex syntax for this challenge: A term is defined as a...

How do i test for a dynamic set of elements from my code without hard-coding?

The question will best be understood with an example. I have Hospital One who have 3 main pharmacies called; Central Pharmacy, Ward Pharmacy, and Private Suite. These pharmacies can be added, deleted, and extended at will. While these go on i would love to know from my code when we are talking about a Central Pharmacy or a Ward Pharmac...

All languages - Procedural Efficiency

Hi Consider these to options if(successful) { if(condition) { //do something } if(condition) { //do something } ... } or if(successful)&&(condition) { //do something } if(successful)&&(condition) { //do something } ... Imagine there 100 if statements. Is there any difference in effi...

given a set of conditions, algorithmically determine only one can be True

Given a set of two or more logical conditions, is it possible to algorithmically determine that exactly ONE of them will evaluate to TRUE? For example: # this should pass, since for every X, only one condition is taken cond 1: (X >= 1.0) cond 2: (X < 1.0) # this should fail cond 1: (X < 1.0) cond 2: (X > 2.0) # this should also fail,...

Code Golf: Movement in 3 Dimensions

Assuming a 3 dimensional irregular matrix where y = 1.5(x) and z = .5(y). Further assuming an object starts at 0,0,0 and must move positively in at least two dimensions, and must move in all three dimensions (x+1, y+1, z-1 is okay, x+1, y+1, z=z is not). It may move any number of "spaces", but must move the same number in all direction...