Click here to Skip to main content
15,219,498 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: Code Puzzler: How quickly can you figure out why this acting "weird"? Pin
Jon McKee31-May-18 10:22
professionalJon McKee31-May-18 10:22 
GeneralRe: Code Puzzler: How quickly can you figure out why this acting "weird"? Pin
Richard Deeming31-May-18 10:42
mveRichard Deeming31-May-18 10:42 
GeneralRe: Code Puzzler: How quickly can you figure out why this acting "weird"? Pin
Marc Clifton31-May-18 10:48
mvaMarc Clifton31-May-18 10:48 
GeneralRe: Code Puzzler: How quickly can you figure out why this acting "weird"? Pin
Richard Deeming31-May-18 11:01
mveRichard Deeming31-May-18 11:01 
GeneralRe: Code Puzzler: How quickly can you figure out why this acting "weird"? Pin
Marc Clifton1-Jun-18 1:54
mvaMarc Clifton1-Jun-18 1:54 
GeneralRe: Code Puzzler: How quickly can you figure out why this acting "weird"? Pin
soulesurfer3-Jun-18 21:34
Membersoulesurfer3-Jun-18 21:34 
GeneralRe: Code Puzzler: How quickly can you figure out why this acting "weird"? Pin
englebart4-Jun-18 2:57
professionalenglebart4-Jun-18 2:57 
GeneralRe: Code Puzzler: How quickly can you figure out why this acting "weird"? Pin
jfren4844-Jun-18 8:10
Memberjfren4844-Jun-18 8:10 
It's the assignment of the static member from the instance constructor. HUGE no-no. If you want to make a singleton without using a DI framework, at least make the constructor private and have the static "Context" member be a property that will create a new object if one doesn't exist, and set it to a backing field. Something like this (might need to make Current a method instead of property if you need to pass constructor arguments, but you get the idea):
public class Singleton
{
    private Singleton _current;

    public Singleton Current
    {
        get
        {
            if (_current == null)
            {
                _current = new Singleton();
            }

            return _current;
        }
    }

    private Singleton()
    {
    }
}

GeneralRe: Code Puzzler: How quickly can you figure out why this acting "weird"? Pin
Q The First Timelord4-Jun-18 8:27
MemberQ The First Timelord4-Jun-18 8:27 
GeneralRe: Code Puzzler: How quickly can you figure out why this acting "weird"? Pin
AnotherKen7-Jun-18 20:57
professionalAnotherKen7-Jun-18 20:57 
GeneralMmmm - it' s nice to know that they care about me... Pin
OriginalGriff31-May-18 6:10
mveOriginalGriff31-May-18 6:10 
PraiseRe: Mmmm - it' s nice to know that they care about me... Pin
lopatir31-May-18 6:27
Memberlopatir31-May-18 6:27 
GeneralRe: Mmmm - it' s nice to know that they care about me... Pin
Eddy Vluggen31-May-18 7:54
professionalEddy Vluggen31-May-18 7:54 
GeneralRe: Mmmm - it' s nice to know that they care about me... Pin
OriginalGriff31-May-18 8:00
mveOriginalGriff31-May-18 8:00 
GeneralRe: Mmmm - it' s nice to know that they care about me... Pin
Eddy Vluggen31-May-18 8:16
professionalEddy Vluggen31-May-18 8:16 
GeneralRe: Mmmm - it' s nice to know that they care about me... Pin
OriginalGriff31-May-18 8:22
mveOriginalGriff31-May-18 8:22 
GeneralRe: Mmmm - it' s nice to know that they care about me... Pin
Eddy Vluggen31-May-18 8:38
professionalEddy Vluggen31-May-18 8:38 
GeneralRe: Mmmm - it' s nice to know that they care about me... Pin
Daniel Pfeffer31-May-18 9:30
professionalDaniel Pfeffer31-May-18 9:30 
GeneralRe: Mmmm - it' s nice to know that they care about me... Pin
OriginalGriff31-May-18 9:51
mveOriginalGriff31-May-18 9:51 
GeneralRe: Mmmm - it' s nice to know that they care about me... Pin
Michael Martin31-May-18 11:20
professionalMichael Martin31-May-18 11:20 
GeneralDo you Program in Paragraphs or Sentences? Pin
RandyBuchholz31-May-18 5:57
MemberRandyBuchholz31-May-18 5:57 
GeneralRe: Do you Program in Paragraphs or Sentances? Pin
lopatir31-May-18 6:14
Memberlopatir31-May-18 6:14 
GeneralRe: Do you Program in Paragraphs or Sentances? Pin
S Houghtelin1-Jun-18 1:13
professionalS Houghtelin1-Jun-18 1:13 
GeneralRe: Do you Program in Paragraphs or Sentances? Pin
Maximilien31-May-18 6:33
MemberMaximilien31-May-18 6:33 
GeneralRe: Do you Program in Paragraphs or Sentances? Pin
RandyBuchholz31-May-18 6:46
MemberRandyBuchholz31-May-18 6:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.