Using a single data structure in a desktop application

Hello,
I am programming an application that needs to constantly access a data structure, for instance to add / edit / update / search data. Several graphical user interfaces need to modify this data structure. I was wondering of easy ways to use the data structure throught the whole application. One solution I found was to use the singleton pattern for my data structure, though lots of people have recommended me to avoid using that pattern. What are better ways of accessing that single data structure from all of those GUIs ?
Thank you,
Alfredo

Not that there is anything wrong with a Singleton pattern, but I don't see how it would help you in this case.
Just create the DataStructure and let every GUI that need to use it have a reference to it.

Similar Messages

  • How to use/sync single data (file) across multiple instances of same application

    Currently we have an application (a diagram editor), that have the ability to save and load (serialize) its state in a xml file.
    Now we want this application to behave like Microsoft OneNote application. Where multiple users have the ability to access the same file.
    Later we may also need to enhance with other things like, (1)what is changed and who changed it, (2)option to resolve conflicts if any.
    I came to know about sync framework to resolve this. so far, i have not tried it.
    All i want is,
    Virtually single file should be edited by multiple instances of same application.
    We need a dll (sync framework) that does following
    It takes complete responsibility of file handling.
    Using this dll, each instance of the application will notify their own changes.
    Each instance of the application should have the ability to detect the changes that is recently made (when, who, what are the changes).
    My question:
    Will sync framework be suitable for this requirement?
    If so, is there a demo application that represents this?
    - Jegan

    Seems like I have found the solution.
    In the taskflow there is a property named data-control-scope and I set it to isolated instead of the default (shared) and this seemed to do the trick.
    I can now have two instances of the same taskflow running with different ApplicationModules
    Cheers,
    Mark

  • Clusters as data structures

    I am looking for the best and simplest way to create and manage data structures in Labview.
    Most often I use clusters as data structures, however the thing I don't like about this approach is that when I pass the cluster to a subroutine, the subroutine needs a local copy of the cluster.
    If I change the cluster later (say I add a new data member), then I need to go through all the subroutines with local copies of the cluster and make the edit of the new member (delete/save/relink to sub-vi, etc).
    On a few occasions in the past, I've tried NI GOOP, but I find the extra overhead associated with this approach cumbersome, I don't want to have to write 'get' and 'set' methods for every integer and string, I like being able to access the cluster/object data via the "unbundle by name" feature.
    Is there a simple or clever way of having a single global reference to a data object (say a cluster) that is shared by a group of subroutines and which can then be used as a template as an input or output parameter? I might guess the answer is no because Labview is interpreted and so the data object has to be passed as a handle, which I guess is how GOOP works, and I have the choice of putting in the extra energy up front (using GOOP) or later (using clusters if I have to edit the data structure). Would it be advisable to just use a data cluster as a global variable?
    I'm curious how other programmers handle this. Is GOOP pretty widely used? Is it the best approach for creating maintainable LV software ?
    Alex

    Alex,
    Encapsulation of data is critical to maintaining a large program. You need global, but restricted, access to your data structures. You need a method that guarantees serial, atomic access so that your exposure to race conditions is minimimized. Since LabVIEW is inherently multi-threaded, it is very easy to shoot yourself in the foot. I can feel your pain when you mention writing all those get and set VIs. However, I can tell you that it is far less painful than trying to debug a race condition. Making a LabVIEW object also forces you to think through your program structure ahead of time - not something we LabVIEW programmers are accustomed to doing, but very necessary for large program success. I have use three methods of data encapsulation.
    NI GOOP - You can get NI GOOP from the tutorial Graphical Object Oriented Programming (GOOP). It uses a code interface node to store the strict typedef data cluster. The wizard eases maintenance. Unfortunately, the code interface node forces you through the UI thread any time you access data, which dramatically slows performance (about an order of magnitude worse than the next couple of methods).
    Functional Globals - These are also called LV2 style globals or shift register globals. The zip file attached includes an NI-Week presentation on the basics of how to use this approach with an amusing example. The commercial Endevo GOOP toolkit now uses this method instead of the code interface node method.
    Single-Element Queues - The data is stored in a single element queue. You create the database by creating the queue and stuffing it with your data. A get function is implemented by popping the data from the queue, doing an unbundle by name, then pushing the data back into the queue. A set is done by popping the data from the queue, doing a bundle by name, then pushing the data back into the queue. You destroy the data by destroying the queue with a force destroy. By always pulling the element from the queue before doing any operation, you force any other caller to wait for the queue to have an element before executing. This serializes access to your database. I have just started using this approach and do not have a good example or lots of experience with it, but can post more info if you need it. Let me know.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • Single Tabular structure of boxes for more than one form?

    Hey everone !
      Can i use a Single Tabular structure for more than one form ? Coz i need the same structure for all my forms and its getting really tough to create it for each and every form ?

    Hi Amuktha
    Just Copy Paste yaar
    if you can say exactly with an example wat you are looking for i can give you info more in detail
    Regards
    Vikas

  • Single date dimension while creating Aggregate tables

    hi Guys ,
    I have single date dimension(D1-D) with key as date_id and granularity is day-level. I have fact table(F1-D) which gives daily transactions . Now i created three aggregate tables with F2-M(aggregated to monthly),F3-Q(Aggregated to quarterly),F4-Y(Aggregated to yearly). As I said.I have a single date dimension table with date-id as a key.I have other columns month,quarter,year in Date dimension.
    My question is : Is this single dimension table is enough to create the joins and maintain the BMM layer .I have joined the date_id to all the facts in physical layer. In BMM Layer i have one fact and 4 logical table sources .Ii have created dimension hierarchy on Date dimension and created the logical levels as year ,quarter,month and daily level and also set their respective level keys . Now after doing these i have also set the logical levels to the 4 logical table sources in the fact table.
    Here i am getting an error saying :
    WARNINGS:
    BUSINESS MODEL Financial Model:
    [39059] Logical dimension table D04_DIM_DATE has a source D04_DIM_DATE at level D04_DIM_DATE Detail that joins to a higher level fact source F02_FACT_GL_DLY_TRAN_BAL.F03_FACT_GL_PERIOD_TRAN_BAL
    Can anyone tell me why am i getting this error .

    1) as you suggest, creating mini dimension tables for each level
    3) using views with select distinct x,y,z to model 1) but without the need for phsical tables
    I have thought of these scenarios .But it's just creating a multiple Date Dimension tables with there respective grains if we follow 1 and 3 steps you mentioned.
    But i don't want to create aliases or views either on Datawarehouse or physical layer (Admin tool).Just with using a single Date Dimension table I need to comeup with a solution as mentioned by my Colleagues.
    2) pushing all the calendar attributes into the aggreate table (eg your year aggregate has all the year fields, your month aggregate has all the year fields and all the month fields etc.). Then in BM&M use the aggregate table as a logical table source for the date logical table.
    What do you mean by "pushing all the calendar attributes into the aggreate table".If possible can you eloborate a bit so i can try in this way to get this done .
    One morething .Here What they were saying is .Join the Single Date Dimension to all the 4 fact tables in Physical layer . Then drag all the tables into the BMM layer and create a Dimensional hierarchies for the Date dimension with levels as Year -->Quarter--> Month--> day level. With the Fact tables: Single fact tables with multiple logical table sources .Then we need to set the levels on the respective logical table sources with the desired levels .Say monthly aggregate table--> Month, Quarter Aggregate table--> quarter level in the Contents TAB.
    When i do this I am getting the Warning:
    WARNINGS:
    BUSINESS MODEL Financial Model:
    [39059] Logical dimension table D04_DIM_DATE has a source D04_DIM_DATE at level D04_DIM_DATE Detail that joins to a higher level fact source F02_FACT_GL_DLY_TRAN_BAL.F03_FACT_GL_PERIOD_TRAN_BAL

  • Data Structure Needed

    *** PLEASE DO NOT REPLY TO THIS POSTING UNLESS
    *** YOU KNOW EXACTLY WHAT I AM TALKING ABOUT
    *** AND HAVE SOLUTION AT THE READY.
    *** NO SWING TREE FYIs PLEASE...doesn't apply.
    *** NO UI JAVASCRIPTS .. I HAVE THOSE.
    I need a properly constructed multiway
    (m-way, general, n-ary, etc.) data structure
    implementation that uses non-ui
    dependent/associated classes. This is know as the
    first child/next sibling data structure used in
    Filesystems (similiar to a BTree).
    I am using many delimited strings, similiar to a
    directory/file structure path but the string is a
    software project hierarchy.
    [a string is structured like this]
    root|branch|...|branch|leaf
    [Process]
    1) the strings are fetched from DB by servlet.
    2) servlet feeds strings into data structure
    to eliminate duplicates and place in proper location.
    3) servlet uses contents of data structure to
    construct links that are coupled with the infamous
    ui-tree script.
    If you know your data structures and have an implementation
    that won't take me 6 days to modify for it to work I would
    appreciate your assistance. I am creating on my own as we
    speak but one from a more experienced java programmer would
    be better.
    Thank You,
    Kevin

    Sounds like one hell of a frustrated programmer over there - all those capitals an'all..
    If I understand you correctly, I don't think you'd take six days to implement this; just split your string by the separator;
    String[] split(String path, char sep, char esc) {
      String[] result = new String[0];
      int o = 0;
      int i; for (i=0; i<path.length(); ++i) {
        char c = path.charAt(i);
        if (c == esc) {
          ++i;
          continue;
        if (c == sep) {
          String substring = path.substring(o, i);
          String[] newresult = new String[result.length+1];
          System.arraycopy(result, 0, newresult, 0, result.length);
          newresult[result.length] = substring;
          result = newresult;
          o = i+1;
    }Then have a java.util.Hashtable as root, with all names in it pointers to either more Hashtables (nodes), or Strings (leaves). If it really does not get anymore complex than that (data associated with leaves, for example), you don't really have to use anything more complex than 'instanceof' here.
    Then start looping over all your String[] split paths, retrieve all nodes, if it's a String and you have a child for it, then convert it to a Hashtable, it it's a Hashtable trod along, if it isn't there create a String (unless you know you have an extra child, in which case you create a Hashtable).
    When you're ready to retrieve, just enumerate your root Hashtable, casting to String all the keys, examining all the values; if they are Hashtable, then recurse. If they're Strings, do your Thing (TM).

  • Multiple Concurrent Single Data definition

    Hi Folks,
    Am having a requirement,which needs to develop multiple Concurrent Reports using a single Data defintion Templete.
    Kindly suggest me the way to do.
                                                     Thanks in Advance

    But my requirement is to develop single data template(single query) which needs to work for multiple Concurrents.
    Based on the concurrent program Id(available in run time),I am able to change the parameter dynamically.Suggest me the way to do..
    look at http://oracle.anilpassi.com/xml-publisher-concurrent-program-xmlp.html
    data template code "is the short name of the Concurrent program" from above link
    as i said
    imho the best way is to use one data template for one concurrent
    it's easier to maintain
    and changing also
    as idea
    look at concurrent program XDOREPPB Oracle Applications Technical Docs: Calling a XML Publisher report from FND_SUBMIT_REQUEST

  • Constracting an xml book data structure

    I have to construct a book data structure storing detalis about a book, which i parse from a file containing the book in XML format.
    I've done the parser, but i'm trying to figure out what would be the best Class I could use as a Data Structure to store the book.
    I have to store info about the title, the author, chapters, etc etc, as well as the book itself...
    Any suggestions would be very appreciated.
    Thanx.
    P.

    If I understand correctly,
    you have an xml file that describes a book.
    Would it be an option, if you just create an oject Book that has all your necessary fields in it and populate that object with your xml values?
    for ex,
    class Book
    String author;
    String title;
    String[] chapters;
    }

  • Air desktop application: how to make a menu item bold?

    Hi, I'm using Flash CS6 to develop an AIR desktop application for OSX. I've created my menu using NativeMenu and such, but I can't find a way to make the first menu item bold, like a true OSX app. So far the little I've found on this always referred to Flex, not Flash. Any hints?
    Thank you.

    Thank you, kglad.
    I think I forgot to mention I'm building an Application Menu. The NativeMenu contains NativeMenuItems and there is no format property or method that I can see. Also, the name the menu item displays is its label property, which you can set, but it's a string, and I believe the htmlText applies to textfields, right?

  • Getting IStorageFile from a desktop application

    I would like to use Windows.Media.Transcoding.MediaTranscoder from a desktop
    application.  I have most of the pieces in place, but I am stumped by how to handle the files.
    In particular, I can convert the files that exist in one of the KnownFolders directories just fine, but I don't know how to get an IStorageFile to an arbitrary file location.  Most of the online discussion on this topic revolves around the fact that
    Windows Store apps are not permitted to touch arbitrary files.  However since this is a desktop application that restriction shouldn't apply.
    Does anyone know how to get an IStorageFile for an arbitrary file location for a desktop app?

    You're trying to use a sandboxed set of types (for WinRT apps) in a general desktop app. If this is the only problem you run into then count your stars lucky. Personally I would look around for a desktop-specific solution rather than trying to use something
    that seems more inherently for WinRT apps.
    Nevertheless take a look at
    StorageFolder.GetFolderFromPathAsync which returns back a StorageFolder that itself exposes the files within the folder as IStorageFile objects. I've never used this set of types so I cannot confirm whether they'll work for arbitrary paths or only paths
    that are deemed "safe" by the system.
    Michael Taylor
    http://blogs.msmvps.com/p3net

  • Implement a program by using data structure

    i've learn link-list,b-tree,red black tree,hash table. now it's time for me to implement a program using any one of these. i've no idea about how to start, and what kind of program should i write? what kind of program use data structure? i want some simple example program to make me understand. can anyone help me?
    thank 4 u r time,
    makio

    what sort of program do use data structure? let's say
    i want to use binary search on data , how can i?As nasch said: pretty much any program uses data structures.
    Okay, let's say you want to try binary search. You could do that on an array, on a singly linked list, on a doubly linked list, probably on others that I can't think of right now.
    If you just want practice using the data structures you've learned, then why not write a binary search over several different ones? That will give you a feel for how they differ in usage and performance.
    Or, you can just pick any kind of program that interests you. Unless it's trivially small and simple, there will probably be a use for one or more of the data strux you've learned.
    A chat program needs data structures to hold curently connected users, ongoing conversations, maybe a queue for messages waiting to be sent.
    A card game needs to be able to search to see if a given card is in a given hand. Needs to hold all the cards in a deck that has to be shuffled. Dealing is like popping off a stack.
    A database of students and their courses might want to keep something in an ordered tree--by last name for instance.
    What applications interest you?

  • Need help on efficient searches using hashes on large #s of data structures

    I have a massive amount of data and I need a way to access it using generated indexes instead of traditional searching such as binary chop as I require a fast response time.
    I have 100,000 Array data structures each containing roughly 10 to 60 elements. The elements of the Arrays do not store any raw data they just hold references to objects. I have about 10,000 unique objects which are referenced to by the arrays.
    What I need to do is supply a number of objects as the query and the system should return all the arrays which contain two or more different objects from the query.
    So for example>
    Given query objects> &#8220;DER&#8221; , &#8220;ERE&#8221; , &#8220;YPS&#8221;
    and arrays> [DER, SFR, PPR]
         [PER, ERE, SWE, YPS]
         [ERE, PPD, DER, YPS, SWE]     
         [PRD, LDF, WSA, MMD]
    It should return arrays 2 and 3.
    I had a look at hashMaps but I&#8217;m not entirely sure if that&#8217;s what I need.
    Would I need to hash the each Array and then hash the query objects and look for overlaps in the two hashes or something similar?
    Thanks In Advance

    For a single query, it's more efficient to do less work, so don't create intermediate objects, don't create a index of objects to sets of possibles, and stop counting matches when you find enough:.
                    final HashSet<String> querySet = new HashSet<String>(Arrays.asList(query));
                    final Set<String> results = new LinkedHashSet<String>();
                    // find matches using scan of all arrays
                    for (String[] array : data) {
                        int matchCount = 0;
                        for (String elt : array) {
                            if (querySet.contains(elt)) {
                                ++matchCount;
                                if (matchCount >= 2) {
                                    results.add(Arrays.asList(array).toString());
                                    break;
                    }Using random data, 100,000 arrays of selections from a list of 10,000 trigrams, scanning all the arrays takes about as long as the set code, but doesn't require generation of the map, which can take up a lot of memory if you pre-create the sets (I didn't complete a run doing that, although it should be faster to query, it used too much memory and my computer started swapping so I gave up after a few minutes).
    Running queries of size 2 to 25, times in ms:
    linear scan of all arrays in data set:
    elapsed: 2196
    creating index of trigram to arrays containing trigram:
    elapsed: 4635
    query using set union and index lookup:
    elapsed: 2195
    query using direct scan and index lookup:
    elapsed: 164
    So if I was doing one query per dataset, just use a simple scan as above. If you're doing lots on the same dataset, then create a map<String, List<String[]>> to index the arrays, and the lookup will save quite a bit of time.
    Creating the index:.
                dataSets = new HashMap<String, List<String[]>>();
                for (String trigram : trigrams)
                    dataSets.put(trigram, new ArrayList<String[]>());
                for (String[] array : data)
                    for (String trigram : array)
                        dataSets.get(trigram).add(array);Finding matches using scan of arrays with at least one elt in query:.
                    final HashSet<String> querySet = new HashSet<String>(Arrays.asList(query));
                    final Set<String> results = new LinkedHashSet<String>();
                    for (String trigram : query) {
                        for (String[] array : dataSets.get(trigram)) {
                            for (String elt : array) {
                                if (elt != trigram && querySet.contains(elt)) {
                                    results.add(Arrays.asList(array).toString());
                                    break;
                    }

  • Single Date Parameter, but using a date range for selection

    Post Author: fireman204
    CA Forum: Formula
    I'm fairly new to Crystal Reports, so be gentle with me.  I have a report that has 4 parameters.  The report asks for data for a specific month, the YTD data to the end of the selected month, and the same data from the previous year.  It seems there should be a way to enter a single parameter (ie., 2007-4-1), and off that date select all the data for the month, the current year to the end of that month, and then the data from the previous year for the same period.  I know this will be a formula field needed to select the data, but not sure how to get there from here.  Any ideas?  Thanks in advance!

    Post Author: SKodidine
    CA Forum: Formula
    It should be possible for you to create just one parameter to have the user input a single date and then create formulae to create the begin and end dates for the month, YTD and PYTD.  You can then use these formulae for record selection criteria.
    For example, if the user inputs a date of 2007-04-01 for the single parameter then create formulae such as:
    beginmonth
    datevar beginmonth;
    beginmonth := date(year({?My Parameter}),month({?My Parameter}),01);
    endmonth
    datevar endmonth;
    endmonth := cdLastDayOfMonth ({?My Parameter});
    To use the cdlastdayofmonth function, In the formula workshop window, click on "Repository Custom Functions" then under CRYSTAL and DATE right click on cdlastdayofmonth and click on ADD TO REPORT.  Once that is done, then create the above "endmonth" formula.  You should see this new function in your formula workshop window in the FUNCTIONS window under CUSTOM FUNCTIONS.
    beginytd
    datevar beginytd := date(year(currentdate),01,01);
    endytd
    datevar endytd;
    endytd := cdLastDayOfMonth ({?My Parameter});
    beginpytd
    datevar beginpytd := date((year(currentdate)-1),01,01);
    endpytd
    evaluateafter({@endytd});
    datevar endytd;
    datevar endpytd;
    endpytd := date(year(endytd)-1,month(endytd),day(endytd));
    In your record selection criteria, you can use the above formulae like this:
    in {@beginmonth} to {@endmonth}
    or
    in {@beginytd} to {@endytd}
    or
    in {@beginpytd} to {@endpytd};
    This is one way of doing it, perhaps others might pitch in with a more efficient way.

  • Can I automate the creation of a cluster in LabView using the data structure created in an autogenerated .CSV, C header, or XML file?

    Can I automate the creation of a cluster in LabView using the data structure created in an auto generated .CSV, C header, or XML file?  I'm trying to take the data structure defined in one or more of those files listed and have LabView automatically create a cluster with identical structure and data types.  (Ideally, I would like to do this with a C header file only.)  Basically, I'm trying to avoid having to create the cluster by hand, as the number of cluster elements could be very large. I've looked into EasyXML and contacted the rep for the add-on.  Unfortunately, this capability has not been created yet.  Has anyone done something like this before? Thanks in advance for the help.  
    Message Edited by PhilipJoeP on 04-29-2009 04:54 PM
    Solved!
    Go to Solution.

    smercurio_fc wrote:
    Is this something you're trying to do at runtime? Clusters are fixed data structures so you can't change them programmatically. Or, are you just trying to create some typedef cluster controls so that you can use them for coding? What would your clusters basically look like? Perhaps another way of holding the information like an array of variants?
    You can try LabVIEW scripting, though be aware that this is not supported by NI. 
     Wow!  Thanks for the quick response!  We would use this cluster as a fixed data structure.  No need to change the structure during runtime.  The cluster would be a cluster of clusters with multiple levels.  There would be not pattern as to how deep these levels would go, or how many elements would be in each.   Here is the application.  I would like to be able to autocode a Simulink model file into a DLL.  The model DLL would accept a Simulink bus object of a certain data structure (bus of buses), pick out which elements of the bus is needed for the model calculation, and then pass the bus object.  I then will take the DLL file and use the DLL VI block to pass a cluster into the DLL block (with identical structure as the bus in Simulink).  To save time, I would like to auto generate the C header file using Simulink to define the bus structure and then have LabView read that header file and create the cluster automatically.   Right now I can do everything but the auto creation of the cluster.  I can manually build the cluster to match the Simulink model bus structure and it runs fine.  But this is only for an example model with a small structure.  Need to make the cluster creation automated so it can handle large structures with minimal brute force. Thanks!  

  • Is timesten still using T-tree as data structure?

    I just come across this paper - http://www.memdb.com/paper.pdf , this researcher do some experiments and showing that using concurrent B-tree algorithm is actually faster than T-tree operation. How do you think about this paper? Do you think actually he is using a inefficient algorithm to access T-tree? Or, Timesten already know the limitation of T-tree and have changed the internal data-structure?

    Yes, we are aware of the comparisons between T-Trees, concurrent B-trees etc. At the moment TimesTen still uses T-trees but this may change in the future :-)
    Chris

Maybe you are looking for

  • Pcard in combination with catalog

    Hi all, Is there someone who can explain me the process of Pcard purchases in combination with catalogs? I heard that there will be no request and purchase order in SRM for each purchase. There will be a periodic load from the catalog into SAP that c

  • Can't drag Photos

    I've been dragging photos out of iPhoto and into a folder on desktop, but suddenly I cannot.  Why?!  I've tried everything I can think of.

  • Pure AS3 self-preloader

    My project originally had everything on the timeline, but I have since moved all the code to the document class, but some of my assets are still in the library and some of them are embedded. I'm trying to make a self-preloader that doesn't use any ex

  • Where is the workload redistribution link in SRM 7?

    Hi, I can not find the workload redistribution link that I use in srm 5 to change the purchase group of one SC or resdistribute the SC to other User. Is in any role? or is a program or service. Thanks. Alex.

  • Flashplayer Constantly Have To Uninst & Reinst

    Every time I need Flashplayer, The media says I need Flashplayer. I go to the Install Site. It goes through the motions without the download box showing up. It says 9.0.28.0 is Successfully installed. I go back to the media and it still doesn't work.