Do I need a Singleton pattern for this case

Hello,
I'm writing a game in Java and I have a very simple score manager class which just tracks the points the player so far has. I need to access this class in different pars of my app (gui, game core ...) so I created a singleton class which looks like this
public class ScoreManager {
        private static ScoreManager instance = new ScoreManager();
        private int score = 0;
     private int highScore = 0;
     public static ScoreManager getInstance() {
          return instance;
     public int getScore() {
          return score;
     public int getHighScore() {
          return highScore;
     public void addScore(int scoreToAdd){
          score += scoreToAdd;
          if(score > highScore) {
               highScore = score;
}so far so good ..
I would like to read the "highScore" from a file when the game starts and write it back when the game ends. I added those two methods:
     public void init(File highScoreFile) {
          highScore = readFromFile(highScoreFile);
                score = 0;               
     public void dispose(File highScoreFile) {
               writeToFile(highScoreFile);
     }So basically I call the init() method when the game stars and the dispose() when the game ends.
It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place.
What would be a better way to do this ?
Thanks for your help,
Jesse

safarmer wrote:
You could keep track of the state (initialised, destroyed etc) in the manager and only perform the action if it is an expected state.
private enum State { NOT_INITIALISED, INITIALISED, DESTROYED};
private State currentState = State.NOT_INITIALISED;
// i will leave the rest up to your imagination :) this looks good, thanks
anotherAikman wrote:
>
It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place. And who would that be? You´re the only one using the code, aren´t you?
If not, you could still include in the documentation where to call those methods.
no I'm not the only one working on this. Documentation can be useful but does not prevent calling wrong methods.
YoungWinston wrote:
I don't see any constructor. Usually, a singleton class should have a private one, even if it has no parameters. If you don't have any, Java will create a public no-parameter one as default.ok I forgot the private constructor.
It works but what I don't like is that the init() and dispose() methods are exposed and someone could call them in a wrong place. Then my advice would be not to make them public. After all, your code is the only one calling these methods - yes?yes only the code of the app calls it.
If you are convinced that your game requires one and only one score manager, then a singleton is probably the best way to go.
I'm a little worried about the init() and dispose() methods though, because these suggest state changes, which is unusual for the singleton pattern. You may want to think about synchronizing them.
An alternative might be to use properties to get and store your scores.ok for the synchronization. What would using the properties ? It would be just another type of storage backend and I'd still need to read/write it.
Thanks for your help,
J

Similar Messages

  • Is there a design pattern for this?

    I'm looking for a solution to a design problem I have.
    For a restaurant booking system I need a number of different opening times describing when you can and cannot book. These opening times are essentially Jodatime Period objects. There's a set of opening times spanning a week and these are repeated for every week (a default set of opening times) however it's possible to override these opening times say for a specific day.
    The domain model would be something like a Restaurant class holding 2 Lists of OpeningTime objects one for defaultOpeningTimes and the other for overiddenOpeningTimes the overidden ones get used if they exist for the requested time period. However the database model would be a bit messy as I'd have 2 lists mapping to the same table (OpeningTime). Is that a good idea? Perhaps there's a design pattern for this, if someone could point me in the right direction I'd be very grateful, or perhaps this is the best solution? Thanks!

    jduprez wrote:
    But why do you put the logic in the database too (I'm no DB expert and I didn't know these concepts until I read your post, but that's what a dynamic view based on derived values looks like to me): performance (1 round-trip instead of two)?Hi jduprez. Long time no speakee.
    I guess part of it is that I spent many years as a DBA and modeller, and really appreciate what it's taught me about design. Also, databases are (or should be) designed from the ground up to provide data-directed requests optimally, and include all sorts of nice stuff like transaction handling that aid consistency, as well as speed.
    That said: I HATE SQL. Think Coliseum, with that emblazoned in 60-foot high letters around its walls, and it might come close to just how much I hate that so-called "language". I hate its form; I hate it's inconsistencies; I hate the fact that something like what OP is trying to do is NOT an easy task (and might involve the creation of a table that simply contains Dates, just in order to satisfy Boolean logic).
    However, once you work it out, a database view (at least from the database's standpoint; JDBC I'm not so sure about) is just like any other Table - and that I DO like.
    Programs are good at processing parameterized (ugh) temporal information; databases are good at persistence and high volume. Those two may meet at some point, but I reckon it's going to take another Codd (or Joda) before it does.
    - that's clearer to 90% of the dev team (my biased numbers, based on 50% of Java developers having decent knowledge of SQL and much less than that having the advanced SQL knowledge which I rank your suggestion at)Sounds to me like you'll get the solution that matches the skills you have then. Is that what you really want, if a better one is available?
    - that doesn't require investigating the if of your suggestion (JDBC support)Agreed, but only because my JDBC knowledge isn't what it could be. I'd also be surprised if it doesn't support access to a named view, since they were designed to be equivalent to Tables.
    - the Op is using DAOs, so it's possible, if profiling does show this is hampering performances, to change that with no impact on the client code that calls the DAO.There's no doubt that a database solution is much higher level than a programming one; but, as I said, it's what they were designed to do. And tinkering around with program optimization has the feel of a "hacker's solution" to me. Not that there's any particular problem with that - I do it quite often when I have no control over my source - but I also try to keep in mind what the "actual" problem is.
    Winston

  • A wallet needs to be configured for this instance of Application Express

    hi
    I m very new to APEX. I could create web service client with wsdl. But when service is on https i get message
    "a wallet needs to be configured for this instance of Application Express".
    I have created wallet using OWM (10.2.0.1.0) at location c:\del_sometime
    Using admin i configured APEX instance settings wallet as
    Wallet Path = file:c:\del_sometime
    And checked in database too
    SQL> ALTER SESSION SET CURRENT_SCHEMA = APEX_030200;
    Session altered.
    SQL> SELECT
    2 APEX_INSTANCE_ADMIN.GET_PARAMETER('WALLET_PATH')
    3 from dual;
    APEX_INSTANCE_ADMIN.GET_PARAMETER('WALLET_PATH')
    file:c:\del_sometime
    Any idea whats wrong? I am following steps from http://download.oracle.com/docs/cd/E14373_01/admin.32/e13371/adm_wrkspc.htm#BABFBJEA

    also whe I try following i keep getting error failure to open file. I am on XP and file is present with proper permissions.
    SQL> SELECT utl_http.request('https://support.oracle.com/',null,'file:c:\del_sometime\') from dual;
    SELECT utl_http.request('https://support.oracle.com/',null,'file:c:\del_sometime\') from dual
    ERROR at line 1:
    ORA-29273: HTTP request failed
    ORA-06512: at "SYS.UTL_HTTP", line 1577
    ORA-28759: failure to open file
    ORA-06512: at line 1

  • I have an Intel iMac running OSX 10.6.8. I would like to use Final Cut Pro 10.1. I know I need OSX 10.9 for this. Can I run both 10.6.8 and 10.9 on the iMac ? I do not want to convert completely to 10.9 because of my existing software. Thanks for any help

    I have an Intel iMac running OSX 10.6.8. I would like to use Final Cut Pro 10.1. I know I need OSX 10.9 for this. Can I run both 10.6.8 and 10.9 on the iMac ? I do not want to convert completely to 10.9 because of my existing software. Thanks for any help

    It would depend on how old your IMac is, how mush memory you have, it it can be upgraded by OWC, etc. I have a 2006 Macbook Pro and would NOT put Mavericks on it or espeacially FCP 10.1.1 on it because the most memory it can have is 4 GB. You need at least 8 GB to work with Final Cut Pro 10.1.1. IMHO.
      I would try to find a copy of Final Cut Express perhaps.
      Does this answer your question?

  • Need pl/sql stmnts. for this simple logic

    Hi,
    I need PL/SQL program for this simple logic i am doing mistake somewhere unbale to trace
    out ..
    select * from GSR03_PO_DTL;
    PO_NUM
    L53177000 -- > no changes reqd (only one entry with new format)
    L00041677 --> to be updated to L41677000(only one entry with OLD format)
    L43677000 -- > no change reqd (exists one row with new format and old format like below)
    L00043677 -- > to be deleted this is old format (and new format like above already exists)
    EX:
    L00012345 --- old format
    L12345000 --- new format
    Hope question is clear. I written the following program.
    update is working fine but delete is not working.
    Please help.
    Thanks in Advance
    Devender
    declare
    Cursor c_test is
    (select po_num from GSR03_PO_DTL);
    BEGIN
    FOR r_test in c_Test
    LOOP
    dbms_output.put_line (r_test.po_num);
    IF ('L'||substr(r_test.po_num,5,5)) = ('L'||substr(r_test.po_num,2,5)) then
         dbms_output.put_line ('delete stmnt');
    END IF;     
    EXIT WHEN c_test%NOTFOUND;
    END LOOP;
    FOR r_test in c_Test
    LOOP
    IF r_test.po_num like 'L000%' then
    IF ('L'||substr(r_test.po_num,5,5)) is not NULL then
         update GSR03_PO_DTL set PO_NUM = 'L'||substr(po_num,5,5)||'000'
         where po_num like 'L000%' ;
         dbms_output.put_line ('update stmnt');
    END IF;     
    END IF;
    END LOOP;
    END;
    *********************

    No need for PL/SQL, man.
    SQL> SELECT po_no FROM po1
      2  /
    PO_NO
    L53177000
    L00041677
    L43677000
    L00043677
    SQL> UPDATE po1 y
      2  SET    y.po_no = 'L'||substr(y.po_no,5,5)||'000'
      3  WHERE  y.po_no LIKE 'L000%'
      4  AND    NOT EXISTS ( SELECT null FROM po1 x
      5                      WHERE x.po_no =  'L'||substr(y.po_no,5,5)||'000')
      6  /
    1 row updated.
    SQL> DELETE FROM po1 y
      2  WHERE  y.po_no LIKE 'L000%'
      3  AND    EXISTS ( SELECT null FROM po1 x
      4                  WHERE x.po_no =  'L'||substr(y.po_no,5,5)||'000')
      5  /
    1 row deleted.
    SQL> SELECT po_no FROM po1
      2  /
    PO_NO
    L53177000
    L41677000
    L43677000
    SQL> Cheers, APC

  • Regex Pattern For this String ":=)"

    Hello All
    True, this isn't the place to ask this but here it is anyway, if you can help please do.
    Can anybody tell me the regex pattern for this String:
    ":=)"
    Thanks
    John

    Yep, cheers it's ":=\\)"
    public class Test {
         public static void main( String args[] ) {
              String s = "one:=)two:=)three:=)four";
              String ss[] = s.split( ":=\\)" );
              for( int i=0; i<ss.length; i++ )
                   System.out.println( "ss["+i+"] = {" + ss[i] + "}" );
    }resulting in:
    ss[0] = {one}
    ss[1] = {two}
    ss[2] = {three}
    ss[3] = {four}

  • HT4972 i am trying to download some apps onto my iphone 3gs and it keeps saying i need to update it for this but ive trying and there is no update option on the phone or through itunes, it keeps saying its up to date, can anyone help please?

    i am trying to download some apps onto my iphone 3gs and it keeps saying i need to update it for this but ive trying and there is no update option on the phone or through itunes, it keeps saying its up to date, can anyone help please?

    Would this matter then? can you not update the 3g to the lastest software?

  • If i were to get this computer would i need a new network for this or what accessories  would i need?

    If i were to get this computer would i need a new network for this or what accessories  would i need?

    If you have WiFI which is not something extremely specific, and I believe it is not - you are fine with network, just go and buy you a computer and enjoy.

  • Need to find table for dispute case attachments in service for objects

    Hi All,
    I have a requirement where i need to find some tables which will hold details of dispute case attachments. After a dispute case is created using UDM_DISPUTE transaction, the concerned person may open that dispute case and can attach some documents/any attachments using services for objects icon at the top left corner of the screen. All i want to know is, in which table (tables related to service object) this attachment details will be stored. Even if the attachments details are stored in service objects related tables, there should be some link for this attachment and dispute case. Please let me know if any of you have some pointers and it would be highly appreciated.
    Thanks in advance,
    Srilakshmi.

    Hi a®s,
    Thanks for your reply. An entry is getting created in this table SRGBTBREL whenever an attachment/URL/notes is attached to a dispute case using services for object and the link between this table and dispute case table SCMG_T_CASE_ATTR is INSTID_A. This field holds the value of CASE GUID from SCMG_T_CASE_ATTR. Now my requirement is whenever an attachment is present in a dispute case i need to set a customized checkbox present in UDM_DISPUTE screen so that when an user opens the dispute case he/she can understand some attachment is present for this case by seeing the checkbox. I found the SCMG* badi's are not helpful to set the checkbox. Please let me know if you have any idea on how to implement it.
    Thanks in advance,
    Srilakshmi.

  • What is the best design pattern for this problem?

    No code to go with the question. I am trying to settle on the best design pattern for the problem before I code. I want to use an Object Oriented approach.
    I have included a basic UML diagram of what I was thinking so far. 
    Stated simply, I have three devices; Module, Wired Modem, and Wireless Modem.
    In the Device Under Test parent class, I have put the attributes that are variable from device to device, but common to all of them.
    In the child classes, I have put the attributes that are not variable to each copy of that device. The attributes are common across device types. I was planning to use controls in the class definition that have the data set to a default value, since it doesn't change for each serial number of that device. For example, a Module will always have a Device Type ID of 1. These values are used to query the database.
    An example query would be [DHR].[GetDeviceActiveVersions] '39288', 1, '4/26/2012 12:18:52 PM'
    The '1' is the device type ID, the 39288 is the serial number, and the return would be "A000" or "S002", for example.
    So, I would be pulling the Serial Number and Device Type ID from the Device Under Test parent and child, and passing them to the Database using a SQL string stored in the control of the Active Versions child class of Database.
    The overall idea is that the same data is used to send multiple queries to the database and receiving back various data that I then evaluate for pass of fail, and for date order.
    What I can't settle on is the approach. Should it be a Strategy pattern, A Chain of Command pattern, a Decorator pattern or something else. 
    Ideas?

    elrathia wrote:
    Hi Ben,
    I haven't much idea of how override works and when you would use it and why. I'm the newest of the new here. 
    Good. At least you will not be smaking with a OPPer dOOPer hammer if I make some gramatical mistake.
    You may want to look at this thread in the BreakPoint where i trie to help Cory get a handle on Dynamic Dispatching with an example of two classes that inherit from a common parent and invoke Over-ride VIs to do the same thing but with wildly varying results.
    The example uses a Class of "Numeric"  and a sibling class "Text" and the both implement an Add method.
    It is dirt simple and Cory did a decent job of explaining it.
    It just be the motivation you are looking for.
    have fun!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Need PL/SQL code for this

    Hi,
    I need a PL/SQL code for this one...
    Let me know if something is not clear...
    1) The table CLOB_CLOBJECT_CDA has the columns described below...
    Explaining only those fields which are important in this context
    -- CDA_STEP_ID : Basically a Sequence
    -- CLOBJECT_SOURCE1_ID : Every id has got a set of records
    -- CLOBJECT_SOURCE2_ID : Every id has got a set of records
    -- LVL : There are total 8 levels..
    This is the main aim :
    1) There are total 16 million rows..(limited to 10 rows here)
    2) We need to go through level by level (LVL column) & insert the intersection records (CLOBJECT_SOURCE1_ID intersect CLOBJECT_SOURCE2_ID)
    into another table...but this is how it goes..
    Level (LVL column) 3's basically have CLOBJECT_SOURCE1_ID as level (LVL column) 2 CDA_STEP_ID's..
    (consider the statement --** where CLOBJECT_SOURCE1_ID = 285 which is same as 1st insert statement step id)..
    The above process goes for next levels until 8..(so have to use loops)
    So for ex :
    We go through the first insert statement and insert the insertion records only when both CLOBJECT_SOURCE1_ID & CLOBJECT_SOURCE2_ID has got records ..
    If we don't find any records for both of them we should skip the corresponding step id when we go to the next levels...
    Let's go through the 1st insert statement...
    -- We have CDA_STEP_ID = 285 & two sources CLOBJECT_SOURCE1_ID as 19 & CLOBJECT_SOURCE2_ID as 74...
    -- We see the table CLOBJECT_COUNTS & check whether we have counts for both 19 & 74 ..(In fact we insert counts into this table only if they have records)
    -- If so, we insert the intersection records into CDA_MRN_RESULTS ( we do have counts for both of them..) with CDA_STEP_ID 285...
    -- Then we insert the step id which is 285 along with the count into CLOBJECT_COUNTS..
    Let's go through another insert statement...
    -- Consider CDA_STEP_ID = 288 which has two sources CLOBJECT_SOURCE1_ID as 19 & CLOBJECT_SOURCE2_ID as 92...
    -- We see the table CLOBJECT_COUNTS & check whether we have counts for both 19 & 92 ..(we have records for 19 but not for 92)
    -- So we should not proceed with this..& also skip all those records (future records with increasing levels..basically level 3's) which have got 288 as CLOBJECT_SOURCE1_ID..
    (As said earlier that the present CDA_STEP_ID will always be CLOBJECT_SOURCE1_ID in the next level)...
    I wrote the following code which is after the statement...
    Let me have the create & insert statements here..
    create table CLOB_CLOBJECT_CDA
        CDA_STEP_ID           NUMBER,
        CDA_ID                NUMBER,
        CDA_SEQ_NUMBER        NUMBER,
        CLOBJECT_SOURCE1_TYPE VARCHAR2(3000),
        CLOBJECT_SOURCE1_ID   NUMBER,
        CLOBJECT_OPERATOR     VARCHAR2(3000),
        CLOBJECT_SOURCE2_TYPE VARCHAR2(3000),
        CLOBJECT_SOURCE2_ID   NUMBER,
        LVL                   NUMBER
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (285, 285, 1, 'CLOBJECT', 19, 'INTERSECT', 'CLOBJECT', 74, 2);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (286, 286, 1, 'CLOBJECT', 19, 'INTERSECT', 'CLOBJECT', 75, 2);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (287, 287, 1, 'CLOBJECT', 19, 'INTERSECT', 'CLOBJECT', 91, 2);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (288, 288, 1, 'CLOBJECT', 19, 'INTERSECT', 'CLOBJECT', 92, 2);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4869, 4869, 1, 'CDA_STEP', 285, 'INTERSECT', 'CLOBJECT', 91, 3);  -- **
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4870, 4870, 1, 'CDA_STEP', 285, 'INTERSECT', 'CLOBJECT', 92, 3);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4871, 4871, 1, 'CDA_STEP', 285, 'INTERSECT', 'CLOBJECT', 93, 3);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4880, 4880, 1, 'CDA_STEP', 286, 'INTERSECT', 'CLOBJECT', 91, 3);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4881, 4881, 1, 'CDA_STEP', 286, 'INTERSECT', 'CLOBJECT', 92, 3);
    insert into clob_clobject_cda (CDA_STEP_ID, CDA_ID, CDA_SEQ_NUMBER, CLOBJECT_SOURCE1_TYPE, CLOBJECT_SOURCE1_ID, CLOBJECT_OPERATOR, CLOBJECT_SOURCE2_TYPE, CLOBJECT_SOURCE2_ID, LVL)
    values (4882, 4882, 1, 'CDA_STEP', 286, 'INTERSECT', 'CLOBJECT', 93, 3);
    create table CDA_MRN_RESULTS
       CDA_STEP_ID      NUMBER,
      MRN              NUMBER,
      INSERT_DATE_TIME DATE
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (19, 1, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (19,  2, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (19,  3, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (74,  1, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (74,  2, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (74,  4, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (75,  1, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (75,  2, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (75,  6, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (91,  2, to_date('19-10-2011', 'dd-mm-yyyy'));
    insert into cda_mrn_results (CDA_STEP_ID, MRN, INSERT_DATE_TIME)
    values (91,  3, to_date('19-10-2011', 'dd-mm-yyyy'));
    create table CLOBJECT_COUNTS
      CDA_STEP_ID    NUMBER,
      CLOBJECT_COUNT NUMBER,
      DATE_TIME      DATE
    Insert into CLOBJECT_COUNTS values (19,3, to_date('19-10-2011', 'dd-mm-yyyy'));
    Insert into CLOBJECT_COUNTS values (74,3, to_date('19-10-2011', 'dd-mm-yyyy'));
    Insert into CLOBJECT_COUNTS values (75,3, to_date('19-10-2011', 'dd-mm-yyyy'));
    Insert into CLOBJECT_COUNTS values (91,2, to_date('19-10-2011', 'dd-mm-yyyy'));The output goes into two tables...
    CDA_MRN_RESULTS : O/p of intersection records between source1 & source2 id
    CLOBJECT_COUNTS : Step id with counts ...(useful for skipping next level step id's if either of source id has "0" counts)
    Any help is appreciated..
    Thanks..

    I tried to code this..but looping takes a lot of time..I want to skip certain rows where source1_step_id & source_2_step_id are not in clobject_counts table as we proceed to the next levels..Not sure how to skip the rows..
    declare
    cursor c1 (p_level varchar2 ) is
      Select * from clob_clobject_cda
        where lvl = p_level    ;
       TYPE V_TT IS TABLE OF C1%ROWTYPE INDEX BY PLS_INTEGER;
        L_TT V_TT;
        v1 number;
        v2 number;
        v_step_id number;
        v_operator varchar2(100) := '';
    begin
    for i in 2..8 loop
      open c1(i);
      LOOP
           FETCH C1 BULK COLLECT INTO L_TT LIMIT 500;
            FOR indx IN 1 .. L_TT.COUNT
             LOOP
               v1 := L_TT(indx).clobject_source1_id;
               v2 := L_TT(indx).clobject_source2_id;
               v_step_id := L_TT(indx).cda_step_id;
               v_operator := L_TT(indx).clobject_operator;
      Execute Immediate ('Insert into cda_mrn_results Select --+ parallel (cm 128)
                                                      distinct ' || v_step_id || ', mrn, trunc(sysdate) dt from cda_mrn_results  cm
                        where cda_step_id = ' || v1 || '
                        and   cda_step_id in (Select cda_step_id from clobject_counts) ' ||
         v_operator ||
                    '  Select --+ parallel (cm 128)
                                                      distinct ' || v_step_id || ', mrn, trunc(sysdate) dt from cda_mrn_results  cm
                        where cda_step_id = ' || v2 || '
                        and   cda_step_id in (Select cda_step_id from clobject_counts)  ' );
    Insert --+ Append
           into clobject_counts Select cda_step_id, count(distinct mrn),
                       insert_date_time dt from cda_mrn_results  where cda_step_id =  v_step_id   group by cda_step_id,insert_date_time;
       COMMIT;                    
             END LOOP;
           EXIT WHEN L_TT.COUNT = 0;
         END LOOP;
      CLOSE C1;
    End Loop;    
    Commit;
    End;

  • Do I use the Brdige pattern for this problem ?

    Hello
    I'm making a music mixer for mobile phones. For the canvas, i divided it up in tiles, to fill
    up with .png images if you want to place a sample in that specific tile. But if you have a phone with no colors and your screen is not big enough, the image is almost all black. So I want to create a different class, to only show a letter or a simple symbol if you can't handle the .png well.
    I read about the bridge pattern, where you encapsulate the implementation in an abstract class and seperate it from the base class with the abstractions. Should I use this pattern for my problem ? I have some doubt because I have multiple implementations (color vs non-color) but I don't have multiple abstractions (a tile to fill up with a symbol or picture).
    Are there other patterns that are more suited for my problem ?
    What about the implementation? Should I see the implementation as only producing the image or symbol, or should i see it as the whole canvas, with the tile system?
    For example, now the tiling looks good on most of the targeted phones. But what if the next generation of mobile phones has a screen with very different dimensions. Wouldn't it be better to incorporate this also in the implementation ?
    Thanks

    What are you trying to do when you say "When I put the password for my apple ID into icloud- it keeps reverting to another password"?
    Where are you doing when you try to enter your password?

  • May I make a singleton pattern like this

    as well know, singleton pattern in java always like the codes below:
    public class ClassicSingleton {
    private static ClassicSingleton instance = null;
    protected ClassicSingleton() {
    // Exists only to defeat instantiation.
    public static ClassicSingleton getInstance() {
    if(instance == null) {
    instance = new ClassicSingleton();
    return instance;
    but, when I read the java non-static initialization block section, I had an new idea about a this pattern. how about like this:
    public class ClassicSingleton {
         private static ClassicSingleton instance = null;
         protected ClassicSingleton() {
              // Exists only to defeat instantiation.
         static{
              instance = new ClassicSingleton();
         public static ClassicSingleton getInstance() {
              return instance;
    or like this
    public class ClassicSingleton {
         private static ClassicSingleton instance = null;
         protected ClassicSingleton() {
              // Exists only to defeat instantiation.
              instance = new ClassicSingleton();
         public static ClassicSingleton getInstance() {
              return instance;
    could anybody here tell me what's the different? thanks.

    I usually do something like this:
    public class ClassicSingleton {
      private static ClassicSingleton instance = new ClassicSingleton();
      private ClassicSingleton() {
        try{
          /* Construction logic here. */
        }catch(Exception e){
          /* Something bad happened, decide what to do, like set a flag indicating singleton isn't valid. */
      public static ClassicSingleton getInstance() {
        return instance;
    }

  • Do I need to use GREP for this?

    I have set up my TOC for my book just fine. In my Contents, the headings from each chapter are pulled in and used as the entries for the TOC, then followed by its page number.
    I would like to add a word (the word "Chapter") before each numbered contents entry. Would I use GREP styles for this?
    I'm using CS5.
    Thank you!

    You can create an autonumbered list format that includes text like "Chapter " along with numbers, for the TOC paragraph style, so no scripting needed. Search Google for terms like "InDesign numbered list format text," without quotes for details.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices
    cc2545 wrote:
    I have set up my TOC for my book just fine. In my Contents, the headings from each chapter are pulled in and used as the entries for the TOC, then followed by its page number.
    I would like to add a word (the word "Chapter") before each numbered contents entry. Would I use GREP styles for this?
    I'm using CS5.
    Thank you!

  • Do I need a web service for this?

    Hi,
    Very short question but would like to know what options I have! I want to send an XML file to the server and depending on what�s in that XML file I receive another XML file, which contains the result of my query. The reason for this is because I want to use the same exact backend from different user interfaces (example swing and html).
    I believe that this can be done only with XML Web Services, but that is because I have only been exposed to that technology!! Is there some other technology? With XML web services you need to have an Application Browser.
    I also thought of maybe using Sockets. A connection would be made with that socket, send the XML and wait for the XML result to arrive.
    Anyways which option do you people think is best, and in case of Web Services, which framework / technology do you use?
    Thanks and Regards,
    Sim085

    Hi,
    There are really a lot of ways to exchange information (in XML) in a client and server setup. As you have suggested, either socket or web service will do.
    In my opinion, I would strongly suggest web service.
    Reason as follows:
    1) web service uses a standard format of exchanging information. Thus it's always a better approach to stick to standards as it will allow portability.
    On the other hand, if socket were to use, you have to define your own set of DTD, which implies what whoever wishes to understand your XML data has to have the DTD. This will not be an issue with web service.
    2) As technology is moving towards SOA ( Service Oriented Architecture ), which heavily relies on web service, developing your application with web service will allow your application to leverage on the architecture in the future.
    3) web service is language/OS independent.
    For implementation of web services, a few possible ways:
    - Some developer tools has good tools for webservice, for example, weblogic do has some useful libraries.
    -Another useful library is the Axis.
    Still, the above may not always be the best choice.
    Cheers

Maybe you are looking for

  • Images not displaying in  LG Mobile (G7100)

    hello, Iam doing an appplication in that i assign a particular image for each key from array of image. The display is OK in Emulators nokia 40(7210) as well as 60 series, but while run with LG G7100 The image is not displayed. what is the problem, ho

  • Ibook clamshell indigo won't go into sleep

    When I close the lid of my ibook clamshell it wont go into sleep. I tried going into system preferences and looking at energy saver and display, but Icouldn't find out how to make it go into sleep when I close the lid. Any suggestions will be appreci

  • Automating creation of the package and feature GUID

    Hi Folks, Is there any way  to do automation process to  changing the GUID while creating a wsp. (Visual studio)  Please let me know and assist me,if  have any material available  about automating creation of the package and feature GUIDs. Thanks,

  • Mystery posterization in RAW images

    So I was reviewing some RAW files from my holiday photos in Bridge, and I bumped some keys in the bottom left area of my keyboard and ever since, every time I left-click on a thumbnail, the thumbnail changes. It's as if the RAW settings are being alt

  • IPhoto v7.x (iLife 08) RAW workflow

    I'm looking for some opinions on a workflow here. I have an Olympus E-510 and shoot in RAW. For my amateur needs, iPhoto's editing tools are sufficient and I like iPhoto's library characteristics. I import the Oly RAW files and then edit as needed wh