Jump to content

Wikipedia:Reference desk/Archives/Computing/2009 September 15

From Wikipedia, the free encyclopedia
Computing desk
< September 14 << Aug | September | Oct >> September 16 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


September 15

[edit]

Scalability of two-tier versus three-tier architectures

[edit]

I'd be grateful for insight into the relative merits of a two-tier versus a three-tier architecture, from the point of view of the scalability of an IT application. Why might one approach be superior to the other? Consider, for instance, an Oracle Application Express (two-tier) versus J2EE or .Net three-tier architectures, for an application which might today serve 1,000 concurrent users, but next year 2,000 or 10,000.

I can (at least intuitively) understand the benefits of logical separation of elements of the application, per Multitier architecture, both in terms of modularisation of code and in the ability to provide distinct platforms for each of the tiers. And so I can see that there is some benefit, from the scalability perspective, in being able to ramp up the hardware provided to a distinct layer, based on an understanding of the pinch points in the system. But as a general proposition, can one approach be thought to be better than the other in its ability to scale, measured, I guess, in terms of cost of hardware deployed?

And - whilst we're on the subject - would I be right or wrong in postulating that a three-tier architecture will tend to need more tin than a two-tier architecture, all other things being equal?

I assure you this is not a homework question: I'm struggling to get an insight into what are for me rather abstract concepts, and I have an obscure interest which needs to be satisfied. thanks. --62.49.21.172 (talk) 00:23, 15 September 2009 (UTC)[reply]

It's really going to vary based on the application and the use-case. The real benefits of a three-tiered architecture come more from a project-management and logistics standpoint, rather than a purely hardware/software consideration. By separating the different predicted bottlenecks, it's possible to assign teams to work on independently optimizing those cases. However, the actual bottleneck in a given application is going to depend on the precise interplay of each transaction with each tier of the software architecture. And, it's possible to measure the cost per unit of hardware in each sub-area, which can be evaluated by the budgeting people as a tradeoff against end-user experience and overall system performance. As far as the "most tin", it's again going to be a case-by-case situation; but the system which uses the least number of nodes is also going to be the most tightly-knit, hardest to maintain, and least redundant system. Modularity is useful in these deployed platforms for maintainability, more than performance; in truth, if it were possible, the entire system could be most efficient as a single layer application. (The challenges of scaling then strictly rely on whether a single node can clone all the required data, and whether data hazards result from this). But, the single standalone-node is the penultimate in pure parallelization - every single unit of the deployed system is a miniature, exact replica of the rest of the system. "Scaling" simply means duplicating these units. Upgrading or modifying, however, becomes a near-impossible task, propagating changes dynamically to n independent nodes. Nimur (talk) 02:21, 15 September 2009 (UTC)[reply]

Installing Pygame on Ubuntu Hardy Heron

[edit]

Hi,

I've been given a laptop with a fresh install of Ubuntu (8.04, Hardy Heron) I'm a total linux newbie, but have spent a few days getting a feel for Ubuntu (and liking it a lot, I might add), and wanted to try doing some game dev on it. Python + pygame seems like a good way to go, and the system came with Python 2.5.2 installed. I've been reading through the docs on the pygame site on how to install it, and mostly it seems to come down to doing a "sudo apt-get install python-pygame", but whenever I do that I just get 'package not found'

As I said, I'm very new to the whole Linux thing, so I might be looking in the wrong repositories or something (I don't really know how to change that yet, but I get that you can) I tried using Ubuntu's add/remove software manager, and searching the 'all apps' category, but nothing came up for pygame.

Any help would be appreciated!

--67.171.37.222 (talk) 03:09, 15 September 2009 (UTC)[reply]

You're probably not going to like this answer, but one friend of mine tried getting started with Pygame, struggled for a day, switched to XNA Game Studio with Windows, and was immediately far happier. Tempshill (talk) 04:35, 15 September 2009 (UTC)[reply]
Is this a new install? The package is in fact called python-pygame (at least in 9.04) so the problem probably that you don't have the repository (universe) enabled. Open System/Admin/Software Sources and tick the first 4 checkboxes in the dialog, then press close and then reload. It should find the python-pygame package now. BTW, Synaptics (System/Admin) is a lot better at searching for packages than Add/Remove software. --antilivedT | C | G 06:42, 15 September 2009 (UTC)[reply]
You, sir or madam, as the case may be, are a genius. Thank you! Worked like a charm, and pointed me to a great package manager I wasn't even aware of --67.171.37.222 (talk) 07:05, 15 September 2009 (UTC)[reply]

Escrow for virtual items either items from games or computer code?

[edit]

I have been searching for days and google only turns up garbage. Does anyone know or know how to find escrow systems that would be good for selling virtual items over the internet such as item from games or source code for freelance coding? Normal escrow sites only deal with physical items or domain names and have $25 minimum escrow fees, and then source code escrow sites charge about $1000 minimum fees and are designed for only working with large companies and enslaving them with long-term contracts. Are you ready for IPv6? (talk) 05:18, 15 September 2009 (UTC)[reply]

Converting between SVY21 and WGS84 Coordination system

[edit]

hello. Im on this project currently. To convert between the 2 coordinate system (SVY21 and WGS84) i found quite a bit of information. But just cant figure out how does SVY21 work. Any kind soul can help me with that? your aid will be greatly appreciated. —Preceding unsigned comment added by Razorsaber (talkcontribs) 05:56, 15 September 2009 (UTC)[reply]

SVY21 is a transverse Mercator projection. Our article on the subject may be of help. decltype (talk) 06:03, 15 September 2009 (UTC)[reply]
SVY21 is a geodetic datum (EPSG 6757), a geographic coordinate system (EPSG 4757) and SVY21 / Singapore TM (EPSG 3414) is the projected coordinate system decltype mentioned. The EPSG registry seems to be down at the moment, but here are the well-known text representations for the geographic and projected systems. What is it that you can't figure out? If you'd just like an introduction to coordinate systems, i'd recommend EPSG's Geodetic awareness guidance note.—eric 18:35, 15 September 2009 (UTC)[reply]
Oh, sorry for giving an inaccurate answer. decltype (talk) 19:25, 15 September 2009 (UTC)[reply]

db2 and sql

[edit]

is there any difference between db2 and sql?if its there then please help me.... —Preceding unsigned comment added by Kc28kc (talkcontribs) 10:35, 15 September 2009 (UTC)[reply]

IBM DB2 is a Relational DataBase Management System (DBMS, a software package to handle databases) whereas SQL is a query language (a set of comands for extracting and manipulating data through a DBMS, unless you are talking about the Microsoft SQL Server - which is another DBMS). I know that's not very helpful but I don't know much more --ReluctantPhilosopher (talk) 13:28, 15 September 2009 (UTC)[reply]
"SQL was developed at IBM by Andrew Richardson, Donald C. Messerly and Raymond F. Boyce in the early 1970s" from Structured Query Language. --Jc3s5h (talk) 17:03, 15 September 2009 (UTC)[reply]
Do you mean mysql? Rbmj (talk) 19:07, 15 September 2009 (UTC)[reply]

The history and architecture of the ARM microprocessors

[edit]

I would like learn about the ARM processors, how and when they began, including the architecture of the processor. A lengthy and detailed response will do. —Preceding unsigned comment added by 196.2.2.228 (talk) 15:34, 15 September 2009 (UTC)[reply]

Have you read ARM Holdings and ARM architecture? You can then start on some of thge people mentioned like Furber and Wilson. Dmcq (talk)

History glitch in Internet Explorer 8?

[edit]

I have the problem at home, and apparently it's here at the library too.

I figure this computer must have the new version because the URL is gray except "wikipedia.org" is black.

I use the back button a lot but it seems that history repeats itself. Instead of going back, the back button seems to go forward before going back. I'm pretty sure I'm not clicking on the forward button by mistake.Vchimpanzee · talk · contributions · 17:53, 15 September 2009 (UTC)[reply]

Does this happen with one particular URL, or every URL you have seen? Do you end up, in fact, at the same page you started with, or do you end up one page back in the history? Comet Tuttle (talk) 21:58, 15 September 2009 (UTC)[reply]
It doesn't happen that often. I did get stuck in an endless loop one day with just two pages.Vchimpanzee · talk · contributions · 18:12, 17 September 2009 (UTC)[reply]
I'm in an endless loop right now. And I see the Forward button "flashing". That doesn't happen.
I clicked on "Inbox" in my email. That stopped the loop.Vchimpanzee · talk · contributions · 20:06, 17 September 2009 (UTC)[reply]
It happened again. This time I got an error message because I had deleted the email I was going "back" to. It should have just gone back to where I was before I looked at the email I deleted.Vchimpanzee · talk · contributions · 20:11, 17 September 2009 (UTC)[reply]
I ended up in a loop. I don't know how. It wasn't email. It was Wikipedia.Vchimpanzee · talk · contributions · 18:04, 28 September 2009 (UTC)[reply]

JAVA repaint problem

[edit]

This JAVA program works fine, except that the repaint() method doesn't work. Why is this and how can I fix it?

Massive amount of code collapsed. Tim Song (talk) 19:31, 15 September 2009 (UTC)[reply]
package towerdefense;

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class TowerDefense extends JFrame implements ActionListener {

    public static void main(String[] args) {
        new TowerDefense();
    }
    JFrame game;
    JPanel panel;
    Image dbImage;
    Graphics dbg;
    Timer timer = new Timer(1, this);
    JFileChooser openDialog;
    int boardWidth;
    int boardHeight;
    int tileSize;
    int pathLength;
    int[][] coordinates;
    int[][] directions;
    boolean[][] board;
    int maxHealth = 20;
    int health = maxHealth;
    Enemy enemy;

    public TowerDefense() {
        openDialog = new JFileChooser();
        openDialog.addChoosableFileFilter(new MapFilter());
        try {
            int returnVal = openDialog.showOpenDialog(null);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                String filename = openDialog.getSelectedFile().toString();
                FileReader reader = new FileReader(filename);
                String text = "";
                boolean keepGoing = true;
                while (keepGoing) {
                    int character = reader.read();
                    if (character == -1) {
                        keepGoing = false;
                    } else {
                        text += (char) character;
                    }
                }
                String[] array = text.split("x");
                String[] coordinateArray = array[2].split(";");
                pathLength = coordinateArray.length;
                coordinates = new int[pathLength][2];
                directions = new int[pathLength][2];
                for (int i = 0; i < pathLength; i++) {
                    coordinates[i][0] = Integer.parseInt(coordinateArray[i].split(",")[0]);
                    coordinates[i][1] = Integer.parseInt(coordinateArray[i].split(",")[1]);
                    directions[i][0] = Integer.parseInt(coordinateArray[i].split(",")[2]);
                    directions[i][1] = Integer.parseInt(coordinateArray[i].split(",")[3]);
                }
                boardWidth = Integer.parseInt(array[0]);
                boardHeight = Integer.parseInt(array[1]);
                tileSize = Math.min(getToolkit().getScreenSize().height / boardHeight, (getToolkit().getScreenSize().width - 300) / boardWidth);
                board = new boolean[boardWidth][boardHeight];
                for (int i = 0; i < boardWidth; i++) {
                    for (int j = 0; j < boardHeight; j++) {
                        board[i][j] = false;
                    }
                }
                for (int i = 0; i < pathLength; i++) {
                    board[coordinates[i][0]][coordinates[i][1]] = true;
                }
                enemy = new Enemy(coordinates[0][0], coordinates[0][1], 100, 0, directions, -tileSize / 2, 0, tileSize / 2);
            }
        } catch (Exception e) {
            showErrorMessage(e);
        }
        game = new JFrame("Tower Defense");
        panel = new JPanel();
        game.setPreferredSize(new Dimension(getToolkit().getScreenSize().width, getToolkit().getScreenSize().height));
        game.add(panel);
        game.setExtendedState(MAXIMIZED_BOTH);
        game.setDefaultCloseOperation(EXIT_ON_CLOSE);
        game.setVisible(true);
        game.add(new JCanvas());
        timer.start();
    }

    public void actionPerformed(ActionEvent e) {
        if(enemy.move()) {
            health--;
        }
        repaint();
    }

    public void showErrorMessage(Exception e) {
        JOptionPane.showMessageDialog(null, "An error has occurred.\n\nDescription:\n" + e.toString(), "Error!", JOptionPane.ERROR_MESSAGE);
        System.exit(0);
    }

    class JCanvas extends Canvas {

        public void paint(Graphics g) {
            for (int i = 0; i < boardWidth; i++) {
                for (int j = 0; j < boardHeight; j++) {
                    if (board[i][j]) {
                        g.setColor(Color.orange);
                    } else {
                        g.setColor(Color.black);
                    }
                    g.fillRect(i * tileSize, j * tileSize, tileSize, tileSize);
                }
            }
            g.setColor(Color.blue);
            if (enemy.isAlive) {
                g.fillOval(enemy.x * tileSize + enemy.xOffset + tileSize / 2, enemy.y * tileSize + enemy.yOffset + tileSize / 2, tileSize / 4, tileSize / 4);
            }
            g.setColor(Color.black);
            g.setFont(new Font("Courier", Font.BOLD, 50));
            g.drawString("HP", getToolkit().getScreenSize().width - 300, 50);
            if (health > maxHealth / 2) {
                g.setColor(Color.green);
            } else if (health > maxHealth / 4) {
                g.setColor(Color.yellow);
            } else {
                g.setColor(Color.red);
            }
            g.fillRect(getToolkit().getScreenSize().width - 240, 0, health * 240 / maxHealth, 50);
            if (health > maxHealth / 2) {
                g.setColor(Color.magenta);
            } else if (health > maxHealth / 4) {
                g.setColor(Color.blue);
            } else {
                g.setColor(Color.cyan);
            }
            g.setFont(new Font("Helvetica", Font.PLAIN, 25));
            g.drawString(health + "/" + maxHealth, getToolkit().getScreenSize().width - 240, 50);
        }
    }
}

--204.184.214.2 (talk) 19:01, 15 September 2009 (UTC)[reply]

While you're waiting, you might like to take a peek at Wikipedia:Reference desk/How to ask a software question. --Sean 20:34, 15 September 2009 (UTC)[reply]
Absolutely - I agree with Sean's comment above. Fortunately, I managed to track down your bug (I think). First of all, you extend JFrame, but you also initialize a new JFrame, "game". Instead, your class should call the super() method, and you do not need a "game" instance variable. (See how to use super() to extend classes). Also, you add your JCanvas to the JFrame; but (surprisingly) this is not correct. In Java Swing, (unlike AWT), always add to contentpanes - not to JFrames. (See why). Read about Swing top-level containers here - in your code, you want to add to the JFrame "game" (or the JPanel "panel")'s content pane. I've also boiled down some code for you to see how to do this properly. Nimur (talk) 23:34, 15 September 2009 (UTC)[reply]
Nimur's example of "proper" JFrame and ContentPane usage.
package test;
 
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics;

import javax.swing.JFrame;
 
public class TowerDefense extends JFrame {
 public static void main(String[] args) {
    new TowerDefense();
    }
  
 public TowerDefense() {
    super("Window Title");
    this.setSize(640,480);
    Container c = this.getContentPane();
    c.add(new JCanvas());
       
    this.repaint();
    this.setVisible(true);
    }
 
class JCanvas extends Canvas {
  public void paint(Graphics g) {
    g.setColor(Color.BLACK);
    g.drawRect(50,50,50,50);
    }
  }
}

.

Hopefully you will understand this simple code, and see the changes you need to make to your own class. Primarily, you want to use the Container object, obtained by the getContentPane() method of the JFrame (or JPanel) that you plan to hold the drawable Canvas area. Watch out; you're secondary issue is that you're mixing up a JFrame instance called "game" with a TowerDefense object ("this"), which is also a JFrame. Nimur (talk) 23:33, 15 September 2009 (UTC)[reply]

(ec)If i remember correctly (and that pretty iffy for Java) JFrame.repaint() does not actually repaint its contents. You do something like frame.getContentPane().repaint() or declare a member variable for your canvas object and use canvas.repaint().—eric 23:36, 15 September 2009 (UTC)[reply]
The above depends on whether the JFrame's child(ren) are lightweight or heavyweight objects. There's more details here: Mixing Heavy and Light Components. Repaint() on the JFrame should cascade to the OP's JFrame content pane and its child JCanvas object, in this case - if the JCanvas resides on the Content Pane (but if the JCanvas resides on the JFrame, all bets are off). Nimur (talk) 23:41, 15 September 2009 (UTC)[reply]

Here's my code after making the changes you suggested (with all the irrelevant parts removed). It still doesn't work. What else should I change? --204.184.214.2 (talk) 18:35, 17 September 2009 (UTC) [reply]

package towerdefense;

import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class TowerDefense extends JFrame implements ActionListener {

    public static void main(String[] args) {
        new TowerDefense();
    }
    Timer timer = new Timer(1, this);
    JFileChooser openDialog;
    int boardWidth;
    int boardHeight;
    int tileSize;
    int pathLength;
    int[][] coordinates;
    int[][] directions;
    boolean[][] board;
    int maxHealth = 20;
    int health = maxHealth;
    Enemy enemy;

    public TowerDefense() {
        super("Tower Defense");
        //Store the map as an array
        this.setPreferredSize(new Dimension(getToolkit().getScreenSize().width, getToolkit().getScreenSize().height));
        this.setExtendedState(MAXIMIZED_BOTH);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.getContentPane().add(new JCanvas());
        this.setVisible(true);
        timer.start();
    }

    public void actionPerformed(ActionEvent e) {
        if (health > 0) {
            if (enemy.move()) {
                health--;
            }
        }
        repaint();
    }

    public void showErrorMessage(Exception e) {
        //Display an error message
    }

    class JCanvas extends Canvas {

        public void paint(Graphics g) {
            //Draw stuff
        }
    }
}

--204.184.214.2 (talk) 18:36, 17 September 2009 (UTC)[reply]

Did you follow Sean's and Nimur's advice, and read this? --NorwegianBlue talk 20:53, 17 September 2009 (UTC)[reply]
You only call your repaint() method when actionPerformed() is called. Is this what you wanted? (Do you understand how Swing ActionListeners work? This is the official Java Book on Swing Action Events, available free online). Notice how in my example code, I called this.repaint() in the constructor. You aren't ever actuating the repaint() function! You either need to fire some ActionEvents, or set up a thread to schedule repaint() calls, or some other method to ensure you are actually calling your painting code. I'm not sure what your various game object classes implement, but I think you intend those objects to fire ActionEvents. This is potentially functional; it might or might not be good architecture depending on your game application's needs (ActionEvents are supposed to be fired when buttons are clicked, e.g. - but if you want, you can fire them when the game state changes, too). However, my guess is that your objects are never actually sending action events to the event listener. You might seriously consider a separate thread scheduling repaint(), independent of any UI events, to guarantee that the paint code is called (even if no game events have occurred). This will ensure that there's always a fresh version being painted on-screen. Nimur (talk) 21:37, 17 September 2009 (UTC)[reply]

Websites That Will Translate Letters -- Not Just Text From The Internet

[edit]

Hello,

I've recently come across a few letters in a family archive that are in Dutch, Polish and Italian. Are there any places I can post scans of these to have them translated?

Thanks in advance for any help,

--Grey1618 (talk) 22:58, 15 September 2009 (UTC)[reply]

If they're not too long, you might find people on the Language Reference Desk who will do it. Otherwise, you'll probably have to type in the text. --Sean 00:11, 16 September 2009 (UTC)[reply]
You mean places where you can hire human translators? Yes, a web search should find tons of them instantly. You could also try something like craigslist to find someplace local. There is no Babelfish for handwritten texts, and anyway if these are family letters that might contain private info, you are better off hiring someone under terms of confidentiality, than posting scans on the internet to be spread all over. 67.122.211.205 (talk) 07:53, 16 September 2009 (UTC)[reply]