Program Structure

Hi, best to give you current structure, then what i am after.
Program - Classes- Main (Swing held here), static dbconn, Member, Membership.
What i would like to know, if i click on a button in the Main class to retrieve info from the database and return it to the Main class, where is the best place to hold my query and the retrieval of information? The info returned is a from two tables - member and membership.
I would like to program correctly and this is something i don't really know. Currently i am holding it in the Main class but for some reason it seems like it's defeating the object of OO.

Perhaps you could be clearer about your design. I assume you have:
class Member, which encapsulates information about one member.
class Membership, which encapsulates information about one instance of membership.
Is there a relationship between them?
I'm guessing these are business objects. As such, they should contain no mention of database stuff (no java.sql) and no mention of GUI stuff (no java.swing).
You should be able to write unit testing code that tests these objects in isolation -- without involving the GUI or the database.
Now you should be able interact with the database -- select lists of Member and Membership objects for example. This code should not mention the GUI. You should be able to test it without involving the GUI.
How does that sound?

Similar Messages

  • What Program Structure to use?

    Dear All Expert,
                 I am looking for a suggestion on which program structure or combination of strutures that I can use for my programming of the following:
    1) My program had a few events triggering object. Start button click, Stop button click, Grid 1 to 4 button click, Serial received buffer true.
    2) With all these event cases, I had a sequence that can be programmed using State Machine. However, some of the state to state transistion had to be triggered by the event cases.
    3) When stop button is pressed, everything must stop and program to exit
                I had little experience with LabView. If possible, can link to some tutorial that is applicable or some example for me to continue with. Thanks a lot 

    Hi,
    JKI developped a tool for installing addons for Labview, and one of them is the JKI state Machine (free).
    You need to install VI package manager (http://jki.net/vipm), and then instal the JKI state machine (http://jki.net/state-machine)
    You will have then in your palette a new feature : JKI state machine.
    Best Regards, 
    V-F

  • Program structure in LV

    Hi,all
    I am a novice for LV. I hope LV's experts give me a exemplification about the program structure in the same VI to accomplish the different events,e.g. PXI5411 generates wave and PXI4472 samples different sensor signal. I programmed the structure with two parallel while loop structure. I try the different events to a WHILE LOOP,but the some ERROR notify about data size! I thought the parallel structure is unreasonable,but there is no better idea for this problem. Would you help me?
    Thanks,
    Regard
    XU

    LIONCSU,
    I'm glad to hear that my advice helped! You may want to post you response to the issue regarding the 5411 on it's respective thread so that I will receive notification that there has been activity. I wasn't aware that the other issue had not been resolved. I would be more than happy to provide more help after your specific follow-up question has been posted.
    You can get this level of support from any of the Application Engineers here at NI. I currently support the products you have been using and answer discussion forum post from time to time. If you happen to post more questions they will be reviewed and if not sufficiently answered by customers a post will be made by one of the other Engineers that I mentioned. Please let us know if there is anything else that we can help you with.
    Regards,
    Shea C
    Applications Engineering
    NI

  • Question about program structure.

    hi, I am trying to write a GUI program like MSN messenger. right now, I am really confused about my program structure.
    Should I put all the things in one class or separate them into GUI class, services class..etc? for example, right now, I have a class responsible for connecting to the server. Should I put it into the GUI class as a nested class or .......? Basically, what is the best structure for GUI program?

    new_java-sun wrote:
    thank you very much. Do you know why the mvc pattern is called mvc pattern instead of DGC(data-gui-controller) pattern?Because a view need not be a GUI, or even a UI, and a model need not be data

  • Help with program structure - simple question.

    Hi. I need a piece of advice on how to create the correct structure for my program. It consist on two main processes:
    1)Detecting time difference between 2 rising edges, and showing the data. I used the concept of another user "panoramarts" that you can see here:
    http://forums.ni.com/t5/Digital-I-O/Measuring-Time​-between-two-Digital-Signals/m-p/2091868#M16230
    (If anyone knows a better way to do it I will really appreciate it)
    2) A continuous process.
    I attached a picture of the structure I am using. The numbers I will refer to, are indicated there.
    The program basically starts counting the time until a rising edge is detected (number 2 in the picture). After that the next sequence is executed (number 3 in the picture) counting the time again until the next edge is detected. After that the subtraction is made to have the time difference and then displayed (number 4 in the picture).
    Here is the problem: I have a continuous process that must be executed, so if I place it in "Number 1" then the edge detection must be running otherwise i do not see the continuous process (is like Labview execute de FLAT sequence, and after that the continuous process). If a place the continuous process in another While loop, then is like sometimes I get inaccurate data from the edge detection.
    How can I solve that? Is there another way to acquire time between edges? I hope you can help me without the VI.
    I am using Arduino, so I can not use DAQmx VI's.
    DMDsync
    Attachments:
    program structure.jpg ‏54 KB

    Thanks for the quick feedback!
    I believe my problem is that I am not using the best way to estimate time between edges. As I previously said, I am using almost the exact VI that "Panoramarts" shared in this link:
    http://forums.ni.com/t5/Digital-I-O/Measuring-Time​-between-two-Digital-Signals/m-p/2091868#M16230
    The only difference is that instead of a DAQ assistant in each of the While Loops, I use the same input for both of them. It works ok. It measure the time difference between the 1st and 2nd edges, the 3rd and 4th, and so on. All that VI is inside a while loop to continuously perform the counting. May be I can simplify my question:
    How can I continuously measure time difference between incoming edges (it could be a Boolean variable varying from true to false periodically) in a VI that already has a continuous process running?
    As Altenbach said, I used a wait statement in the continuous process (as it is not necessary a fast data update for it, because it is just a simple temperature measurement), but that delay created some faulty timing in the edge timing sequence.
    Any ideas?
    Thanks again!
    DMDsync

  • Is there a way to exclude programming structures from diagram cleanup?

    So, I just started Labviewing a month or 2 ago. I really have to get used to the wires. Now, the "Diagram Cleanup" tool generally works fine, but even after tweaking it, it still makes my VI's explode to 3x their size. Is there a way to lock the programming structures I arranged to my liking, so the "Diagram Cleanup" tool doesn't re-inflate them when I decide my newly written code needs a cleanup?
    Thanks. 
    Jacco

    After discovering what the "Event Structure" was for (shame on me for not finding it earlier ), I cleaned up my window considerably, since I no longer had a couple of screens full of buttons connected to case structures.
    mikeporter wrote:
    No...
    Alright, suppose I'll just have to not use the cleanup function in my sort-of-organized VI's then. 
    BTW, if your code is really growing to
    the extend mentioned that might be an indication that you need to
    revisit your code's basic design. Can you post screen shots of the
    Navigation window showing your code?
    Mike...
    Grouping events neatly together solves most of my space requirements for now, it's just a little larger than my 1028x1024 screen (until next time I decide to click "Clean up diagram" ).
    Just wanted to be sure I hadn't missed the option to "lock" loops from auto changes. Thanks for the help.
    Jacco

  • Trying to monitor an indicator at all times...regardless of program structure. HELP!

    I have a complex Labview VI complete with several sequence structures and "for loops" that are necessary to control the logic of the program.  I need to be able to monitor, via an  indicator on the front panel, an indicator at all times during the program. Unfortunately, the way I have it set up, the indicator on the front panel will only display the correct values if the program is in the same structure as the indicator.  How can I monitor an input regardless of where I am at in the program?  Thank you!

    I apologize for the confusion and thanks for trying to help out with this.  The problem I am having is this:  I have a high voltage (0 to 10,000 V source) that I need to measure the voltage on at all times - because of safety reasons.  The high voltage source outputs a 0 to 5 V analog signal that is proportional to the 10,000V.  I measure the 0 to 5 V signal with a DAQ and need to show the value at all times on the front panel.  Because the voltage is always changing - even just a little bit - I should always see the value on the front panel changing.  However, I only see the value changing and fluctuating when the program is in the same structure (the same part of the sequence) as the indicator (that indicates the 0 to 5 V signal to the user on the front panel). Once the program goes to the next part of the sequence structure, the indicator on the front panel stays at the last value that was collected just before the program moved to the next part of the sequence.  I hope this is clearer. Thanks.
    Josh

  • Program Structure for PID temperature Controller

    Hi everybody,
    I built a PID temperature controller VI for a third party DAQ board, based on a very basic knowledge in programming.
    Now the VI works fine in both ends "i/ps & o/ps", the problem is that i cant get the response that I'm looking for from the PID controller. Since the system is time critical, I wounder if the structure of the VI is cosing this problem. please if you have any idea, hint or suggestion.
    Marwan
    http://www.geocities.com/marwan_m13/weemee8080.jpg
    Attachments:
    PIC Temperature Control(PID).vi ‏364 KB

    Marwan,
    You say that time is critical. The timeout is set to 1 second in the main loop. You will only get one update per second with this setting.
    Several comments:
    1. I have never seen the event structure used soley to control loop timing like this. No reason it should not work, but that is not its primary purpose. If you were to use the event structure to also handle user events (as it is designed to do), then things could get complicated. The Wait (ms) functions and Elapsed Time Express VIs can perform the timing for you without the risk of unintended consequences.
    2. Generally it is recommended to use only one event structure in a program, unless you have very specific reasons for using more than one. Since you are using them only as timers, the interaction potential is minimal.
    3. Right to left wiring and avoidance of wires hidden behind other objects make code much easier to read and to debug.
    4. Putting the user controls and displays and the write to file functions in independent loops allows the PID function to run at different rates from the user interface and file save functions. Look at examples of Producer/consumer architecture.
    5. Precalculating things which do not change from iteration to iteration can save time. For example multiply by 2.55 rather than multiply by 255 and divide by 100. Also make the datatypes consistent to avoid type coercion (indicated by little dots at the input connections such as the 255 input to the mutliply. Changing the datatype of the 255 constant to Double eliminates the coercion.
    Lynn

  • Why does LabVIEW skip over commands in programming structures

    Hello everyone!
    Is there a certain way you program to make labview execute ALL commands within a loop before going into another loop? For example, I have a while loop that stops if either the stop button is pushed or if the set point input is greater than 8. If both of these are false, then the code entered a case structure where it controls the output from a plant model. However, labview will enter the case structure without checking if both conditions are met. I've attached the VI and in the next message will post the VIs from the plant. I want it to do the below code,
    IF (Set Point > 8 OR Set Point < 0) THEN
           SET_Point OK= False
    ELSe
          SET_Point OK = True
    END IF
    IF (SET_Point OK = FALSE OR Stop Button pushed) THEN
             ! STOP VI
    ELSE
             ! Enter PID Control Loop
    END IF
    But labview likes to just jump around and skip parts for some reason. So when it for example, skips the OR check it uses the default value of true for the next case structure. It's driving me crazy. Can anyone please tell me why its doing this??
    Thanks.
    Solved!
    Go to Solution.
    Attachments:
    General Auto PID Simulator.vi ‏83 KB
    Global 1.vi ‏5 KB

    Ah! I can't believe I made that dumb of a mistake. And thanks for the advice altenbach. My overcomplicated diagram probably lead me to making that error. 
    I have another question though. How come when I use the Write to measurement file VI it will start the process variable at like 40 inches but when I don't use it, it'll start it at 0 and do as its supposed to? I've attached my updated VI with the write to measurement file VI in it. You'll see that if you delete it then it'll do as its supposed to. I don't understand why though..
    Attachments:
    General Auto PID Simulator.vi ‏118 KB
    Global 1.vi ‏5 KB
    problem with PV initialization.JPG ‏132 KB

  • Smartform - no data incoming to print-program (structures empty)

    Hi,
    I am creating a Smartform for an RMA, based on a standard Sales Order confirmation form.
    When testing the entry in the print program, I have noticed that none of the incoiming global structures are filled with values (VBDKA, VBDPA and etc).
    Is this normal or has something not been configured correctly?
    The only structure that is filled is NAST, which gives me the objky number. This is triggered from VA02.
    Please help.
    Thanks,
    John

    Hello
    This is normal scenario. Print program will always have NAST data coming from Document Output Determination. You will have to fetch/collect any other data required for printing in the Driver Program/Print Program.
    For ex: function module RV_DOCUMENT_PRINT_VIEW has been used in Print Program RVADOR01 (Print Program for Sales Documents) to collect the required data which is used to print the sales documents.
    Thanks
    Amol Lohade

  • ABAP Program structure

    Hi,
    I wanted to know the ABAP code structure.while coding we write the code in a sequence,I just wanted to have a layout for the same.
    Thanks.

    Refer the links -
    http://www.sap-img.com/abap/events-related-to-reporting.htm
    http://www.sap-img.com/abap.htm
    Regards,
    Amit

  • Program structure for a report

    hi,
    could any one clarify whether
    initialization event is to be  written first or
    selection-screen begin of block is to be written.plz tell whether this affects performance.
    I have written a report with the following structure.plz correct me if i'm wrong
    1)DB table declaration
    2) internal tables declaration and ranges decltn
    3)ALV variables & internal tables
    4)constants & variables
    5)initialization
    6)selection-screen(begin of block-end of block)
    7)at selection-screen on value req
    8) at selection-screen
    9)start-of-selection
    10)end-of-selection

    Hi Mamatha
    There is absolutely no need of worrying about which should come first and which next...
    Anything is fine...whether INITIALIZATION coming first or vice-versa. and further, there is no connection of this with performance. Infact, let me tell you that PERFORMANCE comes into picture only when u r accessing the database or when u r processing large internal tables.
    <b>and regarding the order of ur report:</b>
    Its fine! How ever, for more readability, u can swap the 5th and 6th steps, so that all the events are grouped at one place and all the data declarations above them.
    And let me tell u one important thing: Don't allow the data declaration to happen in SELECTION-SCREEN events, it will not be global.....
    Hope u understand me completely
    Reward points if helpful
    Regards

  • Changes in Program Structure

    Hello Everyone,
    First question: Our client has 4 different colleges and 16 different programs of study for undergraduate studies. Thus, at the beginning, we have 16 different program plans stated. But it is foreseen that (with former experiences) there are goning to be some changes in the program plans. For example a student (stu. X) entered school in 2006. He/She has to complete 140 CRH and is still a student. Another student (stu. Y) entered the school in 2009 and because of the change in courses and total credits he/she has to complete 130 CRH.
    Second question: In order to make things more difficult, a course(course A) which was offered in the second semester (we assume that total studying time is 8 semesters - 4 years) is replaced by another course (course B). In the old curriculum course A was offered in the second semester but now in the seventh semester, in the old curriculum course B was offered in seventh semester but now in second semester. Stu. X had completed the course A but because of replacement, we don't know yet how to handle the situation. (actually it is not that difficult to solve a single problem for just one student and for just one course)
    It is strongly forseen that we are going to be facing situations like this even more difficult ones. So we need to find a way to manage the changes in curriculum and assigning those different curriculums to different students. We thought of creating different SC objects but we assume that we are going to have 2 or 3 different curriculums for each program of study which means we can have 30-40 different SC objects - when we are considering the whole university.
    I would really appreciate if you can help me with these problems.
    King Regards,
    Kerem

    Hi Kerem,
    For your first question, I would suggest that you handle the change in the requirements in different years with different Requirement Catalogs assigned to the students. Depending of the year the students enters the university, the requirement catalog is assigned with the requisites that corresponds to that year. And then you will be able to run the Degree Audits to check different requirements for different sets of students. And if requirements change (is it that way? a student may enter a program with some requirements, and then the university change them??), you can later assign another requiremente catalog, or change the ones assigned.
    In your second question, if the changes in the content of the program are not very important, I would reccomend you to use the validity date of the Module Objects to delimit the ones that does not apply anymore, and to add new ones or change data such as credits, etc. In the case the Program has important changes, it is reccomended to create a new SC.
    In the case a student has taken a module A, and  then a module B is required because of a change in the requirements for the student, maybe you can create some custom relationship between that modules that may tell the system that those modules are equivalent. You wuill need to check that relationship when you run an audit, or a report you may use to check student requirements.
    Hope it helps.
    Diego

  • Question on program structure about event handling in nested JPanels in GUI

    Hi All,
    I'm currently writing a GUI app with a wizard included in the app. I have one class that acts as a template for each of the panels in the wizard. That class contains a JPanel called contentsPanel that I intend to put the specific contents into. I also want the panel contents to be modular so I have a couple of classes for different things, e.g. name and address panel, etc. these panels will contain checkboxes and the like that I want to event listeneres to watch out for. Whats the best way of implementing event handling for panel within panel structure? E.g for the the checkbox example,would it be a good idea to have an accessor method that returns the check book object from the innerclass/panel and use an addListener() method on the returned object in the top level class/panel. Or is it better to have the event listeners for those objects in the same class? I would appreciate some insight into this?
    Regards!

    MyMainClass.main(new String[] { "the", "arguments" });
    // or, if you defined your main to use varags (i.e. as "public static void main(String... args)") then you can just use
    MyMainClass.main("the", "arguments");But you should really extract your functionality out of the main method into meaningful classes and methods and just use those from both your console code and your GUI code.

  • Java program structure !

    hi,
    i'm developing a program and i've some memory problems in the runtime.
    my program is something like that:
    public class Service extends JFrame {
    JPanel panel = new JPanel();
    public Service(){
    ListServices();
    public void ListServices(){
    DBServices dbservices = new DBServices(panel);
    public class DBServices(){
    JPanel panel = new JPanel();
    public DBServices(JPanel iPanel){
    panel = iPanel;
    public fetchDatabase(){
    // do a select statement
    while(rowset != null){
    JButton detail = new JButton("detail");
    detail.addactionlistener ( .......
    Detail det = new Detail();
    fecthDatabase();
    JLabel label = new JLabel("name");
    panel.add(detail);
    panel.add(label);
    public class Detail extends JDialog{
    public Detail(){
    Ok, this program makes a list of services, when we press a button(the text could be service n�), a dialog opens and shows his detail. When i close the detail window, he sould retrieve again the list from the database.
    This example works, but every time i press the button to see the detail, the memory taken by the java process increases, and he don't release any memory.
    What can i do to make my program work ?
    tks

    Never mind... you're later on clearing the panel, so
    the button (and its listener) should garbage collect
    at some point. I don't know... you haven't really
    shown all the code (not that I'm promising to look at
    it all), and I don't know if you really have a
    memory leak. From other topics you opened where you
    were concerned about a leak, others told you you might
    not - depends on when the VM decides to garbage
    collect. As long as it doesn't grow uncontrollably
    where it could eventually throw an OutOfMemoryError,
    there might not be a problem - just perceived.But after some operations he throws OutOfMemoryError, and the program hangs, i already try to call GC in many places of the code, but doesn't work.
    The code is very extensive, so i just reduce him to the logical part, the other thing are just variables e calculations....

Maybe you are looking for

  • ITunes thinks iPhone has more music than it really does, and won't sync

    I have an iPhone 4 running iOS 7.1, and am running iTunes 11.1.5 on Mavericks. I was using iTunes Match on the iPhone, but I don't want to do so any more because I have acquired a lot of music that I can't upload to iTunes Match. (This is because my

  • Problem with connecting to DB2 from ADFBC

    I have a problem with connection to DB2 data using ADF BC components. Everything looks fine till I run the page(JSF) to see the data of a db2 table. I created a read only view object. This view is registered in the AM and from AM the view is returnin

  • Photoshop CS5 Issue with GPU accelaration

    I was having gpu accelataration enabled about week ago photoshop gave error that i need to update driver now after updating error it is not detecting my gfx card. According to me it gave error after going some update that was asked by adobe updater a

  • Wifi is hardware disabled

    Hi there, In my Yoga 2 pro, the Intel wireless-n 7260 chip is hardware disabled when using linux. I checked it with fedora, ubuntu and suse. The output of "rfkill list" is always the same: 0: ideapad_wlan: Wireless LAN Soft blocked: no Hard blocked:

  • How to unlock iphone worldwide all network

    hii friend how to unlock iphone worldwide all network with apple server plz guide me