GeeCON Prague 2014*
The moose likes Java in General and the fly likes Can anyone please review my design? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Can anyone please review my design?" Watch "Can anyone please review my design?" New topic
Author

Can anyone please review my design?

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi all, I am preparing for toefl and thought why not write an application which asks me a random meaning for a word from a dictionary. Then I started coding this application. I have written this and its also working fine. I would like programmers here to comment on my design and code. So that I can learn and become better.

Dictionary is nothing but a properties file. I will enter the key value pair in the properties file myself. My program will load all words and corresponding meanings from the properties file at initialization itself. Then my application will pick a random word and its corresponding meaning(s). There is a UI from which the user will input the answers and then the program will check and alert the user whether the answer is right or not.

Later I am going to add soundex functionality also, suppose in case a user enters a misspelled word.

I can also attach the code to this post. But I am not sure whether I can attach or not according to the policies and standards of coderanch.



[Thumbnail for vocabulary_class.png]



Love all, trust a few, do wrong to none.
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Quite a difficult task IMHO.

How will you know the user gives the correct definition?
An exact String comparison which would have to match your property value?

As for your Class diagram, not sure what it's telling me.

WP
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4474
    
    6

Why go to all the trouble of implementing your own dictionary? Why not build on something that's already there? If you're just studying for the TOEFL, all you really need is a way to get definitions of words, right? I would start with finding a Word of The Day site, then maybe find an API to get word definitions, like http://developer.wordnik.com/

Here's what my first-cut design might look like:

Maintenance:
1. Grab a word from word-of-the-day site.
2. Add it to my list of study words.

Drill:
1. Randomly pick out a word from the list of study words - present this as the "test" word
2. Call the API to get the word definition
3. Randomly pick out 3 or 4 other words from list of study words and get their definitions
4. Present the definitions for the user to choose the right one
5. User enters answer
6. Tell user if they are right or wrong

Even though this might turn into a fun little side project, that's way too much programming for me if all I really wanted to do was study for the TOEFL. I'm just lazy, I guess.


Junilu - [How to Ask Questions] [How to Answer Questions]
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Junilu Lacar wrote:Why go to all the trouble of implementing your own dictionary? Why not build on something that's already there? If you're just studying for the TOEFL, all you really need is a way to get definitions of words, right? I would start with finding a Word of The Day site, then maybe find an API to get word definitions, like http://developer.wordnik.com/
Hi Mr. Junilu, the idea behind my own dictionary is, I am reading Cambridge preparation for TOEFl textbook. So I am noting all the words I hit in the book in my mobile. Now instead, I wrote my own small java program to ask me a random question from the properties file at scheduled intervals. So that I can be in track with my preparation while at office also.

Moreover my application asks me to enter the meaning instead of a word instead of selecting from a list. can do this using the web services also. Again I would want to store the word and corresponding meaning(for future use) if I am using a web service. So at the end of the day again I will have a dictionary.

My intention is to save a word when I hit it while reading something and let my program ask me the meaning of the word sometime in the future. Instead of pinging a web service and getting a word I don't know and dint even heard. Basically I am poor at vocabulary.

Or instead of doing all this java stuff, I can simply go to www.freerice.com and learn vocabulary. I can save more time. I want to combine my learning with java.

For example I used to use the word "Best" to praise something. I don't know about the word "Elite" before I read some passages. So if I ping a service and get a word which I don't even know, it is of no use to me.

This is how I learn.

Can I attach my code to this post so that you or someone can review it and suggest me regarding some best coding practices.

Thank you, good day
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

William P O'Sullivan wrote:Quite a difficult task IMHO.

How will you know the user gives the correct definition?
An exact String comparison which would have to match your property value?

As for your Class diagram, not sure what it's telling me.

WP

To match the word even if the spelling mismatch I will use soundex algorithm. Of course I need not implement this functionality because there should not be spelling mistakes. If the user enter a misspelled word he will become aware if my application says it is wrong. One can learn better.

I may or may not add the soundex functionality.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4474
    
    6

Chaitanya, you are welcome to post short snippets of code for discussion about specific questions or doubts you may have. Posting 100+ lines of code is less useful because few people will take the time to read through that much code. Posting code as an attachment is the least useful for you because hardly anyone, if any at all, will take the time to open up the attachment and go through potentially hundreds of lines of code.

If you post small snippets of code, please use the code tags (click on the Code button in the editor) to make the code more readable and preserve indentation and spacing.

Thanks
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Junilu Lacar wrote:Chaitanya, you are welcome to post short snippets of code for discussion about specific questions or doubts you may have. Posting 100+ lines of code is less useful because few people will take the time to read through that much code. Posting code as an attachment is the least useful for you because hardly anyone, if any at all, will take the time to open up the attachment and go through potentially hundreds of lines of code.

If you post small snippets of code, please use the code tags (click on the Code button in the editor) to make the code more readable and preserve indentation and spacing.

Thanks
Thank you Mr. Junilu, I will post some sample code snippets. I will just list the snippets where I want you people to focus and will update this thread ASAP. However I found that the present architecture is tightly coupled. In my next reply I will post the previous code snippets and new design.

Thank you.
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Hi all, this is how I designed my application.

1. There is a main class called EntryPoint.
2. First initializes the Dictionary. The DictionaryImpl needs a properties file.
3. Next it will initialize the Validator. The ValidatorImpl has methods defined to check the inputted answer with the exact answer.
4. Initializes the UI and supplies dictionary and validator to the UI.
5. The UI class takes over from this point.
6. UI will call a populate() method which randomly selects a word from the dictionary. When the user inputs a value and hits check button the, it calls the Validator's validateInput() method.


This is how it works. Below are the code snippets of some crucial elements. I would like experts here to comment on my code.DictionaryImpl.javaUI.javaComments are appreciated. Thank you all in advance. Good day.
 
GeeCON Prague 2014
 
subject: Can anyone please review my design?