0

I have a class that represents a process. In this process there are inputs boxes and output boxes.

public class Process
{
    public long ProcessId { get; set; }
    public virtual List<Box> InputBoxes { get; set; }
    public virtual List<Box> OutputBoxes { get; set; }
}

As you know, naming things is one of the hardest things in programming, and in this scenario, I don't know what name I can give to the inverse property:

public class Box
{
    public long BoxId { get; set; }
    public virtual Process ProcessWhereBoxIsInput { get; set; }    /* ugly name */
    public virtual Process ProcessWhereBoxIsOutput { get; set; }   /* ugly name */
}

What is the common way of naming things in scenarios like this?

closed as primarily opinion-based by gnat, Dan Pichelman, user40980, GlenH7, Doc Brown Nov 18 '14 at 17:28

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

2

The rule I use quite often is to remove the plural and the subject from the original property name, then add "to". In your example, I would probably end up with:

public class Box
{
    public long BoxId { get; set; }
    public virtual Process InputTo { get; set; }    /* ugly name */
    public virtual Process OutputTo { get; set; }   /* ugly name */
}

Depending how I plan to use the property (i.e. whether it makes sense grammatically), I might add the obverse entity name back on to the end.

public class Box
{
    public long BoxId { get; set; }
    public virtual Process InputToProcess { get; set; }    /* ugly name */
    public virtual Process OutputToProcess { get; set; }   /* ugly name */
}
  • It did instantly sense to me. Accepted! – sports Nov 17 '14 at 3:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.