Sometimes all we have to work with manual input, not relying on Intellisense - with components, XML, other declarative things, strings, dynamic languages, scripts. Do you have some useful skills which minimize bugs invoked by manual input?
I don't mean coloring - it is more or less trivial and usually don't depend on programmer. But suc...
Suppose we have N numbers(integers, floats, whatever you want) and want to find their arithmetic mean. Simplest method is to sum all values and divide by number of values:
def simple_mean(array[N]): # pseudocode
sum = 0
for i = 1 to N
sum += array[i]
return sum / N
It works fine, but requires big integers.
If we don...
...meaning pattern in its general English usage, not specific to OO design patterns. Given a table like the following (using <% %> as generic server-side script tags):
<form action="someUri" method="post">
<table>
<thead>
<tr>
<td>Widget ID</td>
<td>Description</td>
<td>Price</td>
...
The common mixing of RGB colors is very different from mixing colors for paintings,
it's mixing of light instead mixing of pigments.
For example:
Blue (0,0,255) + Yellow (255,255,0) = Grey (128,128,128)
(It should be Blue + Yellow = Green)
Is there any known algorithm for color mixing that works like mixing real colors?
I've alread...
The challenge
The shortest code by character count, that will input a string using only alphabetical characters (upper and lower case), numbers, commas, periods and question mark, and returns a representation of the string in Morse code.
The Morse code output should consist of a dash (-, ASCII 0x2D) for a long beep (AKA 'dah') and a dot...
Lets say I have an array of length n and I want to pick k values from it, evenly, starting from 0. If k divides n, then this would be easy, but if k does not divide n, then I need to vary the value m I increment the array pointer with. How would you do this?
For example, if m=1.5 then I want to pick the following numbers:
var arr = arra...
I'm writing an interface that requires classes to implement a clone() method. My naive approach to this went along the following lines:
public interface ISolvableGame {
function clone():ISolvableGame;
//...
}
elsewhere:
public class MyGame implements ISolvableGame {
public function clone():MyGame {
// ...
}
}
...
Preamble
To build dynamic web-sites, we to master at least four languages:
HTML for the structure of web pages
CSS for layout and design
JavaScript for interactivity
A language for business rules or dynamic driven data
In addition, there's SQL for persistent storage, Memcache for sessions and caching, APIs for the many different con...
I have a set of 2D points from which I want to generate a polygon (or collection of polygons) outlining the 'shape' of those points, using the following concept:
For each point in the set, calculate the convex hull of all points within radius R of that point. After doing this for each point, take the union of these convex hulls to produ...
Are circular class dependencies bad from a coding style point of view?
Example:
In a database application we have two classes, one encapsulating information about a single database (DBInfo) and one class which can create a database connection. (ConnFactory)
DBInfo has a getConnection method which uses ConnFactoryto create a connection...
It is agreed by many that commented out code is a bad thing if you are using source control.
(And it is agreed by many more, that if you are not using source control, that is even a worse thing).
So the question is, do you know a tool that detected (too much) commented out code?
Do you think such a thing would be a useful [[your-buil...
I want to make a site that is both difficult to screen-scrap and accessible.
Is that an oxymoron?
...
In response to What is your longest-held programming assumption that turned out to be incorrect? question, one of the wrong assumptions was:
That private member variables were
private to the instance and not the
class.
(Link)
I couldn't catch what he's talking about, can anyone explain what is the wrong/right about that with a...
This is just a general design question. If you are developing a business component or service, (e.g. an object/service that exposes a relatively simple interface for handling billing transactions), what are some good ways to handle business-related errors?
Say the component/service must integrate with a few different external web servi...
After reading this post I kinda felt in the same position as the guy who asked the question. I love technology and coming up with new ideas to solve real world problems just gets my neurons horny, but the other part of the equation - actually getting things done (fast) - is normally a pain in the ass to accomplish, specially when I'm doi...
I'm currently reviewing a very old C++ project and see lots of code duplication there.
For example, there is a class with 5 MFC message handlers each holding 10 identical lines of code. Or there is a 5-line snippet for a very specific string transformation every here and there. Reducing code duplication is not a problem in these cases a...
I have a data set of players' skill ranking, age and sex and would like to create evenly matched teams.
Teams will have the same number of players (currently 8 teams of 12 players).
Teams should have the same or similar male to female ratio.
Teams should have similar age curve/distribution.
I would like to try this in Haskell but the...
I think copy/paste is one of the worst practices there could be in the industry.
Copy and paste code snippets it's ok. That's how most of the code is learn in first place, and saves a lot of time.
What is definitely harmful ( at least from my point of view ) is to copy one section of code from a class or file within THE SAME PROJECT!....
There are days (at least in my life) when you are sooo tired but you must finish the program, build the release, ship the product, etc. I'm talking about loong nights full of coffee, 4-hour sleep-time and a whole lot of work to be done. How do you keep yourself productive in such days?
...
Hi,
I'm interested in creating a sort of hand-off authentication method, where there's a client and two servers (let's call them Alice, Bob and Carmen Sandiego, respectively). Alice is a client (in a browser) somewhere on the 'net, possibly behind a NAT that gives a different IP for outgoing requests to different addresses (I know there...