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.

Similar Messages

  • What can be considered as the business logic of simple data entry form

    Hi all,
    I want to separate my applications logic into layers. It is a simple data entry form and doesn't contain any complex business logic. So I want to get this simple business logic to different layer. But the problem is, I cannot clearly identify what are business logic of this kind of simple data entry form.
    How do I separate business logic of this simple data entry form to another layer?
    any help is appreciated,
    Thanks in advance,
    Dil.

    dcminter wrote:
    It is a [form] and doesn't contain any complex business logic. So I want to get this simple business logic to different layer. But the problem is, I cannot clearly identify what are business logic of this kind of [form].Are you asking which bits are business logic?
    Suppose that the data comes into your system immaculate from some external system. Imagine that it will go out into some other system. The bits that you would still have to write are your business logic.That's a nice practical definition. Thank you, I'm stealing it.
    Also interesting to note that validation falls into that category... say you're recieving data from a magical external source... you still have to validate it.
    And of course you'd still have to store it somewhere, ans retrieve it.
    Yep, I definately like that definition.
    Cheers. Keith.

  • How to call a Java class from another java class ??

    Hi ..... can somebody plz tell me
    How to call a Java Class from another Java Class assuming both in the same Package??
    I want to call the entire Java Class  (not any specific method only........I want all the functionalities of that class)
    Please provide me some slotuions!!
    Waiting for some fast replies!!
    Regards
    Smita Mohanty

    Hi Smita,
    you just need to create an object of that class,thats it. Then you will be able to execute each and every method.
    e.g.
    you have developed A.java and B.java, both are in same package.
    in implementaion of B.java
    class B
                A obj = new A();
                 //to access A's methods
                 A.method();
                // to access A's variable
                //either
               A.variable= value.
               //or
               A.setvariable() or A.getvariable()

  • How do I seperate the audio track from the video and save it to a CD in Premiere Elements 13?

    How do I seperate the audio track from the video and save it to a CD in Premiere Elements 13?

    Binbashi
    You can separate the audio track from video and save it to a DVD disc within Premiere Elements but not a CD disc.
    To do save to the audio to DVD disc, you do not have to separate linked audio video, just use the export Publish+Share/Computer/Audio and set Presets to the wanted format (AAC, AIFF, MP3, or Windows Waveform (WAV).
    You will not see Audio in the choices since it is at the bottom of the list of choices under Publish+Share/Computer/. You will need to use the thin scroll bar to the right of the choices to scroll to it.
    If you need information on selective export of Timeline content when dealing with more than just this one file on the Timeline, please let us know. If you are trying to produce a CD for listening in car or CD player elsewhere, please let us know.
    Looking forward to learning of your results.
    Thank you.
    ATR

  • How to access private attribute of a class from its Friend Class

    Hi Experts ,
    I am coding in Method (DO_SAVE) of class /BOBF/CL_TRA_TRANSACTION_MGR.
    I need to access private variable ( MO_BOPF) of class /BOBF/CL_TRA_SERVICE_MGR ( Friend of /BOBF/CL_TRA_TRANSACTION_MGR ).
    Please help me to understand how can i access private attribute of one class from its friend class.
    Regards- Abhishek

    Hi Reny,
    You should be able to access by creating object of friend class.
    Sample:
    data lo_frnd     TYPE REF TO  /BOBF/CL_TRA_SERVICE_MGR.
    data lo_compl  type REF TO /BOBF/IF_TRA_TRANS_MGR_COMPL.
       create OBJECT lo_frnd
         exporting
                   iv_bo_key = '111'
                   IO_COMPL_TRANSACTION_MANAGER = lo_compl.
    "access the private object of friend class
       clear lo_frnd->MO_BOPF.
    Note: need to provide iv_bo_key & IO_COMPL_TRANSACTION_MANAGER while creating object.
    Hope this helps you.
    Regards,
    Rama

  • How to get HTTP headers from Data Provider Class?

    Hi,
    I'm the beginner in SAP NetWeaver Gateway. Using Service Builder I created CRUD OData web service and implemented CRUD operations in Data Provider Class. Data Provider Class has methods like MYENTITY_GET_ENTITYSET, MYENTITY_GET_ENTITY, MYENTITY_CREATE_ENTITY, MYENTITY_UPDATE_ENTITY. How can I get HTTP headers from the methods of this Data Provider Class?

    You can do so by using the following code in DPC
    Data :  Lo_facade type ref to /IWBEP/IF_MGW_DP_INT_FACADE.
    lo_facade     ?= /iwbep/if_mgw_conv_srv_runtime~get_dp_facade( ).
    lt_client_headers = lo_facade->get_request_header( ).
    Regards,
    Atanu

  • Model provider class and data provider class

    please explain Model provider class and data provider class?

    Hi,
    both MPC and DPC get generated as runtime artifacts.
    MPC - This is used to define model. you can use the method Define to create entity, properties etc using code based implementation. you rarely use MPC extension class.
    DPC - used to code your CRUDQ methods as well as function import methods. you write all your logic in redefined methods of DPC extension class.
    Refer Generated ABAP Classes and Service Registration - SAP NetWeaver Gateway - SAP Library for more information.
    you can also refer my blog Let’s code CRUDQ and Function Import operations in OData service! which will provide you clear idea on how to redefine various CRUDQ methods in DPC extension class.
    Regards,
    Chandra

  • Invoke a method in one class from a different class

    I am working on a much larger project, but to keep this simple, I wrote out a little test that would convey the over all theory of the program.
    What I am doing is starting out with a 2 JFrames and a Class. When the program is launched, the first JFrame opens. In this JFrame is a label and a button. When the button is clicked, the second JFrame opens. This JFrame has a textField and a button. The user puts the text in the textField and presses the button. When the button is pushed, I want the text that was just put in the textField, to be displayed in the first JFrame's label. I am trying to invoke a method in the first JFrame from the second, but nothing happens. I have also tried making the Class extend from JFrame1 and invoke it from there, but no luck. So, how do I invoke a method in a class from a different class?
    JFrame1 (I omitted the layout part. I made this in Netbeans so its pretty long)
    public class NewJFrame1 extends javax.swing.JFrame {
         private NewClass1 nC = new NewClass1();
         /** Creates new form NewJFrame1 */
         public NewJFrame1() {
              initComponents();
              jLabel1.setText("Chuck");
         public void setLabels()
              jLabel1.setText(nC.getName());
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                  
         NewJFrame2 j2 = new NewJFrame2();
         j2.setVisible(true);The class
    public class NewClass1 {
         public static String name;
         public NewClass1()
         public NewClass1(String n)
              name = n;
         public String getName()
              return name;
         public void setName(String n)
              name = n;
    }The second jFrame
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                  
         NewClass1 nC = new NewClass1();
         NewJFrame1 nF = new NewJFrame1();     
         nC.setName(jTextField1.getText());
         nF.setLabels();
         System.out.println(nC.getName());At this point I am begging for help. I have been trying for days to figure this out, and I just feel like I am not getting anywhere.
    Thanks

    So, how do I invoke a method in a class from a different class?Demo:
    public class Main {
        public static void main(String [] args) {
         Test1 t1 = new Test1();
         Test2 t2 = new Test2();
         int i = t1.method1();
         String s = t2.method2(i);
         System.out.println(s);
    class Test1 {
        public int method1() {
         return 10;
    class Test2 {
        public String method2(int i) {
         if (i == 10)
             return "ten";
         else
             return "nothing";
    }Output is "ten".
    Edited by: newark on May 28, 2008 10:55 AM

  • Accessing private attribute of a class from its Friend Class

    Hi Experts ,
    Please help me to understand how can i access private attribute of one class from its friend class.
    I am coding in Method (DO_SAVE) of class /BOBF/CL_TRA_TRANSACTION_MGR.
    I need to access private variable ( MO_BOPF) of class /BOBF/CL_TRA_SERVICE_MGR ( Friend of /BOBF/CL_TRA_TRANSACTION_MGR ).
    Regards,
    Reny Richard

    Hi Reny,
    You should be able to access by creating object of friend class.
    Sample:
    data lo_frnd     TYPE REF TO  /BOBF/CL_TRA_SERVICE_MGR.
    data lo_compl  type REF TO /BOBF/IF_TRA_TRANS_MGR_COMPL.
       create OBJECT lo_frnd
         exporting
                   iv_bo_key = '111'
                   IO_COMPL_TRANSACTION_MANAGER = lo_compl.
    "access the private object of friend class
       clear lo_frnd->MO_BOPF.
    Note: need to provide iv_bo_key & IO_COMPL_TRANSACTION_MANAGER while creating object.
    Hope this helps you.
    Regards,
    Rama

  • Data Access Class Reading a Text File????

    Hi,
    I have created a data access class... and for one of my constructors.. I need to go a text file and get the information : dsn name, username, and password from the file and bring it into the construtor... does anyone know how to do that??
    Thx
    Rich
    Here is my constructor:
    public DataAccess() {
    }

    Define a PropertyManager class where you specify the file and read the parameters? I have a sample I will have searc through my archive.
    Will post if after some time.
    Hope I gave a small spark to ignite.
    Cheers.
    Sekar.

  • Is it possible to invoke a Java class from Data Services 4.0?

    Is it possible to invoke a Java class from Data Services? I have a query transform with a varchar column which I want to run an external java class against to encrypt the string value. In the Management Console, I created an adapter of type TestAdapter and referenced my jar file in the Classpath section, but when I create a Datastore of type Adapter I can't import any functions related to my java class? It seems like I need to create a new Adapter type similar to the TestAdapter with the 'Adapter Class' set to my java class? I can't figure out how to do this - which is the correct approach and is there some documentation available? thanks!

    First u nees to imoprt the class which u are doing right
    then u need to call the function of the class , and then you can put the value in a string .
    DbCon.function()
    String data = DbCon.db;
    where db is a string in DbCon
    Cheers
    Varun Rathore

  • Seperate business logic from application logic

    Hi guys,
    I am looking for a good article explaining the princiaples of seperating between Business Logic & Integartion logic.
    The articale will be used to exlplain the prinicples SAP PI is based on when it comes to integration between 3rd party systems (Non -SAP) missign the application layer and buisness logic.
    If any one has a link to an article as such.
    Will be most appriciated.
    Regards.
    Nimrod Gisis

    It seems that the general rule to making a GUI
    application is to seperate the "Business Logic" from
    the "Presentation Logic". This is absolutely true.
    From this, I'm guessing I'll
    need to package all my GUI stuff together, and all the
    business logic layer stuff together.If you mean the package names and structure then I would had adapted this structure:
    1. I will have a package under which I will put the application common classes and interfaces.
    com.myapp.common.eventhandler.EventHandler (interface)
    com.myapp.common.eventhandler.AbstractEventHandler (default implementation)
    com.myapp.common.form.Form (interface)
    com.myapp.common.form.AbstractForm (default implementation)2. Create for each subject area its own package:
    com.myapp.product.AddNewProductForm
    com.myapp.product.AddNewProdcutEventHandler
    com.myapp.sales.PriceListEeventHandler
    com.myapp.sales.PriceListEeventHandler
    The GUI will then talk to the Biz lay through an
    interface right?As I illustrated through my previous example, you should have common interfaces and you might need to create Abstract classes that encapsulates the common implementation for these interfaces, then for each GUI Form or Web Page you will create its specific implementation class which inherits from the abstract class.
    Finally if you were asking about the deployment packaging:
    1. Create for each EJB its own jar file then bundle these Jar files under one module jar file, which represents the EJB module.
    2.Package the web application (JSP, Servlets, HTML, Images, CSS, and Java script) in one Web module WAR file.
    3. Package your client application module in its own jar file.
    4. Assemble the EJB module Jar, Web module War, and Client module Jar in one J2EE package which will be an EAR file so that your whole package will be assembled in one EAR file at the end.
    Try the "Application Assembly Tool" which comes with WebSphere. It will organize your application and facilitate this kind of integration.
    - Sherif.

  • In imovie how do I seperate all my videos from the photos from iphoto? I have thousands of photos so finding the odd video here or there is like finding a needle in a haystack! Is there a way I can simply import the videos rather than all the photos

    Imovies - how do I seperate the videos from the photos. My library has bundled them all together from iphoto

    One way I was able to do this, was to make a Smart Album in iPhoto, with the rule of showing just the movie files.  This will work, once you know what format the movie files are in.
    In iPhoto, select one of your movies, and right click it.  Look for the option: "Reveal in Finder" or "Show in Finder" (this depends on the version of iPhoto).
    Once you see the file, look for the three letters AFTER the period.  Like this:
    .mov (QuickTime movie)
    .avi  (Uncompressed Windows Video)
    .mpg (MPEG video)
    Back in iPhoto, when you make your Smart Album, set it up like this:
    Once you have it set like this, press RETURN (or click "Ok").
    What you'll see is all the videos that have that file extension (.mov, .avi, .mpg, etc.) listed.  Now the nice thing is this:  Every new movie you add to iPhoto will automatically get listed here, regardless of where in iPhoto they live!
    Integration with iMovie:
    By making this album in iPhoto, when you get to iMovie, you'll be able to see the movies when you select your Videos Smart Album.
    I hope this helps you out.  They have iPhoto and iMovie workshops at Apple Stores that cover this too.  They're free, and you can learn a lot.
    Sincerely,
    Brian K. James

  • How to refresh a JTable of a class from another thread class?

    there is an application, in server side ,there are four classes, one is a class called face class that create an JInternalFrame and on it screen a JTable, another is a class the a thread ,which accept socket from client, when it accept the client socket, it deal the data and insert into db,then notify the face class to refresh the JTable,but in the thread class I used JTable's revalidate() and updateUI() method, the JTable does not refresh ,how should i do, pls give me help ,thank you very much
    1,first file is a class that create a JInternalFrame,and on it there is a table
    public class OutFace{
    public JInternalFrame createOutFace(){
    JInternalFrame jf = new JInternalFram();
    TableModel tm = new MyTableModel();
    JTable jt = new JTable(tm);
    JScrollPane jsp = new JScrollPane();
    jsp.add(jt);
    jf.getContentPane().add(jsp);
    return jf;
    2,the second file is the main face ,there is a button,when press the button,screen the JInternalFrame. there is also a thread is beggining started .
    public class MainFace extends JFrame implements ActionListener,Runnable{
    JButton jb = new JButton("create JInternalFrame");
    jb.addActionListener(this);
    JFrame fram = new JFrame();
    public void performance(ActionEvent e){
    JInternalFrame jif = new OutFace().createOutFace(); frame.getContentPane().add(JInternalFrame,BorderLayout.CENTER);
    public static void main(String[] args){
    frame.getContentPane().add(jb,BorderLayout.NORTH);
    frame.pack();
    frame.setVisible(true);
    ServerSokct ss = new ServerSocket(10000);
    Socket skt = ss.accept()'
    new ServerThread(skt).start();
    3.the third file is a thread class, there is a serversoket ,and accept the client side data,and want to refresh the JTable of the JInternalFrame
    public class ServerThread extends Thread{
    private skt;
    public ServerThread(Sokcet skt){
    this.skt = skt;
    public void run(){
    OutputObjectStream oos = null;
    InputObjectStream ios = null;
    try{
    Boolean flag = flag;
    //here i want to refresh the JTable,how to write??
    catch(){}
    4.second is the TableModel
    public class MyTableModel{
    public TableModel createTableModel(){
    String[][] data = getData();
    TableModel tm = AbstractTableModel(
    return tm;
    public String[][] getData(){
    }

    Use the "code" formatting tags when posting code.
    Read this article on [url http://www.physci.org/codes/sscce.jsp]Creating a Simple Demo Program before posting any more code.
    Here is an example that updates a table from another thread:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=435487

  • Urgent, how to insert un Idoc (already created)  from outside of SAP

    Hi to all,
    I would like to know how to insert an Idoc (alresdy created) from outside of a SAP environnement into SAP.
    I know via the code we20 we could insert an Idoc into SAP, does someone have a file PDF to explique how to do it step by step plz?
    or could you reply it in details step by step?
    caz we are doing a project and we know almost nothing about it, but we need the information urgent.
    Tks in advance

    Hi,
    i think you have missed some of the some of the columns having NOT NULL constraint.ex:Who Columns..
    Please check the same in the table..
    Thanks
    Bharat

Maybe you are looking for

  • Non operational USB ports and stuck on grey apple start up screen

    Two problems 1. USB ports are non operational. I believe I fried them by accident. When hooking up an external USB hub, I may have connected an incorrect power supply. Now the USB ports on the front and back of my tower are non operational/do not wor

  • Time out problem in background

    Hi All, I am facing a problem with a select query while running the report in background (found out while debugging) where as the same select query while running in fore ground works fine.It is getting timed out.If anyone has faced simillar problem c

  • How to assure tht javaw.exe exits from taskbar on application exit

    Hi all, My java application acquires a license when it runs. The problem arises when the application terminates abnormally,sometimes its javaw.exe doesnt stop.This doesnt lead to the release of license by tht application. How can i assure tht the jav

  • Motion 5 Alpha Channel Support

    Does anyone have an answer on what is supported? I know Prores444, but I can get transparency information out of the Animation Codec, but  it results in jerky vision when field based media is imported into Avid.  The file does contain an alpha channe

  • My lock screen button won't work how can I fix this?

    My lock button won't work, every time I click it it won't lock my screen unless I press the button hard enough and or in a weird gesture, how can I fix this where I don't need to struggle locking it?