Archive for the ‘Tutorials’ Category

05.9
07

Terry Pearson’s 7 Steps To Bittorrent Success

by Terry Pearson ·

Bittorrent (pronounced and sometimes spelled “Bit Torrent”) has the potential to completely change the way files are served on the internet. Bittorrent was created by genius programmer Bram Cohan. It allows large files, like open source software distributions, to be downloaded quickly from several “grassroots” file sharers.

JXTA Java P2P ProgrammingThis technology is closely related to Peer to Peer file sharing. Bittorrent differs from some file sharing programs in that it breaks up the files into several bite size pieces and allows users to partially download files from several sources.

One major problem with sharing large files over the internet is that many broadband web hosting companies significantly limit your upload speeds. This means that you may be able to download a file at 8mbps but only upload the file to your friend at 0.8mbps. Thats like saying you don’t have a speed limit, but the guy in front of you does (in the no passing zone of course).

This bottleneck is solved by allowing a downloader to solicit pieces of a file from several people who also have pieces of the file. Eventually the goal is to have the whole file, but in the mean time, it significantly increases your ability to download. You can now download from ten people who each upload at 0.8mbps. If you multiply that out, you are now maxing out your download speed. Not bad at all.

Bittorrent can be a little confusing, and may not be for the ungeeky at heart. But with a little background, it becomes much easier. So without further ado, I will give you Terry Pearson’s 7 steps to bittorrent success.

  1. Download a Bittorent Client. Bittorent downloads require a special software. Don’t worry, the best of these are free. I recommend Azureus. It is free of spyware, and very reliable.
  2. Install the client. This is pretty straight forward. You will need the latest version of the Java Runtime Environment which is provided at the link to Azureus found in number one.
  3. Determine a file that you want to download. For starters, go to http://distribution.openoffice.org/p2p/. You will answer three questions about your operating system and language. After answering those questions, you will begin to download the “.torrent” file. More than likely you will want to choose to “open” rather than save the file. By the way, this is for OpenOffice, an office suite similar to Microsoft Office, but with more features. Sun Microsystems, used to charge for it (under the name StarOffice) but now gives it away in hopes that people buy support packages for the software.
  4. Agree to Import Your Torrent. If you are using Azureus, this will be done automatically. It will pop up a temporary message in the bottom of your screen.
  5. Wait patiently, and do not shut down your client. Remember that your file is huge. More than likely, it will take a little time, but you will hopefully have a much better download than you would get from a file transfer from one computer. By the way, Bittorent is designed to help those who help others. If you disable sharing your pieces of the file, you are known as a leach. Leaches are often blocked, so you will actually download slower than otherwise expected.
  6. Explore your new software. If you are using Azureus, click on “My Library” and go to the “Advanced” tab. You will see a much more “Windows-ish” looking interface. The table will give the file size and status among other things. Some terms that you will come across include Peers, Seeds, and Trackers.
    • Peers - These are computers that you are currently either connected to, or attempting to connect to. Sometimes, Bittorent programs set a maximum number of connections. Therefore, you may have to wait in line for a part of a file.
    • Seeds – These are computers that contain the entire file. It is not mandatory that a torrent have a seed, but torrents with seeds are more likely to be completed since at least one member of your torrent has the complete file.
    • Tracker – This is a server that coordinates how the files will be downloaded. It keeps a record of which computers have certain pieces of the file, and then gets the file pieces to the right places in the most efficient manner.
  7. Practice good Bittorent Etiquette. In order to allow others to get completed files, at least one person needs to be sharing each part of the file. Remember that someone shared with you, so please share with them. This could involve keeping the files shared in your Bittorent client as long as possible. The upload rate will usually be slow, so don’t worry about it bogging down your bandwidth. Remember, you can download a lot faster than you can upload.
04.4
07

Test your Java Skills

by Terry Pearson ·

I am currently in a Java class at my university. This is a language that I think is just wonderful. Java (and  .NET languages) truly utilizes Object Orientated Concepts to the fullest.

When you are learning a language, it is sometimes difficult to test your skills. You certainly think you know a lot about the language, but how do you know that you are an expert? Possibly the best way, besides certification, is to take online tests on the language of your choice.

A great place to look for these online tests is on text book publisher websites. For example, my textbook entitled “Introduction to Java Programming” by Daniel Liang, has a website with source code and tests available to all. This tool makes it very easy to assess your current skill set, and helps identify areas in which you need to improve.

04.2
07

Things to Know Before You Graduate – For Computer Science Majors

by Terry Pearson ·

As a computer science major, there are many things you should know before you graduate. To land a job, it is important that you have a broad base of knowledge when it comes to computer science. Below, I have compiled a list of some key things to know before you graduate.

By the way, these are mainly from questions that were asked during my interview with Avanade last week.

  • SQL Transaction
    • The combination of several SQL statements into one atomic group. It allows for an all or nothing approach.
  • SQL User Defined Functions
    • Functions that are run on the SQL server that are created by the user of the DBMS.
  • SQL View
    • A view appears like any database table, and can be operated on just like any table, but is actually a portion of a database table.
    • CREATE VIEW myview AS
    • SELECT name, age
    • FROM students
    • WHERE age = 5
  • Definition of Inner Join
    • A join of two tables that returns records for which there is a matching value in the field on which the tables are joined.
  • Definition of Outer Join
    • A table join in which rows from one table are included in the result set, even if they don’t contain values that match those in the other table.
  • Normalization
    • Decreases the amount of data
    • Decreases the load on the server and can increase performance
    • Going beyond 1NF can introduce logic errors when inserting/updating/deleting records
  • Acid Properties
    • In databases, ACID stands for Atomicity, Consistency, Isolation, and Durability. They are considered to be the key transaction processing features of a database management system, or DBMS. Without them, the integrity of the database cannot be guaranteed.
  • Linked Lists vs. Arrays
    • Duh! Just think inserts, deletes, and sorting and the complexity involved in these transactions
  • Interface
    • An interface is a description of a set of methods that conforming implementing classes must have.
    • Only non static methods and static final variables can be defined in the interface.
  • Abstract Classes
    • A class in which some of the functions are not implemented.
  • Characteristics of Object Orientated Programming
    • Inheritance
    • Encapsulation
    • Abstraction
    • Polymorphism
  • Access Modifiers
    • Public – Visible to all classes
    • Protected – Visible to the class they belong to and to any sub-classes
    • Private – Visible to the class they belong to
  • Software Development Methodologies
    • In the traditional waterfall methodology, first comes the analysis phase, then the design phase, followed by the implementation phase, with testing completing the process. The team that does each phase is different and there may be a management decision point at each phase transition. This methodology is called the waterfall methodology because each phase flows naturally into the next phase like water over a series of falls.
    • The spiral methodology fixes some of the problems introduced by the waterfall methodology. The spiral methodology still has the four phases. A little time is initially spent in each phase followed by several iterations over all four phases.
  • Sorting Algorithms
    • Bubble Sort
      • The array of values to be sorted is divided into two partitions: the partition of sorted values and that of unsorted values.
      • In each step of bubble sort, the smallest element found so far in the unsorted partition moves up, and it is appended to the end of the sorted partition.
      • The sorting proceeds until the elements in the unsorted partition are exhausted.
    • Selection Sort
      • The selection sort works by selecting the smallest unsorted item remaining in the list, and then swapping it with the item in the next position to be filled. The selection sort has a complexity of O(n2).
      • You have a Floor variable (which identifies the index of your first unsorted position in your array, and you have a minimum index variable that will point to whichever position is lowest so far. Once the remaining portion of the array is looked at, the floor variable and the minimum index variable are swapped.
01.28
07

Display a Double with two decimal places in Java

by Terry Pearson ·

I just spent the longest time trying to find the easiest way to make a double display two decimal places in Java.

Basically, I wanted to output money information, and it would look better if the money data says “$5.00″ instead of “$5.0″ as is sometimes the case. There are so many “solutions” to this, that it is difficult to wade through them all.
The best solution I encountered was relatively easy. You can find it in Sun’s Java forums.

import java.text.DecimalFormat;

double d = 8.9909879;

DecimalFormat dFormat = new DecimalFormat(0.00″);

String formattedString = dFormat.format(d));

The above code will format a string that has two decimal point precision. It will give the number 8.99 instead of 8.9909879.