Click here to Skip to main content
15,881,715 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# win forms .net core, user control, array on a dialog. Pin
jkirkerx28-Oct-20 4:49
professionaljkirkerx28-Oct-20 4:49 
GeneralRe: C# win forms .net core, user control, array on a dialog. Pin
OriginalGriff28-Oct-20 5:20
mveOriginalGriff28-Oct-20 5:20 
GeneralRe: C# win forms .net core, user control, array on a dialog. Pin
jkirkerx28-Oct-20 6:19
professionaljkirkerx28-Oct-20 6:19 
GeneralRe: C# win forms .net core, user control, array on a dialog. Pin
OriginalGriff28-Oct-20 6:35
mveOriginalGriff28-Oct-20 6:35 
AnswerI think I have it now Pin
jkirkerx28-Oct-20 5:16
professionaljkirkerx28-Oct-20 5:16 
QuestionLinq To SQL - Join To Latest Record Pin
Kevin Marois27-Oct-20 12:27
professionalKevin Marois27-Oct-20 12:27 
AnswerRe: Linq To SQL - Join To Latest Record Pin
pkfox27-Oct-20 22:15
professionalpkfox27-Oct-20 22:15 
QuestionTemporal Nulls in C# Pin
RandyBuchholz27-Oct-20 3:18
RandyBuchholz27-Oct-20 3:18 
While Nullable Reference Types are great, in some ways they just kick the problem down the road. In a workflow an object may allow a field to be null in an early step, but mandatory in a later step. I call these Temporal Nulls. If we want our objects to accurately reflect the business case/state NRT's introduce a new design decision. How are you approaching this?

Explainer
In Step 1 I am gathering data. Assume I am not creating the object here, just adding Info data.
In Step 2 I am using the data. At this point Info is required data.

The object is the same object from a business perspective, but from a technology perspective it has two states.
// Step 1 State
class MyInfo {
    public InfoData? Info; 
}

// Step 2 State
class MyInfo {
    public InfoData Info;
}

I can think of three general approaches to this.
1. Use multiple classes
2. Use properties or multiple fields
3. Use defaults

The multiple class approach (above) is the most "accurate" but multiplies maintenance and would require different names for the classes (e.g., MyInfo & MyInfoWip).

A property or multiple field approach can look something like this
class MyInfo {
    private _infoData?;
    public InfoData {
        get => _infoData ?? throw ...
        set => _infoData = value
    }
}

The drawback here is that I've basically exchange a null for an error and I don't know until I try to use it.

The defaults approach is getting common using Empty
class MyInfo {
   public InfoData = InfoData.Empty;

   public static InfoData Empty => new InfoData(); 
}

This is just kicking the can. I've replaced a null check with a "Empty Check". It requires defining what Empty values required fields get - new InfoData(emptyValues).

What other approaches come to mind, and how do you normally deal with Temporal Nulls?
AnswerRe: Temporal Nulls in C# Pin
Gerry Schmitz27-Oct-20 4:26
mveGerry Schmitz27-Oct-20 4:26 
AnswerRe: Temporal Nulls in C# Pin
Pete O'Hanlon27-Oct-20 9:55
mvePete O'Hanlon27-Oct-20 9:55 
AnswerRe: Temporal Nulls in C# Pin
BillWoodruff27-Oct-20 10:17
professionalBillWoodruff27-Oct-20 10:17 
QuestionProgramming C # Pin
Immanuel Hitila26-Oct-20 12:10
Immanuel Hitila26-Oct-20 12:10 
AnswerRe: Programming C # Pin
Pete O'Hanlon26-Oct-20 12:16
mvePete O'Hanlon26-Oct-20 12:16 
GeneralRe: Programming C # Pin
Immanuel Hitila26-Oct-20 12:21
Immanuel Hitila26-Oct-20 12:21 
AnswerRe: Programming C # Pin
Richard Andrew x6426-Oct-20 14:06
professionalRichard Andrew x6426-Oct-20 14:06 
AnswerRe: Programming C # Pin
OriginalGriff26-Oct-20 21:14
mveOriginalGriff26-Oct-20 21:14 
QuestionHow to launch a form only once Pin
Ismael_199926-Oct-20 7:57
Ismael_199926-Oct-20 7:57 
AnswerRe: How to launch a form only once Pin
OriginalGriff26-Oct-20 8:35
mveOriginalGriff26-Oct-20 8:35 
GeneralRe: How to launch a form only once Pin
Ismael_199926-Oct-20 10:09
Ismael_199926-Oct-20 10:09 
GeneralRe: How to launch a form only once Pin
OriginalGriff26-Oct-20 21:15
mveOriginalGriff26-Oct-20 21:15 
GeneralRe: How to launch a form only once Pin
Ismael_199927-Oct-20 10:40
Ismael_199927-Oct-20 10:40 
GeneralRe: How to launch a form only once Pin
OriginalGriff27-Oct-20 10:42
mveOriginalGriff27-Oct-20 10:42 
AnswerRe: How to launch a form only once Pin
Gerry Schmitz26-Oct-20 14:50
mveGerry Schmitz26-Oct-20 14:50 
AnswerRe: How to launch a form only once Pin
Richard Deeming26-Oct-20 22:10
mveRichard Deeming26-Oct-20 22:10 
QuestionDesign an elegant solution for choosing a class whose method gets called Pin
Member 1497555126-Oct-20 6:13
Member 1497555126-Oct-20 6:13 

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.