Programming FAQ: Page 62
-
Java: using a RuntimeException to escape from a Visitor
Exerpt: I am being powerfully tempted to use an unchecked exception as a short-circuit control-flow construct in a Java program. I hope somebody here can advise me on a better, cleaner way …
Tags: java, exceptions, callcc, visitor
-
Your Favorite Code Kata
Exerpt: What are your favorite code kata? What do you do to practice software development? Where do you go to find new small projects to practice? We already know Jeff's answers.
Tags: subjective, self improvement, improvement, code kata
-
A python web application framework for tight DB/GUI coupling?
Exerpt: I'm a firm believer of the heretic thought of tight coupling between the backend and frontend: I want existing, implied knowledge about a backend to be automatically made use of wh …
Tags: python, sql, metadata, coupling, data driven
-
What is the most appropriate .NET exception to throw upon failing to load an expected registry setting?
Exerpt: I have an application which tries to load some expected registry settings within its constructor. What is the most appropriate .NET Exception from the BCL to throw if these (essen …
Tags: .net, c#
-
How do you get the footer to stay at the bottom of a Web page?
Exerpt: I have a simple 2-column layout with a footer that clears both the right and left div in my markup. My problem is that I can't get the footer to stay at the bottom of the page in …
Tags: html, css, footer, div
-
Questions about Setuptools and alternatives
Exerpt: I've seen a good bit of setuptools bashing on the internets lately. Most recently, I read James Bennett's On packaging post on why no one should be using setuptools. From my time i …
Tags: setuptools, pip, python, packaging
-
I just don’t get continuations!
Exerpt: What are they and what are they good for? I do not have a CS degree and my background is VB6 -> ASP -> ASP.NET/C#. Can anyone explain it in a clear and concise manner?
Tags: functional programming, continuations, callcc
-
Where can F# actually save time and money?
Exerpt: There is a lot of hype around the latest functional programming language F# from Microsoft. In real life - where (in what kind of scenarios) can F# most likely save time and money? …
Tags: .net, functional programming, f#
-
JavaScript Hashmap Equivalent
Exerpt: As made clear in update 3 on this answer, this notation: var hash = {}; hash[X] does not actually hash the object X; it actually just converts X to a string (via .toString() if …
Tags: javascript, hashmap, language features, data structures
-
On the web, what fonts should I use to create an equivalent experience cross-platform?
Exerpt: Because Linux (and it's variants) have a completely different set of fonts than Windows and Mac OS X, is there anyone with any experience of creating cross platform font families - …
Tags: linux, css, cross platform, fonts
-
How much input validation should I be doing on my python functions/methods?
Exerpt: I'm interested in how much up front validation people do in the Python they write. Here are a few examples of simple functions: def factorial(num): """Computes the factorial …
Tags: python, best practices, input validation, subjective
-
When should I mock?
Exerpt: I have a basic understanding of mock and fake objects, but I'm not sure I have a feeling about when/where to use mocking - especially as it would apply to this scenario here.
Tags: unit testing, mock
-
Early binding vs. late binding: what are the comparative benefits and disadvantages?
Exerpt: When discussing the evolution of computer languages, Alan Kay says that the single most important attribute of his Smalltalk is late binding; it gives the language its malleability …
Tags: binding, early, late, smalltalk
-
What tool to use for automatic nightly builds?
Exerpt: I have a few Visual Studio Solutions/Projects that are being worked on in my company, which now require a scheme for automatic nightly builds. Such a scheme needs to be able to che …
Tags: visualstudio, build process
-
How to get my first programming job.
Exerpt: What is the best way to go about getting your very first programming job? I am currently going to college but have a few years before I graduate. I want to get out of my current "f …
Tags: programming, resume, employment, subjective
-
Altering database tables in Django
Exerpt: I'm considering using Django for a project I'm starting (fyi, a browser-based game) and one of the features I'm liking the most is using syncdb to automatically create the database …
Tags: database, django
-
Are there any “nice to program” GUI toolkits for Python?
Exerpt: I've played around with GTK, TK, wxPython, Cocoa, curses and others. They are are fairly horrible to use.. GTK/TK/wx/curses all seem to basically be direct-ports of the appropriate …
Tags: python, gui
-
Interview programming test practice
Exerpt: Does anyone know of some good resources for practice coding questions typically asked in interviews. I know of topcoder.com which is kind of fun to use to exercise your algorithms. …
Tags: language agnostic, programming, testing, learning, interview
-
P/Invoke in Mono
Exerpt: What's the current status of Mono's Platform Invoke implementation on Linux? And on Solaris?
Tags: .net, linux, mono, solaris, pinvoke
-
How do I begin using SVN?
Exerpt: I am ready to start using SVN, but I have NO (as in the money required for free beer) experience with source control. I have installed subversion on my server (that was easy, 'apt …
Tags: svn, beginner
-
What’s the best toolkit for doing 2d game programming with Python?
Exerpt: What's the best toolkit for doing 2d game programming with Python? I've heard of pygame but is there anything I should add to it or is there another group of modules that surpasse …
Tags: python, game development
-
Can you pair program remotely?
Exerpt: We have a team of about 7 engineers, whom I supervise. We do not have a formal office where we all work. Instead, a handful are located outside of our city, while the rest of us ar …
Tags: tdd, remote, pair programming
-
Building a custom Linux Live CD
Exerpt: Can anyone point me to a good tutorial on creating a bootable Linux CD from scratch? I need help with a fairly specialized problem: my firm sells an expansion card that requires c …
Tags: linux
-
Is there anything like TortoiseCVS and TortoiseSVN for git?
Exerpt: I looked briefly, but I didn't see anything right off. Does anyone know anything for
Tags: version control, git, tortoisesvn
-
Best books about TDD
Exerpt: I'd like to enhance my TDD knowledge and practice. What would you recommend to read?
Tags: subjective, books, tdd
-
Is there an “exists” function for jQuery
Exerpt: So I know that you can do: if ($(selector).length>0) { // Do something } But is there a more elegant method?
Tags: javascript, jquery
-
Checklist for Web Site Programming Vunerabilities
Exerpt: Watching SO come online has been quite an education for me. I'd like to make a checklist of various vunerabilities and exploits used against web sites, and what programming techni …
Tags: web, security, defensive programming
-
Why do you not explicitly call finalize() or start the garbage collector?
Exerpt: After reading this question, I was reminded of when I was taught Java and told never to call finalize() or run the garbage collector because "it's a big black box that you never ne …
Tags: java, garbage collection
-
Best javascript compressor
Exerpt: What is the the best Javascript compressor available? I'm looking for a tool that: Easy to use High compression rate Reliable end results (doesn't mess up the code)
Tags: javascript, compression
-
Which PHP opcode cacher should I use to improve performance?
Exerpt: I'm trying to improve performance under high load and would like to implement opcode caching. Which of the following should I use? APC - Installation Guide eAccelerator - Install …
Tags: php, performance, caching
-
What’s the difference between a temp table and table variable in MSSQL?
Exerpt: In Sql Server 2005, we can create temp tables one of two ways: declare @tmp table (Col1 int, Col2 int); or create table #tmp (Col1 int, Col2 int); What are the differences be …
Tags: sqlserver
-
How can you require a constructor with no parameters for types implementing an interface?
Exerpt: Is there a way? I need all types that implement a specific interface to have a parameterless constructor, can it be done? I am developing the base code for other developers in my …
Tags: c#, .net, interfaces, ood, constructor
-
Reserved Keywords in Javascript
Exerpt: What Javascript keywords (function names, variables, etc) are reserved?
Tags: javascript
-
How to create a pluginable Java program?
Exerpt: I want to create a Java program that can be extended with plugins. How can I do that and where should I look for? I have a set of interfaces that the plugin must implement, and it …
Tags: java, plugins
-
Dynamic Memory Allocation Failure Recovery
Exerpt: I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't c …
Tags: c++, embedded, windowsce, viper, new
-
I want to assign a record to TStringList.Objects
Exerpt: Hi guys! I want create a Playlist control. I have a lot of information to display into a TStringList. I want to assign a record to TStringList.Objects instead of an object because …
Tags: delphi
-
How do you answer the “Why do you want to work here?” interview question?
Exerpt: Is it better to answer it focusing on why the company is good, or how the job will affect you personally? (ie: by gaining experience and growing) Also, I never feel I answer corre …
Tags: subjective, interview questions, jobs, interview
-
How to translate a virtual memory address to a physical address?
Exerpt: In my C++ program (on Windows), I'm allocating a block of memory and can make sure it stays locked (unswapped and contiguous) in physical memory (i.e. using VirtualAllocEx(), MapUs …
Tags: memory, physical, virtual, windows, c++
-
What’s the best mock framework for Java?
Exerpt: What's the best framework for creating mock objects in Java? Why? What are the pros and cons of each framework?
Tags: java, subjective, mock, unit testing
-
What alternative do I have to ugly submit buttons in html forms?
Exerpt: I'd like to make a simple html form where a person can upvote or downvote an item. However I don't like the default look of a <input type="submit"> . What other options do I …
Tags: html, forms
-
How do I download a file over HTTP using Python?
Exerpt: I have a small utility that I use to download an MP3 from a website on a schedule and then builds/updates a podcast XML file which I've obviously added to iTunes. The text process …
Tags: python, podcast
-
Are there any good parsing libraries for .Net?
Exerpt: I'm looking for something simple to use where the grammar is easy to define.
Tags: parsers, .net
-
What are the main differences between programming for windows XP and for Vista?
Exerpt: From a desktop application developer point of view, is there any difference between developing for windows XP and developing for windows Vista?
Tags: vista, windows xp
-
Atom Publishing Protocol in real life
Exerpt: I know that some big players have embraced it and are actually exposing some of their services in APP compliant way, already. However, I haven't found many other (smaller) players …
Tags: atompub, atom publishing protocol, web services, language agnostic, web development
-
.NET - Throwing Exceptions best practices
Exerpt: What are the best practices to consider when catching exceptions, and re-throwing them. I want to make sure that the Exception object's InnerException and stack trace are preserved …
Tags: c#, .net, error handling
-
Alternatives to stock options as a way to motivate software engineers
Exerpt: I'm in the early stages of a relatively new company that is already cash-flow positive (despite the gloomy economy!), and I soon hope to hire some software developers. I'm thinkin …
Tags: business, management, compensation
-
Why can’t I declare static methods in an interface?
Exerpt: The topic says the most of it - what is the reason for the fact that static methods can't be declared in an interface? public interface ITest { public static String test(); } …
Tags: java, interfaces, methods, static, whycantyou
-
Refactoring: When do you know it’s time and when do you do it?
Exerpt: When do you know it's time to refactor/review some piece of code ? And better yet, when do you do it? Probably like others, I've found myself knowing that something needs a refact …
Tags: programming, refactoring, project planning
-
What is the most brilliant regex you’ve ever used?
Exerpt: I'm constantly amazed by the power of the regex. What I'm looking for here is: Regexs that are more cleverly badass than ridiculously badass Regex replacements are acceptable as …
Tags: subjective, regex, humor
-
How do you organize your Documentation?
Exerpt: I need a documentation system for a team. This team, man, we got a big ol' web service, and we got new products in the pipeline. And currently, there's only a wiki hosted on a trac …
Tags: documentation, organization, management, process
-
How do you embed binary data in XML?
Exerpt: I have two applications written in Java that communicate with each other using XML messages over the network. I'm using a SAX parser at the receiving end to get the data back out …
Tags: java, xml
-
How to profile PostgreSQL Database?
Exerpt: I want to profile (keep an Eye on) all the activities that goes on in a Database which is in PostgreSQL. Is there any such utility which will help me do this?
Tags: postgresql, profiling, monitoring
-
Suggested gaming platform to learn - Direct X (C++), Open GL or XNA
Exerpt: My nephew is an aspiring game developer. I have taught him a bit of C/C++, and suggested he learn that for a start. Once he has come to grips with that, which game/graphics API's …
Tags: graphics, opengl, game development, xna, directx
-
Algorithm for finding the smallest power of two that’s greater or equal to a given value
Exerpt: I need to find the smallest power of two that's greater or equal to a given value. So far, I have this: int value = 3221; // 3221 is just an example, could be any number int resul …
Tags: algorithm, c++, assembly
-
How to plan your learning process efficiently?
Exerpt: I wonder is there a good strategy to use when you're about to start learning completely new stuff. For example, you want to learn LISP and you know nothing about functional progr …
Tags: learning, self improvement
-
Is it possible to retroactively turn a set of commits into a branch?
Exerpt: Say I have a git repository and I've been working on master, can I retroactively create a branch. For example: A - B - C - A1 - D - A2 - E I want to make it look like this: A - …
Tags: git, branch
-
SQL - How can I remove duplicate rows?
Exerpt: What is the best way to remove duplicate rows from a fairly large table (i.e. 300,000+ rows)? The rows of course will not be perfect duplicates because of the existence of the Row …
Tags: sql, sqlserver
-
What does Java use to determine if a key is a duplicate in a Map?
Exerpt: My first instinct is to say each key is an object, and has a hash code, which is what is used to determine if a duplicate is being inserted. However, I can't find anything to back …
Tags: java, map
-
Which are your productivity tools?
Exerpt: What tools do you use to boost up your application development?
Tags: productivity, software tools
-
What is a good way to implement an agile database process, which is in synch with the code base, especially in regards to continuous integration?
Exerpt: The project I am working on were are trying to come up with a solution for having the database and code be agile and be able to be built and deployed together. Since the applicati …
Tags: database, agile, database design, version control, continuous integration
-
Why doesn’t **find** find anything?
Exerpt: I'm looking for shell scripts files installed on my system, but find doesn't work: $ find /usr -name *.sh But I know there are a ton of scripts out there. For instance: $ ls / …
Tags: unix, bash, shell, ksh
-
Python idiom to return first item or None
Exerpt: I'm sure there's a simpler way of doing this that's just not occurring to me. I'm calling a bunch of methods that return a list. The list may be empty. If the list is non-empty, …
Tags: python, idioms, python2.4
-
Java: Best way of converting List<Integer> to List<String>
Exerpt: I have a Java list of integers, List<Integer> and I'd like to convert all the integer objects into strings, thus finishing up with a new List<String>. Naturally, I cou …
Tags: java, string, collections, conversion, integer
-
What does the “@” symbol do in Powershell?
Exerpt: I've seen the @ symbol used in PowerShell to initialise arrays. What exactly does the @ symbol denote and where can I read more about it?
Tags: powershell, syntax
-
Best environment for Python on Windows?
Exerpt: So I've got plain python downloaded, so I can run .py files from the command line. Now I want to step it up, have a debugger, be able to call .net or other Windows things, etc... …
Tags: python, windows
-
Setting default value for function argument in actionscript 3
Exerpt: Is there any way that I can reference a var or const as the default value for a function argument in actionscript 3. I can define default values like null, string, int. function …
Tags: actionscript3
-
Looking for a better C++ class factory
Exerpt: I have an application that has several objects (about 50 so far, but growing). There is only one instance of each of these objects in the app and these instances get shared among …
Tags: c++, design patterns
-
Most effective way for float and double comparison
Exerpt: What would be the most efficient way to compare two doubles or two floats (single precision)? Simply doing this is not correct: bool CompareDoubles1 (double A, double B) { retu …
Tags: c++, algorithm, optimization, floating point
-
Good open source Reporting tool/framework for WPF (C#).
Exerpt: I am looking out for a good open source Reporting tool/framework for windows based application (WPF). The database I am using is sql server 2005. The typical reports format whi …
Tags: c#, wpf, reporting, open source
-
Sanitising user input using Python
Exerpt: What's the best way to sanitise user input for a Python-based web app? Is there a single function to remove HTML chars and any other necessary characters combinations to ensure tha …
Tags: python, xss
-
What is the best way to determine application root directory?
Exerpt: I need to get all dlls in my application root directory. What is the best way to do that? string root = Application.StartupPath; or string root = new FileInfo(Assembly.GetExecu …
Tags: c#, files, directory
-
Lightweight source control
Exerpt: I am looking for a lightweight source control system for use on "hobby" projects with only one person (myself) working on the project. Does anyone have any suggestions? Ideally it …
Tags: version control
-
Should an interface that is inherited from base-class be implemented explicitly in subclass?
Exerpt: My question is, if an interface that is implemented implicitly by extending a class that already implements it, should be explicitly implemented by the class, if the class wants to …
Tags: java, interface, contract
-
Creating test data in a database
Exerpt: I'm aware of some of the test data generators out there, but most seem to just fill name and address style databases [feel free to correct me]. We have a large integrated and norm …
Tags: database, integration testing
-
How many C# vs. VB developers are out there?
Exerpt: As a company it's important to choose which .NET language to go with. Many have chosen C# but are there any actual numbers out there to support going with C# over VB.NET? How many …
Tags: .net, c#, vb.net, hiring, statistics
-
What are the best unknown features of Visual Studio .NET 2005?
Exerpt: Visual Studio .NET is an extremely powerful IDE. There are many features of the program that I discover when I actually take the time to poke around or read up on something. What …
Tags: subjective, visualstudio, visualstudio2005, shortcuts
-
Dealing with god objects
Exerpt: I work in a medium sized team and I run into these painfully large class files on a regular basis. My first tendency is to go at them with a knife, but that usually just makes matt …
Tags: best practices, language agnostic, programming, debugging
-
What’s the best Linux backup solution?
Exerpt: We have a four Linux boxes (all running Debian or Ubuntu) on our office network. None of these boxes are especially critical and they're all using RAID. To date, I've therefore b …
Tags: linux, backup
-
Mixing Secure and Non-Secure Content on Web Pages - Is it a good idea?
Exerpt: I'm trying to come up with ways to speed up my secure web site. Because there are a lot of CSS images that need to be loaded, it can slow down the site since secure resources are n …
Tags: web optimization, web development, web
-
Improving Your Build Process
Exerpt: Or, actually establishing a build process when there isn't much of one in place to begin with. Currently, that's pretty much the situation my group faces. We do web-app developme …
Tags: build process, build automation, builds
-
Is tight looping bad?
Exerpt: Is tight looping in a program bad? I have an application that has two threads for a game-physics simulator. An updateGame thread and a render thread. The render thread is throttl …
Tags: java, tight looping, best practices
-
How can I pass command-line arguments to a Perl program?
Exerpt: I'm working on a Perl script. First time in more than a decade. Really. How can I pass command line parameters to it? Example: script.pl "string1" "string2"
Tags: perl, command line
-
VS2008 binary 3x times slower than VS2005?
Exerpt: I've just upgraded a native C++ project from VS2005-SP1 to VS2008-SP1 The first thing I tested was a very basic functionality test of the application and the first thing I noticed …
Tags: c++, performance, visualstudio2008, visualstudio2005, optimization
-
What is the best Delphi n-tier low bandwidth technology?
Exerpt: I need to deploy a Delphi app in an environment that needs centralized data and file storage system (for document imaging) but has multiple branch offices with relatively poor inte …
Tags: delphi, n tier, remobjects, kbmmw, datasnap
-
Why use the Visitor Pattern? [closed]
Exerpt: Duplicate of: When Should I Use The Visitor Design Pattern Why would someone want to use the visitor pattern? I've read a couple of articles, but I'm not getting something. If I …
Tags: design patterns, visitor
-
constant values in Rails
Exerpt: I have some data that I want to store somewhere in my Rails app because I use it for generating form fields, checking a submitted form to ensure its values are valid, etc. Basical …
Tags: ruby, rubyonrails, rails, best practices, constants
-
C# Service cannot execute batch file?
Exerpt: I have a service that call a batch file sometime. The batch file take 5-10 seconds to be executed. The code to launch the batch file is : System.Diagnostics.Process …
Tags: c#2.0, .net, service, c#, windows services
-
Computational complexity of Fibonacci Sequence
Exerpt: I understand Big-O notation, but I don't know how to calculate it for many functions. In particular, I've been trying to figure out the computational complexity of the naive versio …
Tags: fibonacci, complexity, big o
-
Google Maps - Easy way in ASP.Net?
Exerpt: I'm wanting to use google maps and see a million ways to do it on the web. Some are javascript methods and some are asp.net server components with which I have hit and miss luck. W …
Tags: c#, asp.net, google maps
-
Which is faster, Hash lookup or Binary search?
Exerpt: When given a static set of objects (static in the sense that once loaded it seldom if ever changes) into which repeated concurrent lookups are needed with optimal performance, whic …
Tags: algorithm, binary search, hash, lookup