instance - definition and analysis

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ice8595
    New Member
    • Mar 2007
    • 13

    #1

    instance - definition and analysis

    Hi there,

    I am doing a programming project in which there is a written essay/report component along with a coding component.

    In my codes, I used instance variables so that I wouldn't keep on recreating new objects. And every time I need to call a Rec object I just use:
    Rec* r = Rec::instance() ;

    Rec* Rec::instance()
    {
    if (!myInstance)
    {
    myInstance = new Rec();
    }

    return myInstance;
    }

    My problem is that I am having trouble putting this all into words savvy enough for the report. I am having trouble explaining exactly what instance objects are and how it is useful in this case, and make it sound clear and understandable at the same time.

    I'm wondering if anyone can help me, whether they know any good resources, or if they are good with words.

    Thanks a bunch
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by ice8595
    Hi there,

    I am doing a programming project in which there is a written essay/report component along with a coding component.

    In my codes, I used instance variables so that I wouldn't keep on recreating new objects. And every time I need to call a Rec object I just use:
    Rec* r = Rec::instance() ;

    Rec* Rec::instance()
    {
    if (!myInstance)
    {
    myInstance = new Rec();
    }

    return myInstance;
    }

    My problem is that I am having trouble putting this all into words savvy enough for the report. I am having trouble explaining exactly what instance objects are and how it is useful in this case, and make it sound clear and understandable at the same time.

    I'm wondering if anyone can help me, whether they know any good resources, or if they are good with words.

    Thanks a bunch
    It looks like you're using the Singleton design pattern. Does that help, or am I mis-interpreting your code?

    Comment

    • ice8595
      New Member
      • Mar 2007
      • 13

      #3
      Originally posted by sicarie
      It looks like you're using the Singleton design pattern. Does that help, or am I mis-interpreting your code?
      wow...thanks so much

      wasn't it silly how I wrote the program without knowing the name of the method i'm using? I took an idea someone suggested to me and just kinda went with it. And I am now stuck on explaining exactly what I did. haha

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        Originally posted by ice8595
        wow...thanks so much

        wasn't it silly how I wrote the program without knowing the name of the method i'm using? I took an idea someone suggested to me and just kinda went with it. And I am now stuck on explaining exactly what I did. haha
        Yeah, I had no idea what they were until I took a grad-level Java programming course. You learn something new every day. They actually help quite a bit, once you start looking at them. )

        Comment

        Working...