Monday, March 7, 2011

Which to choose: 2D or 3D for a java game

What should a small team choose for their first game, when they are low on time but have big ambitions? I'm an experienced programmer, but haven't done any game programming before this. My designer is very talented and artistic, he has worked with 3D about an year ago but hasn't done it since so it could take him some time to learn it again, and i'm not sure if he'll be able to do a good job at it even though his graphic design skills are terrific otherwise.

Our primary concern is to get the game finished as quickly as possible, and also to do it easily since this is my first game programming project. At the same time, we don't want to have any limitations that might hinder our progress later on, or otherwise make the game not fun in certain ways.

For example, i learnt that certain animations aren't possible in 2D such as rotation etc. I would like the ability to have the player's character be able to morph into animals and there must be the ability to shoot at the monsters, (like shooting an arrow and seeing it fly through and hit the other person). Are these things possible in 2D?

In the future, if we wanted to go from 3D to 2D, would it be possible without fully rewriting the game?

From stackoverflow
  • You don't have to use 3D to allow for a "3D look". Things like rotations, motions or transformations can be prerecorded or prerendered as animations or image sequences and seamlessly integrated into a 2D game. The only thing that is not possible in 2D is to navigate freely within your "game space" (like walking or flying freely, turning arbitrarily etc.)

    The main concern, however, when deciding for 2D or 3D should be the gameplay. There are games that absolutely need 3D (shooters, simulations), while others do perfectly without (adventures, puzzles, ...). So you don't actually have to decide but to choose the better fit for your game idea.

    Personally, I'd avoid using 3D in your first game attempt if possible to eliminate all the constraints and hassles that come with it.

    When using 3D you typically have to decide for a 3D framework which will heavily influence your software design, game look and feel and overall performance. Java3D for example brings a complicated class structure that you have to adjust to. And a lot of effort goes into making that 3D stuff work at all. Simple things like rotating a square evolve into matrix operations incorporating quaternions. Every effect has to be done in the complex 3D world, and in such a way that its 2D projected look turns out the way you intended it. Not to mention that 3D applications often suffer a very stereotypical look that is very hard to overcome.

    In 2D, you literally avoid one dimension of complexity. You do everything exactly the way it is supposed to look, you can use standard graphic applications and open file formats to simplify the workflow between the designer and the developer. And a lot of pseudo-3D effects like parallax motion, depth of field and prerendered artwork allow for astonishing looks in a 2D world.

    Click Upvote : Can you eleborate on the constrainsts and hassles that come with using 3D?
    Ross : I couldn't agree more. Since this is Java's first game programming project, the decision to go 2D was already made if you ask me.
    : > Simple things like rotating a square evolve into matrix operations incorporating quaternions In java3d...? You can just set a couple of rotation transforms with whatever angle you like - and I believe there's even a builtin rotation interpolator that will allow you to effectively apply an angular velocity without too much headache. Generally, I've found java3d very easy to get to grips with, and certainly far simpler than using an opengl wrapper directly.
    Vuntic : Although portal 2D is a pretty cool game.
  • Given your requirements, I'd choose 2D . You have more tools to choose from . more available talent to contract for artwork .. and the asset pipeline is simpler. In the end it's going to be all about how good the game is on its own merits. 3D is sometimes more difficult for your average user to figure out.

    Depending on what you are conceptualizing, rotations and morphing oughta be quite possible in 2D. You might even consider a pseudo-3d approach ala Paper Mario ..

    Moving from 2D to 3D should not be a major issue if you design your code structure with that in mind. ..

  • I think writing a 2D or a full 3D game needs a completely different design approach what cannot be modified easily later: SUN provides a Java 2D API and a Java 3D API for the two development decisions. For the first game with tight deadline I would vote for a 2D version. If the gameplay is interesting and the design is nice then the 3D is not a must.

  • You should go 2D. You have stated several reasons to take this approach:

    • You are a small team, and 3D takes more work.
    • It's your first game, so you need to keep it as simple as possible, or the project may fail (you are exposed to a lot of risk!)
    • The 3D artist needs to relearn the crafts!
    • You have a (seemingly self-imposed) deadline.
    • Etc.

    3D takes a lot of time, and it will be best invested in improving the rest of the game. Think of all the awesome games that existed previous to the 3D era.

    Do not fear to accept restrictions: whilst 3D might give you lots of possibilities, 2D may result in more creative work!

  • I would recommend 2D as well. A 3D game will be more graphically demanding on the user's computer, and many things like collision detection are significantly simpler in 2D. You could even make your character models in 3D and then project them down to 2D to make the sprites for the actual game. Puzzle Pirates ( takes this approach and it works very well in terms of consistent lighting, etc.

  • I would considre a couple of factors:

    1. Is it a mobile or applet game? If so, I would go for the 2D version. It's very hard to get 3D right under those circumstances.
    2. What is your designer more comfortable with? Can he more quickly model, texture and animate a characte, rather than creating all the sprites needed for a 2D character?
    3. Tool support. What output formats can your designer produce in both 2D and 3D? What kind of formats is the middle ware, you are going to use, able to handle? Can your 3D engine load, or at least convert, .obj files (just an example, could have used any other model format.)?

    Even if you would like to go the 3D way, you can still make a 2D game (sometimes called 2.5D or pseudo 3D). Also there are some nice third party frameworks out there for both 2D and 3D stuff in Java. You don't have to use java2D/java3D.

Approach for large data/reporting project

What is a good approach for the following:

On a weekly basis, approximately 250,000 records representing transactions will be appended to a large table in an SQL 2005 database. It is required to augment this data and append it to another table. (For example, based on the client ID on the transaction, various data will be computed based on certain business rules; the data is dependent on the client ID and the transaction ID.) Think of this table as preprocessed input for an analytical engine. This input data will then be put through the analytical engine (vendor solution) that will produce yet a third database table. This table will then require further processing (e.g., aggregation by client ID and some in-house analytics) to be appended to a table containing results in a form our team can use for report production. It is likely that in the future the same data will feed other applications, such as a web-based viewer of the data.

Our skill base is C, C++, C#, .NET and a passing familiarity with ADO.NET and LINQ. If this is not sufficient for such a project, please let me know. While our budget for new talent is non-existant right now, we would probably work to enhance our in-house skill base or borrow from another team to meet the project requirements.

From stackoverflow
  • Based off your description this sounds like it should be totally driven through the database, e.g., with T-SQL and SSIS. Loading to tables and pre & post processing (aggregations, subsequent loads, etc.) is where SSIS will shine. Let me know if I missed the intent.

    Dillie-O : I was thinking the same thing. The one thing to note that the scripting language within SSIS is VB.NET. Most of the modules/tools/whatever in SSIS are quite robust, so you shouldn't have to do anything too intense with the scripting.
  • It sounds like ETL project. You want to use SQL Server Integration Service. It is the replacement for DTS in SQL 2000.

  • I'm reading about dimensional modeling, star schemas, and data warehousing these days, so forgive me for seeing a nail after studying hammers. I'd ask if you have a good data modeler on hand. I really like Ralph Kimball's ideas about dimensional modeling. I'll bet that vendor reporting solutions would plug right in. It seems to me that the difference in mission between transactional and reporting schemas calls for different approaches.

    1. Database operations are S... L... O... W...

    2. You put stuff in a database to query it.

    Therefore, your intermediate results are not good candidates for database storage.

    "250,000 records representing transactions .... It is required to augment this data ... based on the client ID on the transaction, various data will be computed based on certain business rules; the data is dependent on the client ID and the transaction ID."

    The first few operations do not lead to data you're going to query. You're simply staging it in the database. That's (1) slow and (2) not very helpful. Just leave it in files to do all of this augmentation processing.

    Put the files in directories that can be backed up as simply as you do your database backups and you'll be fine.

    Since your design seems pretty well fixed, that's about all you can do. However, if your database design is flexible, look at Kimball's Data Warehouse Toolkit, you'll see that when you have fields dependent on Client ID, that really means you have a client dimension.

    Define a table of clients. Use a simple join between fact and dimension to locate the client data.

    This dimensional lookup technique works for all of these "data augmentation" operations. Consequently, there's little actual processing to be done in your "data augmentation".

    Mostly, you figure out how to match the incoming transaction's keys against your defined dimensions. Sometimes the dimension values have changed; sometimes you need to add new dimension values. Consequently, your "augmentation" devolves to checking the dimensions, and appending some keys to each incoming record. Then loading the fact tables with appropriate measures and foreign keys to the dimensions.

Lazy binding functions to multiple events with jQuery

Here's the scenario: I have a set of buttons that I want to bind to corresponding functions when clicked. The ids of these buttons are the same as the names of their corresponding functions. I could do this:


But I'm lazy and would like to do this more lazily (as is my nature). As the buttons are all contained in a block element, I'd like to do something like this:

$("#button_holder > span").each(function () {
    var doThis =;

Except that doesn't work. Any suggestions?

From stackoverflow
  • $("#button_holder > span").each(function () {
        var doThis =;
    robbiebow : I don't think that works; it binds an anonymous function to the event.
  • <input type="submit" id="kick" value="Kick Me">
    <input type="submit" id="push" value="Push Me">
    <script type="text/javascript>
    $(function() {
        $("input[type=submit]").each(function () {
            var doThis =;
    robbiebow : This gives me the same end result, just that the way the elements to bind to are selected has changed, as far as I can see.
  • I guess I don't see the point of this. You need to create each function individually anyway and this sort of programming is difficult for others to grok usually. Maybe if you have dozens of buttons and it's throw-away code, I could understand but .. probably not...

    Why not just bind all to a single function and make the determination based on at event time??

    robbiebow : I find it more readable and more reusable to say "children spans of this div will all have their own functions, and the functions' names will be the same as the spans' ids". It's a matter of aesthetics, IMO.
  • its very simple ! you try to pass none-function to the click method.

    var doThis =;

    you need to pass a function :



    or :

    function myFunc(){};
  • Like the other answerers, I'm not sure that this is "true" laziness (as in the programmer's virtue), but only you know your implementation details.

    If you really want to do something like this, you can use an object to store your particular functions and then use the string to look them up:

    var myFunction = {
         kick:  kick,
         push:  push,
         shove: shove
    $("#button_holder > span").each(function () {
        var doThis =;

    Or as anonymous functions:

    var myFunction = {
         kick:  function() { /*do kick  */ },
         push:  function() { /*do push  */ },
         shove: function() { /*do shove */ }
    $("#button_holder > span").each(function () {
        var doThis =;
    robbiebow : Thanks for the ideas, both of which work for me. I consider this to be proper laziness as it reduces the amount of repetition / work I need to do to add new buttons with associated events, but sure, it's arguable. Thanks again.

lossless video codec playback in Java

I need to encode a sequence of frames with a lossless video codec and play them in a Java app. I don't care about the file size. The output frames should match the input frames exactly. Lossy codecs don't do this even at high bit rates.

None of these well-known lossless video codecs appear to be supported in JMF or FMJ:

  • HuffYUV
  • CorePNG
  • Lagarith
  • FFV1
  • ...

Do you know of any lossless video codec that is supported in Java?

Other options I've considered:

  • animated GIF: is the playback guaranteed to have a constant frame rate like real video codecs?
  • load and display the separate frames: how difficult will it be to do this at a constant frame rate and without dropping too many frames?
  • Proce55ing: the video playback library requires Quicktime, which isn't available on my platform.

EDIT: I finally decided to settle for JMF's (non-standard) MotionJPEG at highest quality. It's not strictly lossless, but still much better quality than MPEG4.

From stackoverflow
  • Well, since you say file-size is not an issue, gzip/bzip2 can be a quick and painless option. It won't give maximum compression, but it can be the last recourse if you fail to find a better answer.

    Gzipped files can be transparently opened using, and similar interfaces are available for Bzip2.

    palm3D : That's basically a variation of the "load and display the separate frames" option. I'm worried it won't be fast enough even without the compression.
    ePharaoh : Why would that option be slower? I can only think of i/o becoming a bottleneck, depending on specifics like resolution of the video. CPU won't be a bottleneck because you are reducing its work by giving it ready to use data. PS. I have implemented a video decoder (MPEG4 FGS) once.
    palm3D : I tried something similar: I can read uncompressed BMP files at a decent rate, but not PNG files because they need some decoding. So the bottleneck seems to be decoding/decompression, not I/O.
  • FMJ does support an experimental method of storing/playing a series of PNG images much the way MJPEG is a series of JPEG images. One is an experimental XML file format which uuencodes the PNGs (fairly bloated), and the other is the x-multipart-mixed-replace HTTP format, which FMJ supports in a file format ending with the extension .mmr

    palm3D : The README says movie playback is not yet implemented on Linux. :-(
    • Animated GIFs: yes, you can define the framerate of animated GIFs (actually you can set a delay for each single frame)

    • displaying frames manually: depends on the hardware, frame rate and size of the images. An HD resolution at 30fps will be difficult without hardware support, thumbnail size shouldn't be a problem on any platform.

    • Another alternative: depending on what you want to do, you could consider to 'remote-control' another player or framework, possibly with some native code. For example, embed an mplayer on *nix/X11, or use COM to control WMP or DirectShow on Windows.

Misunderstanding of Long data type in VBA

From the help for the Overflow Error in VBA, there's the following examples:

Dim x As Long
x = 2000 * 365 ' gives an error

Dim x As Long
x = CLng(2000) * 365 ' fine

I would have thought that, since the Long data type is supposed to be able to hold 32-bit numbers, that the first example would work fine.

I ask this because I have some code like this:

Dim Price as Long
Price = CLng(AnnualCost * Months / 12)

and this throws an Overflow Error when AnnualCost is 5000 and Months is 12.

What am I missing?

From stackoverflow
  • 2000 and 365 are Integer values. In VBA, Integers are 16-bit signed types, when you perform arithmetic on 2 integers the arithmetic is carried out in 16-bits. Since the result of multiplying these two numbers exceeds the value that can be represented with 16 bits you get an exception. The second example works because the first number is first converted to a 32-bit type and the arithmetic is then carried out using 32-bit numbers. In your example, the arithmetic is being performed with 16-bit integers and the result is then being converted to long but at that point it is too late, the overflow has already occurred. The solution is to convert one of the operands in the multiplication to long first:

    Dim Price as Long
    Price = CLng(AnnualCost) * Months / 12
  • The problem is that the multiplication is happening inside the brackets, before the type conversion. That's why you need to convert at least one of the variables to Long first, before multiplying them.

    Presumably you defined the variables as Integer. You might consider using Long instead of Integer, partly because you will have fewer overflow problems, but also because Longs calculate (a little) faster than Integers on 32 bit machines. Longs do take more memory, but in most cases this is not a problem.

  • In VBA, literals are integer by default (as mentioned). If you need to force a larger datatype on them you can recast them as in the example above or just append a type declaration character. (The list is here: The type for Long is "&" so you could just do:

    Price = CLng(AnnualCost * Months / 12&)

    And the 12 would be recast as a long. However it is generally good practice to avoid literals and use constants. In which case you can type the constant in it's declaration.

    Const lngMonths12_c as Long = 12
    Price = CLng(AnnualCost * Months / lngMonths12_c)

How do you get a minimal SDL program to compile and link in visual studio 2008 express?

I'm trying to use SDL in C++ with Visual Studio 2008 Express. The following program compiles but does not link:

#include <SDL.h>

int main(int argc, char *argv[])
    return 0;

The link error is:

LINK : fatal error LNK1561: entry point must be defined

I get this regardless of how or if I link with SDL.lib and SDLmain.lib. Defining main as main() or SDL_main() gives the same error, with or without extern "C".

Edit: I solved this by not including SDL.h in main.cpp - a refactoring I did independent of the problem. A similar solution would be to #undef main right before defining the function.

From stackoverflow
  • The linker can't find the entry point. Which means your main() function is not recognized as the entry point.

    If you have a .def file, remove it.

    Also, if you've set up your project to compile with unicode and not as mbcs, you have to use wmain() instead of main().

  • I don't have VC++ available at the moment, but I have seen this issue several times.

    You need to create a Win32 project as opposed to a console project. A Win32 project expects a WinMain function as a program entry point. SDLmain.lib contains this entry point and the SDL_main.h header file has a macro that remaps your main function to SDL_main. This function is called by the entry point in the SDLmain library.

    The main function must have the following signature:

    int main(int argc, char *argv[])

    It is also required to include SDL.h before the declaration of your main function, and you need to link to both SDL.lib and SDLmain.lib.

    It looks like you are doing this. So, my guess is that you have a console project setup. Therefore, the linker is looking for a main function to call, but it is getting remapped to SDL_main by the macro SDL_main.h. So, the linker can't find an entry point and gives up!

    Johannes Hoff : Yes, changing from to a windows application (through Project Properties / Configuration Properties / Linker / System / SubSystem) works. Thanks. (I ended up with a different solution, though)
  • To me it helped to add the following lines before main():

    #ifdef _WIN32
    #undef main

    German Wikipedia also suggests to add these lines instead:

    #ifdef _WIN32
    #pragma comment(lib, "SDL.lib")
    #pragma comment(lib, "SDLmain.lib")

    Though I still had link errors when I tried second solution.

  • #ifdef _WIN32 #undef main #endif

    Thank you, I have had this problem for days and this is the first solution that has worked. Thank you very much.

What hardware changes will affect WebLogic performance the most?

When requesting hardware for a WebLogic server, what hardware would best improve its performance? Should I give it lots of memory, CPU, fast hard drives? The OS is going to be Redhat 4 either Standard or Enterprise.

From stackoverflow
  • Memory is cheap. Give it as much as you can. 4 gigs is what, $50?

  • That of course depends alot on what type of applications you run on the server. I know that our Weblogic portal eats quite alot of memory (10+ gigs) while other apps make due with alot less.

  • Depends on the applications you deploy on it. It's impossible to answer, given that we know nothing about the apps deployed, the hardware you have, and the myriad settings available on a typical Java EE app server.

    More is always better. Supply the most memory, the biggest hard drives, the fastest multicore processors you can afford.

How to walk the methods and their properties contained in a DLL?

Using preferably JScript, but VBscript will also do, how does one walk a DLL obtaining the properties and their attributes contained therein? Why? Because it would be good to ascertain the attributes of certain objects such as their datatypes at runtime rather than having to hard-code them before hand. An example of their use would be to initialise fields to their default values, e.g., spaces for strings, zeros for binaries and current date for dates.

Cheers, John

From stackoverflow
  • VBSEdit will at least show you methods and properties of DLLs for VBScript when you create an object of that type in a script.

Sharepoint custom personalization

I am creating sharepoint custom solution that will show number of drop down in page. The drop down data is shared in may pages.

I want to persist selected values of the user such that when ever he visit that page or any other page that have same drop down, he should be able to see is saved value pre selected in drop down.

To implement this i have number of options. Please suggest me the best for SharePoint 1)Sharepoint User profiles 2)Sharepoint list 3) Cookie 4) Isolated storage?

3 and 4 option here is client side. But i am looking for any other way that SharePoint provide to save user preferences/personalization information.

Which one is the correct way of doing that in SharePoint? Any Help is appreciated!!


From stackoverflow
  • I would go with profile storage, because that's the sort of thing it's there for, although generally when you are writing custom code in SharePoint the idea of best practices kind of gets thrown out the window.

    noocyte : "ustom code in SharePoint the idea of best practices kind of gets thrown out the window" <-- SO true! :)
  • One issue you should be aware of with user profiles is that they are only available for MOSS (as opposed to WSS). In WSS each site has their own User information list. If the solution you are building will need to run in both MOSS and WSS environments, you should plan accordingly.


  • My instinct tells me to use cookies for this, if it's a fairly simple state you need to persist. This seems to be a part of the UI logic, and I wouldn't bind that to the profile storage.

    Pages and web parts have personalization stores as well, but they are generally not shared between instances.

New C# Programmer - Adding two numericUpDown values together?

Hi there! I'm fairly new to C# programming.

I am making a program for fun that adds two numbers together, than displays the sum in a message box. I have two numericUpDowns and a button on my form. When the button is pushed I want it to display a message box with the answer.

The problem is, I am unsure how to add the twp values from the numericUpDowns together.

So far, I have this in my button event handler:

private void button1_Click(object sender, EventArgs e)
        MessageBox.Show(this.numericUpDown1.Value + this.numericUpDown2.Value);

But obviously, it does not work. It gives me 2 compiler errors: 1. The best overloaded method match for 'System.Windows.Forms.MessageBox.Show(string) has some invalid arguments 2. Argument '1': cannot convert decimal to 'string'


From stackoverflow
  • this.numericUpDown1.Value + this.numericUpDown2.Value is actually evaluating properly to a number, so you're actually very close. The problem is that the MessageBox.Show() function, needs a string as an argument, and you're giving it a number.

    To convert the result to a string, add .ToString() to it. Like:

    private void button1_Click(object sender, EventArgs e)
            MessageBox.Show((this.numericUpDown1.Value + this.numericUpDown2.Value).ToString());

    For reference, if you want to do more advanced formatting, you'd want to use String.Format() instead of ToString(). See this page for more info on how to use String.Format().

  • Try this:

    private void button1_Click(object sender, EventArgs e)
            MessageBox.Show((this.numericUpDown1.Value + this.numericUpDown2.Value).ToString());

    It takes the values from the numericUpDown components and adds them to get an object of the type Decimal. This is then converted to a String, which MessageBox takes.

  • Now that's easy. NumericUpDown.Value has a type of Decimal. Messagebox.Show() expects a String. All you need to do is

    MessageBox.Show((this.numericUpDown1.Value + this.numericUpDown2.Value).ToString());

    to convert the result of the addition to a string.

  • That worked! Thanks everybody!

  • This works.

        decimal total = this.numericUpDown1.Value + this.numericUpDown2.Value;

    MessageBox.Show expects a string as a parameter (that's the first error message).

Project Framework / Management certifications

So there's ITIL, and PMP, and Project+, and etc. etc.

What are your preferences? I heard that PMP and ITIL can perhaps allow you to make more money. Project+ is cheaper. Has anybody actually gotten usage out of any of these certificates?

From stackoverflow
  • ITIL can probably help you to make money, but it's basically to allow suits to chew the wool over each other's eyes with PowerPointSpeak, and to make us programmers very bored and unhappy.

  • I have seen several of these "studies" and polls that try to reason that, upon obtaining a certification, you'll earn more money. What they are actually doing (on most cases) is confusing correlation and causatily.

    The naked truth is that some certifications are more related to better waged jobs. Thus, if you want to make more money, following those polls results, you need to move to more "suity" jobs, and, for such transition, the certifications will only take you so far.

    (Plus, as Brent's comment shows, to some people the certifications are not worth a lot; if you have a junior profile, most companies don't care whether you have a certification; if you're leaning more towards the senior profile, most certifications is mostly a matter of paying, doing some silly tests, and proving you have worked for X years...)

  • The certificate may or may not get you a better paid job, but doing the training WILL give you knowledge enabling you to do a better job with your job!

    I would choose ITIL, but it depends on the nature of the job you want to do..

Security of Tomcat versus WebSphere versus WebLogic

The company I work for sells a J2EE application that runs on Tomcat, WebSphere, or WebLogic. We have a customer that is trying to decide between Tomcat and WebSphere. They're leaning towards WebSphere because they're concerned that Tomcat has more security holes.

After searching around on the web, I've been unable to find any sites or studies that compare the robustness of the major J2EE application servers from a security standpoint.

Can any of you point me to information comparing app server security holes?

From stackoverflow
  • In my experience, WebSphere isn't adding anything that isn't spec (and thus somewhat supported on Tomcat). The problem comes when trying to do some more complex security tricks (admin authentication using SecureID or something) you need to dig much deeper. WebSphere tries to put more of that in the UI Console.

    That being said, your company should look at testing on Glassfish. It uses Tomcat as it's servlet container, but adds a much better UI for management.

  • According to this article, WebSphere community addition is no different than Tomcat 5.5 in terms of the servlet engine. In my opinion, this decision should be based on overall features needed rather than perceived "security holes".

    McDowell : WebSphere Application Server Community Edition is not WebSphere Application Server, it is Apache Geronimo.
  • I can't say whether one is better than the other as I have never used Tomcat, and you really haven't defined what your security requirements are. Security can be a rather large beast and involve varying levels. So you will need well defined requirements to even determine what Security features are required.

    We use Websphere integrated with several other IBM products to provide secure access to our application, which has been working well for us so far. You can look up Webseal and the Tivoli line of products for added security to WebSphere.

  • I'd say use tomcat over WebSphere if at all possible.

    I think 99% of security is how you set it all up.

    Are you also evaluating the security implications of Apache HTTP Server, IBM HTTP Server, and IIS?

    Security involves so much more than just what application server you choose to run your webapp on.

    Tomcat security report

    Websphere security report (You have to dig into each update to see what was fixed)

  • It's interesting that your client is "concerned that Tomcat has more security holes." I wonder if they could list what those holes are? If they can't, it's hearsay and FUD.

    I would say that all web servers/servlet engines suffer from the same issues. It's the applications that are deployed on them that represent the real security holes. Cross-site scripting, SQL injection, lack of input validation, exposure of sensitive data due to poor layering and practices - these are all application issues that will be problems regardless of which app server you choose.

    My personal opinion is that WebLogic is the best Java EE app server on the market. I don't have first-hand experience with WebSphere, but people that I respect who have tell me that it's a horror show. I've only used Tomcat for local development. It's never failed me, but that's hardly production experience. I have no idea how it scales.

    I'd think carefully about Spring's dm Server, based on Tomcat, Spring, and OSGi. I have a feeling that it represents a future direction that all its competitors will be taking.

Allow mobile access to an InfoPath form on a forms server/sharepoint instance

Before I begin asking this question I will have to warn you that I know next to nothing about SharePoint and im basically learning as I go along.

Here's where I am right now:

  • I have a virtual pc with an instance of SharePoint and windows server 2003 running on it
  • I have managed to get a network adaptor set up so I can access the SharePoint instance via a web browser in the host.
  • I have created and published a InfoPath form to the SharePoint instance and I can view the form in a browser from my host machine.

So far everythings great, the only issue is that in order to view the SharePoint Instance or InfoPaths form in the browser I have to firt login as the virtual PCs administrator. Now what I want to do is view the same InfoPath form in a mobile device.

Here's what I have done next:

  • On my host machine I created a Windows CE 3.5 application
  • in which I added a web browser control and pointed it at the hosted InfoPath form on the SharePoint instance.

Now when I run the application in a mobile emulator I get a connection error, though I do not get this error if I point the control to google, or some other site.

I now have the distinct feeling that the reason for this is that as I mentioned to access the form I needed to login using windows authentication. I tried changing the web application in IIS to allow anonymous access and not require windows authentication. While this worked the SharePoint site stated "Not authorized" so now I gather that SharePoint builds on top of windows authentication to control access to its functionality.

So finally, after all that here's my actual questions:

  • How do I grant access in SharePoint to specific bits of functionality for specific windows users?
  • For a mobile device that is not a user on the same network as the SharePoint instance how do I give it access to view the InfoPath form?

I know my questions are a little rambled but one bit issue I have with all this is I am really not sure what to ask, or how to word it. Hopefully someone has grasped what I am trying to do and help out.

To summarize: I basically want to have an emulated mobile device (on the host) access an InfoPath form served by SharePoint/Forms Server on a virtual PC image.

From stackoverflow
  • Use ISA Server and publish your InfoPath Form Services on a public IP. Access it through Internet, it will work automatically with FBA.


  • When you want to change authentication to SharePoint never do so by changing settings in IIS directly but go to Central Administration, Application Management, Authentication Providers. There you can set it up to use basic authentication, Forms Auth or Anonymous access.. whatever works for you.

    Forms Services may have further challenges but this should at least get you a login.

Using Lisp (or AutoLisp) how good is the associative lists performance?

I'm doing an AutoLisp project which uses long associative structures to do heavy geometrical processing - so I'm curious about the associative list intense use timing results. How simple/complex is the implementation? It uses some data structure or a normal list of dotted pairs? The are any extension for b-tree or something?

From stackoverflow
  • In Common Lisp and Emacs Lisp association lists are linked lists, so they have linear search time. Assuming that AutoLisp is the same (and if it isn't, then their use of the term "Associative List" is misleading), you can assume that all operations will be linear in the length of the list. For example, an alist with 100 elements will, on average, need 50 accesses to find the thing that you are after.

    : See my comment for the crashmstr answer below.
  • Of course, most Scheme implementations (or maybe it's in the specs?) have hashtables, which use mostly the same API; but it's not transparent, when you ask for an alist, you get a list of pairs, if you want a hashtable, ask for it.

    that said, it's important to remember that linear algorithms aren't slow; they're 'unscalable'. for a small number of elements, they'll outperform a more complex 'clever' algorithm. just how large 'n' has to be, depends a lot on the algorithm, and fast processors with big caches but slow RAM, keep pushing it. Also, heavy optimising compilers (like those available on some Lisp's) generate very tight linear code.

  • I have not worked with AutoLisp in about 10 years, but I never found any real performance issues with association list manipulation. And I wrote code that would do a fair amount of association list manipulation.

    Working in VBA or ObjectARX might have some performance benefits, but you would probably need to run some comparison testing to see if it is really better.

    : I made a quick test which do three searchs in a 10k elements associative list: 50k random elements from 0 to 100;then from 9900 to 10000; then from 0 to 10000 (all the range). The results was: 0.2173 seconds, 22.0785 seconds and 11.1284 seconds. So, I think its linear.
  • the turning point for SBCL on recent x86 hardware between alists and identity based hashtables, assuming even distribution of access, is around 30-40 elements.

  • There is no extension for b-tree that I know of but if you use Visual LISP you can use ActiveX objects and thus access most types of databases.

Accessing a webserver from a cocoa application.

I am writing a cocoa application in which I want to download a file from a webserver. What will be the most convenient method to go about doing this? Should I go in for NSSockets or a NSUrlRequest? Or is there any other easier way to achieve this?

From stackoverflow
  • The simplest thing to do is probably use NSURLDownload with NSURLRequest.

  • If you want to load the contents of the file into memory, many of the Cocoa data classes such as NSString, NSData and even NSDictionary have initWithURL: methods, which initialize directly with the contents of a web request. They're very easy to use, but they're not very flexible or provide for good error handling. NSURLConnection provides a more flexible way to load data if you need it.

    If you want to download the file directly to disk, then NSURLDownload would be the best bet.

  • A word of warning: The initWithURL: methods are blocking, which is a big problem if the file is large, the server is slow, the user's internet connection is slow, etc. Don't call them from the main thread.

    You also don't get any progress reporting, so when the download is slow, you have no way to tell the user how far along it is or how much longer it will take.

    In almost all cases, you should use NSURLDownload or NSURLConnection instead.

  • And another way is using libcurl, which comes preinstalled on any OS X system. You'd better make sure System Settings like proxies etc. are respected though if you use this approach.

  • NSURLConnection is good if you want to get data from the web service into an NSString or NSData. Make sure you make asynchronous calls and handle errors and data in the NSURLConnection methods

    Here's a good example for REST-style calls

  • NSURLConnection does give you the most granularity, but be careful with NSURLConnection's sendSynchronousRequest() method. It leaks memory each time (have attached the XCode Leak Instrumentation tool and run it to prove it to myself) and gives weird HTTP 204 responses for no reason at all on occasion. I've blogged about this here

Which Python GUI framework?

I am a newbie at Python. I see a few GUIs listed in the Python wiki but I would like to know what you think is the easiest to use. I have 2 requirements

  1. Have buttons, tabs and a textbox
  2. Be able to load an image in memory/from the web (I am using pyCURL to download the temp image(s))
From stackoverflow
  • I believe that wxPython is your best option. The GUI that comes with the Python standard library (Tkinter) is pretty nice, but doesn't support tabs out of the box. There's an extension called Tix which does, but it is a cross-language library which is well documented for Tcl and poorly documented for Python.

    I've been using wxPython recently and have been very impressed. It's easy to use, is extremely well documented for both Python and C++, and supports your requirements.

    Bryan Oakley : It's too bad that Python's Tk support is so far behind the latest iteration of Tk. The standard distribution of Tk has had tabs for quite a while now (since '07) with the new themed widgets. It's a pity Python isn't keeping up.
    Kirill Titov : As far as I know, Tkinter even does not operate with WinAPI, but has its own buttons etc. IMHO, i'ts bad.
    Eli Courtwright : You're correct, although whether that's bad depends on whether having a native look and feel for your app is desired.
  • Well, if we are voting, I would vote for PyGTK. It has the

    • best API,
    • fantastic documentation and tutorials,
    • a number of helper libraries,
    • a thriving community,
    • Glade user interface designing (edit: nosklo)
    • and not too hard for beginners.
    nosklo : and you have glade.

    Qt used with C++ is very nice, but I cannot say what PyQT is like since I never used it.

    Eli Courtwright : I agree that it's nice, unfortunately it's only free to use without buying a license for open source projects. This makes it a non-starter in a lot of corporate environments.
    Deestan : I tried (for research purposes) halfway rewriting one of my company's apps to PyQT. It was a pleasant experience.
  • I already answered here + under Wx you have something called XRC which is very similar to Glade.

  • I use wxPython quite a bit for my GUI needs; the simplest reason for me is that I've found it much easier to distribute wxPython apps than PyQt apps. (Additionally, Traits are better supported under wxPython that Qt, but that is changing.) That being said, XRC and Boa Constructor and Glade (which can also build wxPython GUIs with wxGlade) are all way, way behind Qt designer in sophistication and reliability.

    So, because I was willing to spend a bit of time writing the layout code, etc, and because I had to distribute to several platforms, I went with wxPython. But if you have a more controlled deployment environment and you want to design graphically, PyQt might be a better fit.

  • It would depend on your background as a programmer. If you're used to functional programming, I would go with Tkinter. If you're used to event-based programming, I would use wxPython.

    sli : wxPython lets you register events hooked to form elements, while in Tkinter you register functions as call backs to elements. I suppose the line dividing event-based and functional in this instance is fine, but that's how I feel about it.
  • PyQT. Here is a small tutorial.

    Emrah : It's not free though unless your project is GPL'ed.
    Ranieri : There's always the LGPLd pySide (, but I'm not sure what the current status is like.

Is .NET System.Net.CookieContainer thread safe?

  1. Is the .NET class System.Net.CookieContainer thread safe? --Update: Turnkey answered--
  2. Is there any way to ensure thread safeness to variables which are modified during asynchronous requests (ie. HttpWebRequest.CookieContainer)?
  3. Is there any attribute to highlight thread safe classes? --Update: If thread-safeness is described on MSDN then probably they don't have an attribute for this --
  4. Are all .NET classes thread safe? --Update: Marc answered--

I ask these questions because I use the CookieContainer in asynchronous requests in a multithreaded code. And I can't put an asynchrounous request inside a lock. Maybe I'll have to use readonly "variables" (or immutable types) like in F#, right?

From stackoverflow
  • From the horses mouth:

    Thread Safety

    Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


    You could put a lock around actions that modify the instance members.

  • No, not all .NET classes are thread safe. In fact, very few have a need to be. In general, static members should be thread-safe, but that is about it.

    Immutable / semi-immutable objects are automatically thread safe (this includes things like XslTransform etc) - and there are a mutable few cases (such as threaded containers) where you can expect things to be thread safe. MSDN states thread-safety for each class.

    I would have no expectation for a cookie-container to be thread-safe, so you will probably have to synchronize this yourself.


    Re your second point; exactly which variables are you thinking of? Your own local state variables won't be directly updated during the async request, so it simply falls to you to synchronize access when preparing requests are when processing responses. Most commonly, via a Monitor - i.e.

    lock(syncLock) {
        // prepare request from (synchronized) state

    and then in the callback

    lock(syncLock) {
        // values from request...
        // ...update local state...

    Where syncLock is just a lock object (perhaps held against an instance):

    private readonly object syncLock = new object();
    Jader Dias : I don't know exactly on which point HttpWebRequest.CookieContainer is updated, but I guess it is during the async request.
    Marc Gravell : Well, do you need to make concurrent requests from the same object? Can't you have multiple HttpWebRequest objects with separate cookie-containers? then there is no conflict.
  • All static classes in the .NET framework are guaranteed by Microsoft to be thread safe.

    You can verify this by using Reflector.

  • Just a note, a web page sends a modifed cookie list as part of its HTTP reply. Modifying the CookieContainer after the reply has been send won't accomplish anything-- you'll just modify the cookie collection of a page request that no longer exists.

WPF/C#: Where should I be saving user preferences files?

Whats the recommended location, to save user preference files? Is there a recommmended method(or should I call it pattern) of dealing with user preferences?

Currently I use the path returned from typeof(MyLibrary).Assembly.Location as a default location to store files generated or required by the app.

EDIT: Found two related/interesting questions:

EDIT #2: This is just a note for people like me who had never used settings before. Settings are pretty useful, but I had to do a whole bunch of digging to figure out what was going on (Coming from a python world, not something I am used too). Things got complicated as I wanted to save dictionaries and apparently they cant be serialized. Settings also seem to get stored in 3 different files depending on what you do, There is an app.config, user.config and a settings.setting file. So here are two more links that I found useful:

I am going to try and conduct, a bit of a social experiment. I am going to "award" the answer to any kind soul out there who would merge all these bits of information from the links and the answers of Sailingjudo/Nir/Samuel below into a more "complete" answer. If nothing happens in a week, SailingJudo gets selected by default for putting me on the right track. Or maybe I should just turn this into a community wiki?...still have to find out what that is...stackoverflow n00b here. Stackoverflow rocks btw! Thanks to everyone for their contributions!

From stackoverflow
  • You can use the Application Settings easily enough.

    If you haven't done so before just right click on the project and choose Properties. Select the Settings tab. Make sure you chose "User" for the scope (otherwise the setting is read-only).

    The code to access this is simple:

    forms.Width = Application1.Properties.Settings.Default.Width;

    If you need to save it:

    Application1.Properties.Settings.Default.Width = forms.Width;

    In the sample above, Width is the custom setting name you define in the Settings tab and Application1 is the Namespace of your application.

    Edit: Responding to further questions

    You mentioned you wanted to store Dictionary objects in the Settings. As you discovered, you can't do this directly because Dictionary objects are not serializable. However, you can create your own serializable dictionary pretty easily. Paul Welzer had an excellent example on his blog.

    You have a couple of links which sort of muddy the situation a little. Your original question is where to save "User Preference Files". I'm pretty certain Microsoft's intention with the Settings functionality is exactly that... storing user skin preferences, layout choices, etc. It not meant as a generic repository for an application's data although it could be easily abused that way.

    The data is stored in separate places for a good reason. Some of the settings are Application settings and are read-only. These are settings which the app needs to function but is not specific to a user (for example, URIs to app resources or maybe a tax rate). These are stored in the app.config.

    User settings are stored in an obfuscated directory deep within the User Document/Settings folder. The defaults are stored in app.config (I think, can't recall for certain off the top of my head) but any user changes are stored in their personal folder. This is meant for data that changes from user to user. (By "user" I mean Windows user, not your app's user.)

    Hope this clarified this somewhat for you. The system is actually pretty simple. It might seem a little foreign at first but after a few days of using it you'll never have to think of it again... it just works.

    Klerk : when you say access code is: forms.Width = Application1.Properties.Settings.Default.Width; Does this mean it loads Width that was possibly saved in a previous session?
    Klerk : Btw thanks for the reply. Learnt something new here,
    Samuel : Yes, the little sample he provided will restore the previous width. If you're going to use it (along with height and position), make sure you have some checks to ensure the window is visible. Restoring the position is a bad feature for dual monitor users when they remove the second one.
    Sailing Judo : Yes... this sample was just the first thing that popped into my head. You can store almost anything in the settings, including arrays. I have a rather extreme app that stores a large deserialized List of objects.
  • When running as non-admin or on Vista you can't write to the "Program files" folder (or any sub folder of it).

    The correct location to store user preference is (replace MyCompanyName and MyApplicationName with the correct names, obviously)

    On disk:

    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\MyCompanyName\\MyApplicationName"

    Or in the registry under the key:


    Those location are per-user and they work with non-admin user, several users using the same computer, fast user switching, terminal services and all the other ways people can interact with your software.

    If you need a common location for all users then:

    1. It will only work when the user run as an administrator
    2. It will not work reliably on Vista
    3. You have to take care of everything yourself (like two users running the application on the same computer at the same time via fast user switching).

    and the locations are:

    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationCommonData) + "\\MyCompanyName\\MyApplicationName"

    Or in the registry under the key:

    Klerk : Thanks Nir. Your first alternative sounds like what I am looking for.
    Scott Whitlock : I think your second one should be CommonApplicationData, not ApplicationCommonData.
  • You can use isolated storage. You can isolate by user, assembly and/or domain.

  • I have found this seems to be the case:


    rather than Environment.SpecialFolder.ApplicationCommonData.

  • the following seems to be the best option: