Results 1 to 10 of 10

Thread: More Java GUI queries

  1. #1
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts

    More Java GUI queries

    Well, i've been working flat out with some excellent results but i've been pondering;

    What i've done is put each page of my GUI into a seperate class because there's a lot to deal with in each page, one class for the GUI would simply be too little, i was reaching 500 LOC with one page and needed it to be more dynamic and understandable so i put them into different classes. Is this a good idea? Any other methods of approach used that anyone else has experience with?

    Cheers

  2. #2
    Sam
    Sam is offline
    Registered+
    Join Date
    Oct 2003
    Posts
    22
    Thanks
    0
    Thanked
    0 times in 0 posts
    There's no hard and fast rule of amount of code per class. I have some classes with 3000 lines of code, and some with 10.

  3. #3
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    It's more for increased readability than anything

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Location
    Folsom, CA
    Posts
    221
    Thanks
    0
    Thanked
    0 times in 0 posts
    I would think personally for overall understandability of the project, at the beginning of the class, make some comments, well thought out and descriptive of what this particular class is trying to achieve and where it is used. Something like that. And well written comments on top of the methods would help as well. Generally i prefer not to write too many comments because it gets messy quick. But I dont think there is a hard and fast rule as to when to break things down into separate classes. For my little XML IDE for example I started about with having one fat gui class but then I realized breaking it down would make it more manageable and while it worked for a readability and logical point of view, the programming got a slight bit more complicated.

  5. #5
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    That's what i was hoping to hear I'm on my way now, shame my deadline is a week and a half early. Due in on monday, bit fudged for that as there's some advanced algorithms i'm meant to write for it which i haven't yet :S

  6. #6
    Member
    Join Date
    Mar 2005
    Posts
    88
    Thanks
    0
    Thanked
    0 times in 0 posts
    It's normally best to ensure each class has a limited well-defined responsibility - makes it easier to test and you know where to start hunting bugs. So a GUI class could just take user input for one window, feed it to the application logic class(es) and display the result. Needs a bit more planning than the all-in-wonder GUI but it should scale better.

  7. #7
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    It's just amazing how such a small project can have such a large GUI code wise. But yes, each page on my GUI has a seperate class, and each class has get methods to i can return each button or text field etc. so i can pass it to the action listener in the main UserInterface class

  8. #8
    Senior Member
    Join Date
    Feb 2005
    Location
    Folsom, CA
    Posts
    221
    Thanks
    0
    Thanked
    0 times in 0 posts
    Ahh Kezzer you just solved one of my problems hahaha. Hmm a get method...that is quite interesting...wondering why I didnt think of that. lol

  9. #9
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Get methods are what allow you to do message passing. They're the source of all OO

  10. #10
    Senior Member
    Join Date
    Feb 2005
    Location
    Folsom, CA
    Posts
    221
    Thanks
    0
    Thanked
    0 times in 0 posts
    Yes that is true, but somehow they did not seem that elegant to me previously but now it does actually!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Best book to learn JAVA 2?
    By Taz in forum Software
    Replies: 16
    Last Post: 27-08-2005, 08:54 PM
  2. Java GUI
    By Kezzer in forum Software
    Replies: 4
    Last Post: 04-05-2005, 11:11 PM
  3. Java constructor question
    By suryad in forum Software
    Replies: 9
    Last Post: 03-05-2005, 08:23 AM
  4. Java Linux
    By Raz316 in forum Software
    Replies: 8
    Last Post: 06-04-2005, 09:35 AM
  5. Potential HUGE source of free Java games / apps
    By PriestJPN in forum Smartphones and Tablets
    Replies: 4
    Last Post: 03-11-2004, 01:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •