language-agnostic

How to convince your fellow developer to write short methods?

Long methods are evil on several grounds: They're hard to understand They're hard to change They're hard to reuse They're hard to test They have low cohesion They may have high coupling They tend to be overly complex How to convince your fellow developer to write short methods? (weapons are forbidden =) question from agiledevelo...

Can I obtain higher resolution in the frequency domain with a stereo signal?

Background I admit, this question stems from an ultimate lack of deep understanding of the underlying mathematics involved with digital signal processing; I'm still learning. I want to take a set of amplitude samples, say 1024 (single channel), and bring them into the frequency domain. Obviously this requires a FFT; no problem there. ...

Judging competency - does one swallow make a summer?

Whilst working on some generally horrible Javascript code this morning, I came across the following (in multiple places): // make moveAmount negative moveAmount = moveAmount - (moveAmount * 2); I sit directly across from the guy that wrote this; he's been a developer here for seven years. I, on the other hand have just started, am pre...

How should substring() work?

I do not understand why Java's String.substring() method is specified the way it is. I can't tell it to start at a numbered-position and return a specified number of characters; I have to compute the end position myself. And if I specify an end position beyond the end of the String, instead of just returning the rest of the String for ...

What is the most effective programming ritual to have?

Looking back at my life and career as a programmer, there are a number of rituals or habits I have developed when it comes to the actual activity of designing and writing software. My question is: What is the most effective ritual you have that improves your ability to either design or write software? What would you recommend to others ...

Language translators: Anything to Assembly

Im just curious if there is is any sort of program/application out there that will allow to enter code in one language and translate that to another language such as asm. This seems perfectly possible....so does anything like this exist? ...

We treat interfaces and implementations like we treat content and styling, so why not handle it similarly?

I've used Spring, and I've looked into Guice, and I think that these are both rather obtrusive extensions to languages. I firmly believe that programming languages themselves need to adapt to patterns more cohesive to dependency injection, testing, etc., so why not gravitate to a stylesheet based approach? By allowing multiple "stylings,...

Monostate vs. Singleton

What are the scenarios when one would use a Monostate pattern instead of singleton inorder to maintain a global object? Edit: I know what Singleton and Monostate patterns are. Have also implemented Singleton in quite a few scenarios. Just want to know the scenarios (case examples) where MonoState pattern needs to be implemented. For eg...

Do any "major" frameworks make use of monkey-patching/open classes

I am curious about the usage of the feature known as open classes or monkey-patching in languages like e.g. Ruby, Python, Groovy etc. This feature allows you to make modifications (like adding or replacing methods) to existing classes or objects at runtime. Does anyone know if major frameworks (such as Rails/Grails/Zope) make (extensive...

Demo (FX) Coding Tutorials?

I'm looking for a few good tutorials to get me started in demo coding. I have some background in CG but it's all rather theoretical. There are many regular 3D programming tutorials, but I'm especially looking for some old school 2D stuff. ...

Inheritance or condition?

I've heard people saying that good design involves using inheritance instead of littering your code with if block. In what situation should we use inheritance, and when condition block is just fine? ...

Algorithm to recognise mouse movements

Hello, Am wondering if there has been any research/algorthms which specify the amount of deviation of the mouse while recognizing characters like say "?" drawn using the mouse. Something a sort of optical character recognition, but probably a simpler version. Is there some algorithm using which I can say that a question mark drawn by th...

Which languages have support for return value caching without boilerplate code?

For methods where ... there exists a static one-to-one mapping between the input and the output, and the cost of creating the output object is relatively high, and the method is called repeatedly with the same input ... there is a need for caching result values. In my code the following result value caching pattern is repeated a lot...

What is a Well Documented, Stable, Secure, and Scalable Web Application Framework?

We are building a RESTful API for our company, which will provide XML, JSON, and potentially other content types. My team is looking to find a framework which is (In order of priority): Well Documented Ideally with good tutorials, and a thriving community and knowledgebase Follows rational design patterns Mostly we want consistency...

Best practices for seaching for alternate forms of a word with Lucene

I have a site which is searchable using Lucene. I've noticed from logs that users sometimes don't find what they're looking for because they enter a singular term, but only the plural version of that term is used on the site. I would like the search to find uses of other forms of a word as well. This is a problem that I'm sure has bee...

Pixies in the custard swamp puzzle

(With thanks to Rich Bradshaw) I'm looking for optimal strategies for the following puzzle. As the new fairy king, it is your duty to map the kingdom's custard swamp. The swamp is covered in an ethereal mist, with islands of custard scattered throughout. You can send your pixies across the swamp, with instructions to fly low or high...

What are some good code optimization methods?

I would like to understand good code optimization methods and methodology. How do I keep from doing premature optimization if I am thinking about performance already. How do I find the bottlenecks in my code? How do I make sure that over time my program does not become any slower? What are some common performance errors to avoid (e.g.;...

Which is preferred: (var==null) or (null==var)

Possible Duplicate: Conditional styles: if (0 == resultIndex) vs if (resultIndex ==0) I've seen both in code, and I do not know why one is better over the other, but which do you prefer to use, and why? ...

Proper OO modelling of correspondences

Something keeps showing up in my programming, and it is that two things are the same from some viewpoint, but different from another. Like, imagine you build a graph of rail stations, connected by trains, then the classes Vertex and RailStation are sometimes the same, other times not. So, imagine I have a graph that very much represent...

How can I parse a list of name=value pairs in a parser generator (ANTLR, YACC etc)?

I want to parse a list of (whitespace separated) pairs in the form of name1=value1 name2=value2 ... where: NAME can contain anything except whitespace and equal sign VALUE can contain anything except whitespace (including equal signs!) The problem is getting the parser to match input like name1=value1 as separate 'NAME EQUAL...