Parent class private data accessable in Child class?

Hi!
I thought that this would be obvious, but my search foo fails me.  Hopefully someone would be kind enough to answer my newbie LVOOP question.
I have a a parrent class.  This parrent class contains a cluster of class private data.  I setup all the accessor methods to this data.  I create a child class that has functions that need to access data stored in its parrent class.  Its inheritence is set, but when I try to unbundle the class data all I can seem to get to is what is setup in the child class' data cluster.
I've watched a video and it looked like the data cluster magically appeared and was accessable through the children methods.  What am I missing?
Thanks for input!
-nic
Solved!
Go to Solution.

Nickerbocker wrote:
Well, that makes sense.
One other quick question.  Is the procedure, New->"VI for Override..." from the context menu of my child class the only way to create a method that overrides the parents method?  Where is the property that defines this newly created VI as overriding my parent's VI?  Can I simply create a VI that is named the same and it have the same effect?
That is the only method I use but I believe if you get all of your icon patterns and terminal marking as dynamic and all of the other rules, you should be able to do the same thing by hand (I base this guess on the fact I messed with those things and broke my ever-rides).
The only thing I think has to be done from the project (scripting aside) is to set-up the inheritance.
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction

Similar Messages

  • LVOOP Parent private data returned when child instance created from constant

    I have created one Parent class, and one Child class.  For each of these classes, I have created a member VI that is a constructor, whose purpose will be to initialize some constants for each class, and return the class instance.  I also have a member accessor VI for each class that returns the private data of the class (in this case a single string for each class).
    The Parent class's private data "String" is set to"Parent text" as the default value.
    The Child class's private data "Child String" is set to"Child Text" as the default value.
    The Parent class constructor works just fine.  For testing purposes, I return the text from directly unbundling in the constructor VI, and as returned from the accessor VI. The Parent constructor starts from a class constant.
    However, in the case of the Child class constructor, if I start from a class constant, directly unbundling the private data (using an Unbundle By Name function, and choosing "Child String" as the element), I get the Parent's private data!
    If I use the Child class's member VI to retrieve the text, I get the Child's private data.
    If I change the constructor to start from a class Control instead of a class Constant, I get the Child's private data.
    This only occurs  before the Child class has existed as a
    Control/Indicator. i.e. If I unbundle the private data after the class 
    is returned by any member VI, I get the correct Child private data.  So obviously something changes once the class "data" has been a control at some point.
    I am using Labview 8.6.1, Windows XP
    I have attached a small project that illustrates the problem I am encountering, without actually doing any initialization, just reading.
    Is this the intended behaviour?  Why does it matter if I start with a class constant instead of a class control?  When you drag from the Project window to the Block diagram, you always get a constant.
    Solved!
    Go to Solution.
    Attachments:
    ParentChildClass.zip ‏54 KB

    Although I was able to replicate your issue in LabVIEW 8.6.1, it appeared to run correctly in 2009.  I could not find a CAR ID but at this point can only assume that the behavior was not intended but is fixed in 2009.
    Let me know if you need me to find any further details.
    Alex Person
    NI-RIO Product Support Engineer
    National Instruments

  • Incorrect aggregation in parent after deleting data in any child member

    Hi Experts,
    Currently we are facing a problem in which data are aggregating at parent level properly except in cases where data were already present and subsequently has been deleted. For example if '1000' has been entered in a child level member, it is properly shown in its parent. But, when this figure is deleted, the parent level member is not updated. If '1000' is replaced by any other figure, it is properly being updated in the parent.
    The dimension members in which data are being entered have 'Store' property and we are using AGG business rule to accumulate data in parent level.
    The above issue is appearing in all months except February. I have checked settings of the dimension member 'February' and it matches with the settings of all other months.
    Kindly guide me in this regard as to why this issue is coming and its possible solution.
    Thanks in advance!
    SYR

    Not very clear from description but,
    Along with Aggregate missing off, Turn off the intelligent calculations as well:
    SET UPDATECALC OFF;
    http://docs.oracle.com/cd/E17236_01/epm.1112/esb_tech_ref/set_updatecalc.html
    Is it a single child of the parent, the only child which aggregates to parent,
    Are you entering data though data form, is the base member and shared member both are present in data form in rows?
    Cheers..!!
    Rahul S.

  • Accessing subclass data when parent class is part of private data of another class.

    I am working up an OOP test program and have a problem with data access.
    I have the following classes defined:
    General Test
    General Report
    Specialized Test
    Specialized Report
    The Specialized Test and Specialized Report are subclasses of General Test and General Report, respectively.
    The General Test class contains a General Report class instance as part of it's private data.
    Specialized Test writes a Specialized Report to its parent class data on initialization. The Specialized Report contains additional data items in its private data.
    I have a method for Specialized Test where I first access the Report object stored in the General Test private data, then try to access the private data of the Specialized Report, that should be returned.I get a class mismatch, as the General Test accessor does not know it is returning a Specialized Report.
    Should I simply typecast the returned report to the more specific class before trying to access the subclass data as shown below, even though it will already be the more specific class?
    Thanks,
    Josh

    I don't see your image - maybe it just hasn't finished uploading yet - but if I'm understanding correctly, using To More Specific Class (not Type Cast) is a fine solution here. It's reasonable to use To More Specific Class to get the wire type to match the type of data that you know it will carry when the compiler cannot make that determination for you automatically.

  • Can I make methods which are public in a parent class into private in a child class ?

    I suspect the answer to my question is probably no, but...
    I have a parent class that provides several general purpose methods, I also have a child class which is intended to provide a more specific set of methods for manipulating the data in the class. As a result, calling some of the parent's methods on the child class can provide results that I'd rather not let the users of the child class have to worry about. It seemed (from my rather naive OOP experience) that the nicest way to do this would be to make access to some of the parent's public methods be private in the child class. This doesn't seem to be trivially possible.... ?
    Gavin Burnell
    Condensed Matter Physics Group, University of Leeds, UK
    http://www.stoner.leeds.ac.uk/

    Hi Gavin,
    Unfortuneately I don't think this can be done. You can use an overide VI to change the functionality of a method in a child class but it has to have the same scope and the method it overides.
    Regards
    Jon B
    Applications Engineer
    NI UK & Ireland

  • Accessing protected and private data of a class

    Hi friends,
    I have writen a sample code in oops abap but iam facing some problem.
    CLASS MAIN DEFINITION.
        public SECTION.
          DATA : VAR1(10) TYPE C VALUE 'NEW VALUE'.
          METHODS : PUBLIC.
      ENDCLASS.
      CLASS MAIN IMPLEMENTATION.
         METHOD : PUBLIC.
           WRITE : /5 VAR1.
              VAR1 = 'CHANGED'.
           WRITE : /5 VAR1.
         ENDMETHOD.
      ENDCLASS.
    START-OF-SELECTION.
        DATA :
               O_MAIN TYPE REF TO MAIN.
               CREATE OBJECT O_MAIN.
               CALL METHOD O_MAIN->PUBLIC.
    now its working fine as public methods can be access by all the people where as protected methods can be access by class and subclass so i can inherit the properties of above class and access the protected data.
    where as to access private data , private data can be access by class itself...
    so now how do i access the private data within the class...ie : how do i get the above output when i use a private section instead of public..
                CLASS MAIN DEFINITION.
        private SECTION.
          DATA : VAR1(10) TYPE C VALUE 'NEW VALUE'.
          METHODS : Private.
      ENDCLASS.
      CLASS MAIN IMPLEMENTATION.
         METHOD : Private.
           WRITE : /5 VAR1.
              VAR1 = 'CHANGED'.
           WRITE : /5 VAR1.
         ENDMETHOD.
      ENDCLASS.
    START-OF-SELECTION.
        DATA :
               O_MAIN TYPE REF TO MAIN.
               CREATE OBJECT O_MAIN.
               CALL METHOD O_MAIN->Private.
    iam getting a error saying you cannot access the private section...
    now private section can be accessed within the class but nt by others...
    to access the private section within the class how should i correct it...
    Regards
    kumar

    HAI,
    Private attributes or methods can be accessed directly by the Object but within the Scope of the Class, but not outside.
    Look at this:
    CLASS MAIN DEFINITION.
    public  SECTION.
    METHODS : Public.
    private SECTION.
    DATA : VAR1(10) TYPE C VALUE 'NEW VALUE'.
    METHODS : Private.
    ENDCLASS. " END of CLASS DEFINITION
    CLASS MAIN IMPLEMENTATION.
    METHOD : Public.
    CALL METHOD Private.
    ENDMETHOD.
    METHOD : Private.
    WRITE : /5 VAR1.
    VAR1 = 'CHANGED'.
    WRITE : /5 VAR1.
    ENDMETHOD.
    ENDCLASS. " END of CLASS IMPLEMENTATION
    START-OF-SELECTION.
    DATA:  O_MAIN TYPE REF TO MAIN.
    CREATE OBJECT O_MAIN.
    CALL METHOD O_MAIN->Public.
    PS: If there is any better alternative solution please share it .
    Best Regards,
    rama

  • Class VIs for access to private Data: reentrant or not?

    I just created in a class some VIs for access to private data (my German translation). I'm talking about these VIs, which enable you to connect your class object to a property node to read or write private class data. These VIs are by default non-reentrant. My question is: what happens, if I try to access two objects of the same class with these property nodes? Does the second object have to wait for the first one to be read? If yes, can I circumvent this by making these VIs reentrant?
    Regards,
    Marc
    CLD
    Solved!
    Go to Solution.

    In theory yes. In pratice it will depend on what you are doing in the private method and the methods it calls.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • LabVIEW crashes when modifying OOP parent class private data control or typedef contained in that control

    I've been seeing strange behaviour when I modify the private data control of a class, especially if it is a parent class.  It seems that those changes are not always propagated to all the VI's in the project.  This sometimes causes my project to crash with an exception error, or sometimes the problem is more subtle as it will simply write data to the wrong elements in the control (when bundling/unbundling).
    I solve the problem by opening the typedef or class control by itself (i.e. not as part of the project), and then saving it.
    The next time I open the project all problems are solved.  This is a difficult error to track down but I now know to keep a list of typedefs or class controls that I have modified (using subversion helps here), and then when this strange behaviour or crashes happen, I simply close the project and open each modified typedef or class outside of the project and save them individiually.
    Anyone seen something like this too?

    Hmmm.... Have not seen what you are describing -- though occasionally I will see a class that appears broken until I open it by itself outside the project.
    How large is your application?
    How many classes do you use?
    How extensively do you use classes in the application?
    Could you post a screen shot of your project and how things are arranged in it?
    Does the problem seem to be related to any particular class or group of classes?
    Have you tried mass-compiling your code?
    Are the VIs set to separate the object code from the source?
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Problems accessing child swf from parent class

    First off: Hi. I'm new - to the forum and to Flash.
    I'm currently writing a flash app that requests a XML feed
    from a Java controller and loads child swfs into various parts of
    the stage based on the settings/URL details received from the XML
    feed.
    Its nearly there and I've got my head round a couple of weird
    things, but theres one thing left that I've found impossible to
    solve. Once the loader class has loaded the swf, it can't access
    its methods or set its variables and the child can't access the
    parent either (or access the parent's variables full stop). From
    what I've read this should be possible. Heres some of my code plus
    pseudo code:
    Note the Panel class is not linked to a symbol and uses
    composition to act like a movie clip, rather than inheritance.
    quote:
    class Panel{
    function Panel(owner:MovieClip, insName:String,
    depth:Number){
    initiates properties etc....
    panelMovie = owner.createEmptyMovieClip(insName,depth);
    listener.onLoadComplete = mx.utils.Delegate.create(this,
    scheduleModule);
    loader.addListener(listener);
    loader.loadClip(moduleX.url, panelMovie);
    function scheduleModule(){
    trace(panelMovie.key);
    trace(panelMove.keyTest());
    panelMovie.key = "dave";
    trace(panelMovie.key);
    Child swf:
    quote:
    var key:String = "test";
    As you can see I create an empty movieclip which I store a
    reference to in this class under the field "panelMovie". I then use
    this (instead of target_mc like you might do with an event handler)
    to try to access the child swf. The output is:
    trace(panelMovie.key); = "test" (Works fine)
    trace(panelMove.keyTest()); = (Nothing returned)
    panelMovie.key = "dave";
    trace(panelMovie.key); = "test" (Previous line = no effect)
    Is this something related to using a class? Really would be
    preferentially to keep all code outside of the fla.
    I've also tried a lot of different combinations of _root,
    _parent and _levelx. None of which I truly understand.
    Any help would be much appreciated! Plus any good tutorial
    links on timeline and referring to objects in it!
    (Couldn't find the code tag/button...)

    >>trace(panelMove.keyTest()); = (Nothing returned)
    You have panelMove here instead of panelMovie
    Dave -
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • Setting private fields from Parent class.

    Hi all, I have what seems to be a weird situation to me.
    Basically I have two classes:
    import java.lang.reflect.Field;
    public class Parent {
         protected void ensureDefaults() {
              Field[] declaredFields = getClass().getDeclaredFields();
              for (Field field : declaredFields) {
                   Object fieldValue = getDefaultValueForType(field.getType());
                   try {
                        System.out.println("defaulting field - name: " + field.getName() + " | this: " + this);
                        field.set(this, fieldValue);
                   } catch (Exception e) {
                        e.printStackTrace();
         private Object getDefaultValueForType(Class<?> type) {
              Object defaultValue = null;
              if (type.isAssignableFrom(String.class)) {
                   defaultValue = "default";
              } else if (type.isAssignableFrom(int.class)) {
                   defaultValue = -100;
              return defaultValue;
    public class Child extends Parent {
         private String name;
         private int age;
         public Child() {
              ensureDefaults();
         public String getName() {
              return name;
         public void setName(String name) {
              this.name = name;
         public int getAge() {
              return age;
         public void setAge(int age) {
              this.age = age;
    // Test Case
    import junit.framework.TestCase;
    public class ChildTest extends TestCase {
         public void testEnsureDefaults() {
              Child child = new Child();
              assertEquals("default", child.getName());
              assertEquals(-100, child.getAge());
    }The odd thing to me is that the output looks like:
    defaulting field - name: name | this: Child@7431b9
    java.lang.IllegalAccessException: Class Parent can not access a member of class Child with modifiers "private"
    ... more exception ...
    defaulting field - name: age | this: Child@7431b9
    java.lang.IllegalAccessException: Class Parent can not access a member of class Child with modifiers "private"
    ... more exception ...
    As you can see, it doesn't like me setting (or getting for that matter - tried that) these fields because they're private. However, if you look it's saying that "this" is a Child, so shouldn't those fields be accessible? Shouldn't ensureDefaults be executed as if it was being called by the Child instance?
    Obviously, I can try to use the accessor methods, but that means creating strings for method names, and then looking for the methods. I'd like to avoid this and it seems to me this should work, no?
    Another odd thing is that if I change the fields in Child to protected, it works fine.
    Also, I'm not sure if this is important (I don't know enough about security managers to know if they're different platform to platform, version to version), I'm on a Mac OSX 10.4.11 and:
    java version "1.5.0_13"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-241)
    Java HotSpot(TM) Client VM (build 1.5.0_13-121, mixed mode, sharing)
    Any help with this would be greatly appreciated.
    Thanks,
    Eric

    jschell wrote:
    As you can see, it doesn't like me setting (or getting for that matter - tried that) these fields because they're private.Myself I don't like it because it suggests a design problem which is associated with understanding that although a child is a parent that doesn't mean that a parent is a child.
    I understand that, but I don't see how this actually breaks that. The Child is executing a method that is passed down to it from it's Parent, but it's executing it as itself - by that I mean it's not looking at anything that it can't already look at, or at least I thought it was.
    Shouldn't ensureDefaults be executed as if it was being called by the Child instance?No.Ok, I thought it was. Can you please explain this a bit more, I want to understand it.
    >
    Another odd thing is that if I change the fields in Child to protected, it works fine.If you messed with reflection some more you could get to to work even with private. How exactly? I really don't want to bypass any security measures (by settings accessible or using a different security manager, or anything like that). As I mentioned in my last post, what I want to do really is nothing more than a nice way to have a generic toString or hashCode method, if it's not possible to do it nicely - within java's default constraints, I'd rather not.
    >
    However in general the idiom would still be wrong.I'm moving more towards using beans anyway, so I plan on just calling accessor methods which corrects the "wrong idiom" right?
    Thanks for all the help,
    Eric

  • Array of objects in class private data and calling overridden VIs on these objects?

    Hello
    I am developing part of an application using the actor framework and have run into problems.
    I have a several actors and will try briefly describe them and their intended functionality. All actors are started by a Controller actor and in the actor core for the controller I have the possibility to do a lot of intiliazation etc.
    Logger:
    Has a message (Send Log Message) that other actors can use to write to the log. It is supposed to take a string input and a log level (error, warning, debug etc). This message chain sends data to the actor core with a user event.
    The Actor Core of Logger is supposed to save the incoming message to a log, but should be able to do it in several different ways (file, database, email or whatever).
    Logger Output:
    Abstract class that has a dynamic dispatch vi called "Write Output" that all it's children are supposed to overwrite.
    Logger Output File
    Child of Logger Output and overwrites "Write Output" to save the string to a file on disk.
    Problem:
    I want to be able to set up the actor core for Logger once and for all but still be able to create new children of "Logger Output" and have them be handled in the Logger actor core.
    My idea was to have Logger use an array of objects as private data and initialize this array in the Controller actor core.
    In the logger actor core I could then auto index the array and use each element (each Logger Output child) and the abstract "Write Output" vi to get the correct functionality.
    HOWEVER, I cannot get this to work properly and I think I have misunderstood something or stared myself blind on this problem. I have tried 3 different methods when it comes to private data for Logger.
    1. Labview Object
    2. Array of Labview Object
    3. Array of Logger Output Object
    Of these 3 methods, I can only get the first one to work and that doesn't accomplish what I want in the end (being able to add more classes without changing private data / actor core for Logger).
    I have included 3 screenshots that show snippets of 2 of the actor cores and the private data. File names should correspond to my description above.
    The screenshot "Logger actor core.png" shows a very fast test of the 3 different methods I described above. Each of the 3 tunnel inputs to the event structure can be wired to the "Reference" input of "To More Specific Class", but only method 1 (Labview Object) works.
    If you need additional information / screenshots or whatever please ask.
    Thanks in advance
    Attachments:
    Logger ctl.PNG ‏8 KB
    Logger actor core.PNG ‏25 KB
    Controller Actor Core.PNG ‏11 KB

    Thanks for the reply and sorry for the confusing OP. It was meant as a quick test and a way to skip making 10+ screenshots .
    I updated the actor core for the Controller and Logger to be less confusing (hopefully) and attached 2 screenshots.
    I agree with you that it would be a good idea to make a message for the controller that can launch new children of the L" abstract actor, but for these tests I have just launched it the easy way (dragging it to the controller actor core).
    Both Logger Output and Logger Output File are actors and in Logger Output there is a dynamic dispatch vi called Write Output that I want to override in all its children.
    The problem is when I run the actor core of Logger (see the screenshot) only the abstract version (the one in Logger Output) of Write Output is executed, not the overridden version from Logger Output File.
    When I did the same thing with the actor cores looking like the did in my original post, then the correct overridden version got executed when I used the method with one Labview Object in private data (not any array or an array of Logger Output objects).
     EDIT: I just tried to have the Logger private data be a single Logger Output object and writing the Logger Output File to that piece of private data in the Controller and the correct Write Output override method gets called now. So apparently I have done something stupid when it comes to creating the array of Logger Output objects and writing them in the controller? The private data is in the Logger actor so I have simply right clicked and chosen "New VI for Data Member Access" and chosen "Write" for "Element of Array of Logger Output Objects".
    Attachments:
    Controller Actor core updated.PNG ‏10 KB
    Logger actor core updated.PNG ‏24 KB

  • How to track child instances in parent class

    I have a **simple** design question about a good way to implement LV OO.
    I have a parent class (multiple instances) with a single child class. The parent class needs to keep track of all "active" instances of the child class because some parent methods must be applied to all children. Is there a way for this to happen automatically in LV? I'm not aware of any, so I assume I will have to use some "register" and "unregister" actions for creation and destruction of child class instances. But how do I track them; where do I store the list?
    It would be easiest to simply add an array of child class references to the private class data of the parent. However, LV seems to not support this due to "circular referencing". I am not familiar enough with OO, nor it's implementation in LV to know what is a good design approach to accomplish this task.
    Any suggestions?

    What I am trying to do:
    I have one or more TCP connections that I am using. The parent class is the TCP connection. The private data for the class is a queue reference. The queue data type is a type def cluster of relevant parameters. The queue has a maximum of 1 element. The reason for this abstraction is that our applications use many TCP connections "simultaneously." As such, we want almost all of the TCP support VIs to be reentrant. This means that we need semaphore action when connection parameters are changed, and we use the queue to achieve this.
    The TCP standard guarantees that each message is delivered intact, but does not guarantee message order. Sending large waveforms (or data from a continuously measuring process) requires additional work to ensure that the messages are correctly reordered on the receive end. We created an Ordered Data Stream (ODS) construct to accomplish this. That is the child class. Each TCP connection has 0 or more ODS. Each ODS inherits all the TCP settings from the parent, and can use the parent communication functions. It seems this is a textbook example of the usefulness of inheritance.
    However, all good parents are able to keep track of their children. The TCP class needs to be able to track all active ODS instances on that TCP connection. We are struggling with the best method to use for the TCP class to keep track of all ODSs. Adding an array of ODS class instances to the TCP "private data" does not work, due to circular referencing between parent and child classes.
    In response to trying a grandparent class:
    We tried using a grandparent class. We added an array of grandparent classes, from which the TCP class inherited. The array is actually ODS instances that have been (2X) upcast from ODS to grandparent (more general class) to be stored in the TCP class data. We found that adding the array of grandparent classes to the TCP class created a VI that could not compile when we attempted to place the type def cluster ("class data") on the block diagram of a VI in the TCP class.

  • How to access the parent class variable or object in java

    Hi Gurus,
    I encounter an issue when try to refer to parent class variable or object instance in java.
    The issue is when the child class reside in different location from the parent class as shown below.
    - ClassA and ClassB are reside in xxx.oracle.apps.inv.mo.server;
    - Derived is reside in xxx.oracle.apps.inv.mo.server.test;
    Let say ClassA and ClassB are the base / seeded class and can not be modified. How can i refer to the variable or object instance of ClassA and ClassB inside Derived class.
    package xxx.oracle.apps.inv.mo.server;
    public class ClassA {
        public int i=10;
    package xxx.oracle.apps.inv.mo.server;
    public class ClassB extends ClassA{
        int i=20;   
    package xxx.oracle.apps.inv.mo.server.test;
    import xxx.oracle.apps.inv.mo.server.ClassA;
    import xxx.oracle.apps.inv.mo.server.ClassB;
    public class Derived extends ClassB {
        int i=30;
        public Derived() {
           System.out.println(this.i);                  // this will print 30
           System.out.println(((ClassB)this).i);  // error, but this will print 20 if Derived class located in the same location as ClassB
           System.out.println(((ClassA)this).i);  // error, but this will print 20 if Derived class located in the same location as ClassA
        public static void main(String[] args) { 
            Derived d = new Derived(); 
    Many thanks in advance,
    Fendy

    Hi ,
    You cannot  access the controller attribute instead create an instance of the controller class and access the attribute in the set method
    OR create a static method X in the controller class and store the value in that method. and you can access the attribute by 
    Call method class=>X
    OR if the attribute is static you can access by classname=>attribute.
    Regards,
    Gangadhar.S
    Edited by: gangadhar rao on Mar 10, 2011 6:56 AM

  • Urgent: how to really seperate business logic class from data access class

    Hello,
    I've this problem here on my hand and i really need help urgently. so please allow me to thank anyone who replies to this thread =)
    Before i go any futhur, let me present a scenario. this will help make my question clearer.
    "A user choose to view his account information"
    here, i've attempted to do the following. i've tried to seperate my application into 3 layers, the GUI layer, the business logic layer, and the data access layer.
    classically, the GUI layer only knows which object it should invoke, for example in the case above, the GUI would instantiate an Account object and prob the displayAcctInfo method of the Account object.
    here is how my Account class looks like:
    public class Account
    private acctNo;
    private userid;
    private password;
    private Customer acctOwner;
    the way this class is being modelled is that there is a handle to a customer object.
    that being the case, when i want to retrieve back account information, how do i go about retrieveing the information on the customer? should my data access class have knowledge on how the customer is being programmed? ie setName, getName, setAge, getAge all these methods etc? if not, how do i restore the state of the Customer object nested inside?
    is there a better way to archieve the solution to my problem above? i would appriciate it for any help rendered =)
    Yours sincerely,
    Javier

    public class AccountThat looks like a business layer object to me.
    In a large application the GUI probably shouldn't ever touch business objects. It makes requests to the business layer for specific information. For example you might have a class called CustomerAccountSummary - the data for that might come entirely from the Account object or it might come from Account and Customer.
    When the GUI requests information it receives it as a 'primitive' - which is a class that has no behaviour (methods), just data. This keeps the interface between the GUI and business layer simple and makes it easier to maintain.
    When using a primitive there are four operations: query, create, update and delete.
    For a query the gui sets only the attributes in the primitive that will be specifically queried for (or a specialized primitive can be created for this.) The result of a query is either a single primitive or a collection of primitives. Each primitive will have all the attributes defined.
    For a create all of the attributes are set. The gui calls a method and passes the primtive.
    For an update, usually all fields are defined although this can vary. The gui calls a method and passes the primitive.
    For a delete, only the 'key' fields are set (more can be but they are not used.) The gui calls a method and passes the primitive.
    Also keep in mind that a clean seperation is always an idealization. For example verify that duplicate records are not created is a business logic requirement (the database doesn't care.) However, it is much easier and more efficient to handle that rule in the database rather than in the business layer.

  • Accessing variables in a parent class?

    Hello everyone,
    I'm rather new to java, and I've been looking at the documentation a bit but am still trying to figure out just what I am looking for. I've posted an example of such before where I have two seperate files, the parent class file and the child class file. What I want to do is somehow return the instance of parent that child was created with from the below code.
    public class parent {
         protected int var;
         public static void main(String[] args) {          
              child chld = new child();
    }Is it possible to get the same instance of parent that created the child? If so, can it be used to access or modify the variables held by parent? Or is it only possible to do this by creating methods to set or get the value of the variable?
    Can someone point me to the proper term as well, so as I might check the manual as well?

    Another thing I just noticed; your question does not seem to match your post's subject title. Taking that into context, it is possible to read your post very differently. Do you mean that you want to reference parent from inside of its own method, not necessarily after it has returned?
    You can access an object's variables and its methods from within a method it owns. To clarify what I mean...
    public class Something
        int someData = 0;
        public void someAction()
            // Something has a variable "someData" which can be accessed directly from inside of Something's own method someAction()
            someData = 5;
            System.out.println(someData);
    }If you mean you want a reference to the object itself from within one of its methods, Google for the "this" keyword.
    None of these have anything to do with the child object though, so I'm still a bit stumped as to what exactly you mean. Perhaps a combination of all answers received so far?
    Again, you probably need to further clarify exactly what you're looking for.

Maybe you are looking for