Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

Dictionary Builder Application

Thread view: 
j1mb0jay - 27 Jan 2008 19:15 GMT
I have created a program to build a dictionary file. This program uses a
  simple socket connection to a news server and stores each word in a
article found in every group. These words are stored in a hash table to
help make the insert time of each word as small as possible. The
popularity of each word is also stored and the list is sorted before
saving to a text file. Please if you have time can you download the
source code and let me know what you think of it.

http://users.aber.ac.uk/jap6/filedetails.php?id=wordlistbuilder&type=zip

Regards j1mb0jay
Christian - 27 Jan 2008 23:35 GMT
j1mb0jay schrieb:
> I have created a program to build a dictionary file. This program uses a
>   simple socket connection to a news server and stores each word in a
[quoted text clipped - 7 lines]
>
> Regards j1mb0jay

I am sorry to say it but I think your application is horrible.

several things:

- try using lower case letters for method names (have a look at Java
coding conventions)
- Don't implement your own HashTable use Java's  HashMap
- Don't implement your own LinkedList  .. use some list implementation
Java already has
- There is really no need for you to store the hashcode of a string..
(Word.java)
- I would recommend against reusing the  name of java api classes.
Especially don't reuse popular names like "Socket" or if you even use
Socket in your own Socket class.

- code looks cleaner if you use import statements consequently

About your IO
Its better to throw exceptions to a level that can handle it
If an IOException occurs for example when writing your word list. The
exception will be printed out.. still the hashtable will keep writing to
 your FileWriter  as it doesn't know that an exception occured.

Also don't simply catch Exception .. be a bit more specific .. just
catch IOException ..

I recommend you to practice coding. May be start reading some example
code on Java's learning trails. Try to adapt the coding style you can
see there.

Christian
j1mb0jay - 28 Jan 2008 01:07 GMT
> j1mb0jay schrieb:
>> I have created a program to build a dictionary file. This program uses
[quoted text clipped - 15 lines]
> - try using lower case letters for method names (have a look at Java
> coding conventions)
I will take this into consideration (have been used to writting C#
before this point).

> - Don't implement your own HashTable use Java's  HashMap
> - Don't implement your own LinkedList  .. use some list implementation
> Java already has
I have to implement my own version of these data structures as this is
coursework and i require an understanding of how these work and i feel
this is a good way of doing this.

> - There is really no need for you to store the hashcode of a string..
> (Word.java)
I understand where you are coming from, and will remove this propriety
from the word class. I just thought it would be faster if i stored it
rather than calculating it each time (but this thought is wrong as i
would just look at the index into the array - as this is the hashCode)

> - I would recommend against reusing the  name of java api classes.
> Especially don't reuse popular names like "Socket" or if you even use
> Socket in your own Socket class.
>
> - code looks cleaner if you use import statements consequently

I will start working on renaming the class names.

> About your IO
> Its better to throw exceptions to a level that can handle it
[quoted text clipped - 4 lines]
> Also don't simply catch Exception .. be a bit more specific .. just
> catch IOException ..

Throwing exceptions is something i will start working on the final
version of the application. At the moment I just wanted to test to make
sure it worked.

> I recommend you to practice coding. May be start reading some example
> code on Java's learning trails. Try to adapt the coding style you can
> see there.

I have read an understand some of the Java coding practices. Like i said
i am used to writing C#.

> Christian

Thanks for your time. Hope the code didn't make you cringe to much
...!!! Have not been writing Java for to long.

Regards James


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.