Design Patterns. Singleton. Real life examples?

Hello All,
1. 'There is no substitute for experience.' So would it be
possible that you share your experiences by providing an example
of real life application of the Singleton pattern.
2. 1M thanks for all.

I'll give you two Real Life examples in a computer environment:
You can use the singleton pattern wherever you have to share one device (e.g. a DB connection, a serial port or a file access) among multiple instances of a class. So the singleton has the job to control the access to a limited resource.
You can use the singleton pattern also as "Yellow Pages". Assuming you plan a big project with a lot of modules and you don't know at developing time how much and what kind of modules will be on your destination system. So you can use the singleton pattern in a, let's say "Library"-class. Assume that each module will be registered by that library, thus it is possible to perform requests for modules (maybe also by other modules) to that library. The library should exist on a system only once.
I hope these examples helps.
J�rg

Similar Messages

  • Who is using SES in internet? (serching for real-life examples)

    Hi
    Does anybody know internet addresses where can we see and test SES in a production environment? It would be nice to have a "touch & try" example.
    Bye & thanks,
    Aron

    You will be able to see SES in action on Oracle.com & OTN shortly.
    Cheers, OTN

  • PL/SQL website with sample PL/SQL codes from real life examples

    Hi All,
    Can any one guide me and suggest me on the website where they post sample PL/SQL code. Thanks much in advance.
    AL

    Something like this ->
    UPDATE PRODUCT e
    set e.new_id = (
                      SELECT distinct i.id||i.code
                      FROM item i, product pi
                      WHERE i.ccode = '12'
                      AND i.scode = 'ACTIVE'
                      AND i.id IS NOT NULL
                      AND pi.id = i.id
                      AND i.id IN (
                                      SELECT DISTINCT ri.item_id
                                      FROM category ri
                                      WHERE ri.category_code = 'RRR'
                      AND pi.id = e.id
    WHERE e.new_id IS NULL;N.B.: Not tested...
    Please post your table structure. Otherwise it is very difficult to find out the exact reason.
    Regards.
    Satyaki De.

  • Real structures for this design pattern

    Hello , this is my first time posting and I hope to be doing it in the right section. I have a school assignment that says the following: Identify real or abstract structures that could be modeled by the class diagrams represented below: [http://img704.imageshack.us/img704/3523/diagrams.png]
    Upon searching I found out that this is a composite design pattern. I have to implement 2 scenarios for this class system. I was thinking of taking class A (from the uploaded image) to be the Software ( more like a program oriented towards a certain domain like multimedia ), B1,B2 could be an Application/Compiler, and the composite class (D) is an Operating System( because is is usually compiled out of many software (program) pieces) . I want to ask for your opinions on this example because I'm not sure whether this is correct or not. If it isn't could you please give me a real-life example of a correct model ?.

    Roronoa_Zorro wrote:
    Hello , this is my first time posting and I hope to be doing it in the right section. I have a school assignment that says the following: Identify real or abstract structures that could be modeled by the class diagrams represented below: [http://img704.imageshack.us/img704/3523/diagrams.png]
    Upon searching I found out that this is a composite design pattern. I have to implement 2 scenarios for this class system. I was thinking of taking class A (from the uploaded image) to be the Software ( more like a program oriented towards a certain domain like multimedia ), B1,B2 could be an Application/Compiler, and the composite class (D) is an Operating System( because is is usually compiled out of many software (program) pieces) . I want to ask for your opinions on this example because I'm not sure whether this is correct or not. If it isn't could you please give me a real-life example of a correct model ?.Unless your assignment specifically required you to use a computer analogy I would use something else, and even then, I'd still use something else first to understand it better.Since OperatingSystem objects aren't composed with other OperatingSystem objects this doesn't really fit the pattern. Now of course you may be able to run several virtual operating systems inside one but that stretches the example too much for my taste. A directory tree may be seen as an example of the composite pattern -- class A can be a Node, different types of files are specializations of a Node (B1, B2, ...) and are not composable (can't put one file inside another), and a Directory (D) is a Composable specialization of a Node -- it can contain other Nodes. [Edit: I see Saish beat me to the file system analogy]
    With real-world examples you have to be careful as some obvious examples that seem to correspond to computer world, such as containers, boxes, etc, don't actually work, e.g. boxes aren't composable because if box1 fits into box2, then box2 won't fit into box1. Power extension cords and surge protectors are composable extensions of Pluggable class, though not recommended that you take advantage of that feature too much lest you burn your house down. Bags are composable in the real world since they aren't rigid and can be folded up -- class A would just be Object, class B1, B2, etc would be stuff that isn't composable like Apple and Orange, and D would be Bag. You can put Apple, Orange, and Bag instances inside another Bag instance.
    Maybe we should have a contest here -- who can come up with the most creative real-world analogy to the Composite pattern? I know mine are pretty lame.
    Edited by: fromrussiawithjava on Mar 30, 2010 5:36 AM

  • What is a design pattern?

    Howdy,
    I hear a lot of talk of deasign patterns in ABAP...
    My question is what on earth is a design pattern and why/how would it be useful?
    Any ideas anyone

    Hi Steve.
    The good point to start with design patterns is to read book "Design Patterns - Elements of Reusable Object-Oriented Software" by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. It gives strong, consistent understanding of patterns basis with real life examples.
    Short introduction extract:
    "Christopher Alexander says, "Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice". Even though Alexander was talking about patterns in buildings and towns, what he says is true about object-oriented design patterns. Our solutions are expressed in terms of objects and interfaces instead of walls and doors, but at the core of both kinds of patterns is a solution to a problem in a context.
    In general, a pattern has four essential elements:
    The pattern name is a handle we can use to describe a design problem, its solutions, and consequences in a word or two. Naming a pattern immediately increases our design vocabulary. It lets us design at a higher level of abstraction. Having a vocabulary for patterns lets us talk about them with our colleagues, in our documentation, and even to ourselves. It makes it easier to think about designs and to communicate them and their trade-offs to others. Finding good names has been one of the hardest parts of developing our catalog.
    The problem describes when to apply the pattern. It explains the problem and its context. It might describe specific design problems such as how to represent algorithms as objects. It might describe class or object structures that are symptomatic of an inflexible design. Sometimes the problem will include a list of conditions that must be met before it makes sense to apply the pattern.
    The solution describes the elements that make up the design, their relationships, responsibilities, and collaborations. The solution doesn't describe a particular concrete design or implementation, because a pattern is like a template that can be applied in many different situations. Instead, the pattern provides an abstract description of a design problem and how a general arrangement of elements (classes and objects in our case) solves it.
    The consequences are the results and trade-offs of applying the pattern. Though consequences are often unvoiced when we describe design decisions, they are critical for evaluating design alternatives and for understanding the costs and benefits of applying the pattern. The consequences for software often concern space and time trade-offs. They may address language and implementation issues as well. Since reuse is often a factor in object-oriented design, the consequences of a pattern include its impact on a system's flexibility, extensibility, or portability. Listing these consequences explicitly helps you understand and evaluate them."
    Regards,
    Maxim.

  • Design Patterns Web Site

    Hi,
    I was curious what everyone's opinion (or at least those who frequent this forum) was about a website explaining Design Patterns using Java.
    I was thinking about making a site which discusses various design patterns, including real-world analogies (to try and make things simple and clear), and sample code.
    i thought it might be a good idea, b/c I myself am trying to learn about design patterns (including when to use them and when not to use them)....and there is a lot of info on the web, but I learn best by example....so thats wherei got the idea for a straight forward site.
    what are your thoughts? I kind of like the style of O'Reilly's "Head First Design Patterns" as an approach. Let me know what u think..
    peace.
    craig

    wow, thats what i had in mind...and since a lot of the samples are C#...its easy to relate to java.
    thanks

  • Software reuse with Java design patterns

    Anyone have any suggestions on how software can be reused with Java design patterns? Any concrete examples?

    Buy the GoF book. Lot's of examples there.

  • Observer Design Pattern: Looking for redesign ABAP OO code example

    Hello folks,
    I am looking for an example for ABAP OO code that has been redesigned by applying the Observer Design Pattern. I would be very interested in both the code before as well as the code after the pattern is being applied.
    Thanks in advance and kind regards, Alex

    Observer can be implemented using the EVENTS.
    I had recently implemented the observer at one of my client's place. I had screen with so many ALVs. One ALV was kind of editable and other were just showing the information of the current row as well as some total information. So, initially I started with the Main ALV and SUB(1 and 2) for other ALVs. Now, when I need to refresh my ALVs based on the main ALV data, I had to explicitly update the data of the each Sub ALV. The code was kind of static and requirement was not yet fixed.
    Later on we need to add one more ALV on the same screen. It was easy to change the existing method where I was doing the explicit refresh of each ALV. But I thought of using the Events.
    I created an event REFRESH_DETAILS for main ALV. so, when data gets changed (which I was catching by DATA_CHANGED event of ALV), I raise the event.
      RAISE EVENT REFRESH_DETAILS
        exporting new_data = it_Data.
    In Sub ALVs, I created the event handler method to handle the event REFRESH_DETAILS of the main ALV.
      methods: handle_refresh_details
          for event REFRESH_DETAILS of ZCL_MAIN_ALV.
    I also had to register the Handler.
      SET HANDLER me->handle_refresh_details FOR ALL INSTANCES.
    I'll soon write a post on my [ABAP Help blog|http://help-abap.zevolving.com/] with all the details.
    Regards,
    Naimesh Patel

  • Code for singleton design pattern

    Hi,
    This is kalyan. Can u provide code for Singleton design pattern.
    Thanks in Advance

    public class Singleton {
      private Singleton() {
      private static Singleton instance;
      public Singleton getSingleton() {
        if (instance == null) instance = net Singleton();
        return instance;
    }Does it make sense?

  • Facade design pattern example?

    Can someone point me to a LabVIEW example of this OOP design? I am learning OOP in LabVIEW and my task is to create an example program using the facade design pattern. I can't find an example to study.
    Solved!
    Go to Solution.

    I'm interested, too, so I posted a link to your question on LAVA.  There are a lot of discussions of this sort over there.
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • Struts using DAO Design Pattern ..?Please give an example..... URGENT......

    Dear all,
    I have to develop an application in Struts by using DAO design pattern ..........
    Please give an example on Struts using DAO...................
    Thank you
    Please

    I'm glad you asked. It means Read The Flaming Manual. That'd be the struts manual by the way.

  • Any good article on Singleton design pattern recently updated.

    Hi,
    Can anyone suggest me a good article on Singleton design pattern recently updated..?
    Thanks in advance.

    Check out the following Singleton Design Pattern Tutorial
    http://www.beginner-java-tutorial.com/singleton.html

  • What is singleton design pattern

    Hi All,
    Anybody please tell me what is Singleton Design Pattern ?
    What is the right definition of it and where can I get the right information about it.
    Please help and reply soon
    Thanks
    Amitindia

    Not meaning to be arrogant: check the topic "Public singleton". It explains what the singleton pattern tries to achieve and show various ways of creating singleton classes.

  • Examples of the Abstract Factory Design Pattern

    Could someone please give an example about situations in which you would definitly use the Abstract Factory Design Pattern?

    Ok, but they are coupled because Abstract Factory uses Factory methods. Without getting too detailed here, Abstract Factory is useful when you want to swap out entire sets of things (ie. pluggable look and feels). So one subclass of AbstractGUIFactory is MotifGUIFactory while another is WindowsGUIFactory. Your application can gets a specific factory but puts it in an AbstractFUIFactory variable.
    AbstractGUIFactory factory = new WindowsGUIFactory();
    AbstractButton = factory.makeButton();So you can program generically and swap out entire sets of widgets by changing one line of code.
    You should really read Design Patterns by Gamma et al. because it is the definitive book on this topic.

  • Real life technical and business issues--FICO--implementation

    Hello,
    Can someone please give some real-life Technical and Business issues and problems faced by FICO consultant in different-different phases of implementation (asap)? please provide from basic to critical examples? 
    Thanks,
    Amit
    Moderator: Please, respect the rules of the forum

    What you are asking is very project specific.
    Try to do the following:
    1. Ask for the detailed business requirements
    2.  Ask for the design documents. Usually, there will be bunch of documents that got documented when the project team made the design. There must be documents like conceptual / high level design, detailed / low level design, ABAP specifications, report specifications, etc.
    3. The design documents will contian other things, DATA FLOW DIAGRAM. Here in this diagram, you will see where the data comes and how it gets processed and transformed when the data reaches BW.
    4. Ask for your access to the develoment system or the sandbox ( where you can play around without affecting anybody's work).
    5. With the data fliow, you keep reviewing the objects in BW and also in the source system.
    6. Even if you dont get access to dev or sandbox, you cans till view the objects in display mode.
    7. Open the query designer and see how the variables are defined and how formulas are defined and how the restricted key figures are defined.
    8. In production system, go to SM37 and see the jobs that are scheduled.
    9. Try and co ordinate weekly calls with your team members and this is the place where ideas  and problems will be shared.
    If you have specific questions ot need some specific help, dont hesitate to send me a note. My email is [email protected]
    Best luck,
    Ravi Thothadri

Maybe you are looking for

  • Disk Warrior 3.0.3 on OSX 10.6.8?

    I'm having major problems with my iMac (2.4 Ghz Intel Core 2 Duo/2 GB 66 MHz DDR2 SDRAM/running OSX version 10.6.8). Very, very slow to login, hangs up during normal use, slows to a crawl, etc. I did some searching on this forum and have tried some s

  • A World image instead of apple

    Today when I turned on my MacBook i saw a diferent image, was a world blinking twice then the apple appears as usual. What does it mean?

  • Display of Cost Element without Compound

    Hi All I am trying to display Cost Element Key in query without the controlling Area (The compound of Cost Element). What I get for now is for Example "1000/172000008". How do I get rid of the "1000/" so the user will see only the "172000008" ? Thank

  • Saving session state on authentication

    Hey all... In all my applications that interact with each other, I am running an application-level process on authentication which loads two preferences into applicaton-level items. I am seeing different results when jumping into different applicatio

  • How to connect java project to sql server 2008 r2 database

    i want to create an java application which has to create a database and later access it. My problem is that i am not able to connect sql server 2008 r2 database driver on to the netbeans.i have sql server 2008 r2 installed on my system.please suggest