I have a class that represents a process. In this process there are inputs boxes
ID: 645806 • Letter: I
Question
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?
Explanation / Answer
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 */
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.