How to modify code so that it adheres to the Law of Demeter

Posted by guazz on Stack Overflow See other posts from Stack Overflow or by guazz
Published on 2010-04-19T11:23:49Z Indexed on 2010/04/19 11:33 UTC
Read the original article Hit count: 500

Filed under:
|
public class BigPerformance  
{  
    public decimal Value {get;set;}  
}  


public class Performance  
{  
    public BigPerformance BigPerf {get; set};  
}  

public class Category    
{  
    public Performance Perf {get;set; }     
}

If I call:

Category cat = new Cateogry();  
cat.Perf.BigPerf.Value = 1.0;  

I assume this this breaks the LoD?
If so, how do I remedy this if I have a large number of inner class Properties?

© Stack Overflow or respective owner

Related posts about law-of-demeter

Related posts about c#