• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Programming Structure.

 
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello world,
I am hoping to write a stock controlling program. In that prorgam I want to to have these functions listed bellow. 1) Bill. (User can specify the quantity and the discount and add that entry to a bill.)
2) Inventory (User can add new items, update the item details and delete item details from the databse.)
3) Supplier (User can add new suppliers, update supplier details and delete supplier details.)
4) User (The administrator can add new users and delete. )
5) Reports (Various reports on the transactions, the items to be reordered etc.)
I am hoping to do the program in 'SWING'. The main window has a menubar and for each function I have mentioned above has seperate Menus. For example there is a 'User' menu which has 'Add User', 'Delete User' as menu items.
As you know,for example when adding a user, details are taken about the user such as the name etc.For this I need a GUI. The problem which I am having is do I need to create seperate classes which creates the GUI for each and every sub function ?.(example: adding a user)
So far what I have thought to have is, a main class for each of the main functions (for example supplier), and use the methods in that class to add, delete etc suppliers, and have different frames to get the GUIs in the main GUI. To make it more clearer this is the program structure what I have in mind.

public class abc {
public static void main(String arg[]) {
JFrame jFrame = new RMain();
}
}
class RMain {

/**
* Declare Components for the main gui.
*/

/**
* Declare Components for the Adding of a new user.
*/

/**
* Declare Components for the Deleting of a user.
*/
public RMain() {
}
}
class Supplier {
public Supplier() {
}
}
class User {
public User() {
}
}
program structure.

So is this structure ok?. or other wise do I have to have different classes for let's say 'AddSupplier' class which has the needed GUI components for adding a new Supplier. (I tried this but, I felt restricted when performing actions.)
Could you please advice me on this with your expertise knowledge.
Please if YOU know any online books for 'Good Programming or How to be a good programmer' please do tell me.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the OO, Patterns, UML, and Refactoring forum...
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've always found the code to build Swing UIs unattractive and unpleasant to work with, so I try to break it into relatively small chunks. I'd have a class per frame, and code in that class to build the contents. I break up methods for parts of the screen, too. If using a border layout I might have a routine that says something like:

Look for UI bits that might be reusable. Maybe address has a half dozen fields for street, care of, city, state, zip, etc. You can make an address panel in its own class and add instances to any number of panels. Then address will always look exactly the same.

Any of those ideas help?
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the Answer. YES you thoughts are helpful
 
What a show! What atmosphere! What fun! What a tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic