Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a class created in some namespace, like SomeNameSpace.SubNameSpace.StaticClassName

Here is a code snippet from other code file where I want to use this class many more times, so I created a property in the code file like this

//Just to provide an Alias for long name "SomeNameSpace.SubNameSpace.StaticClassName.PropertyName"
public StaticClassName ServerProxyAlias
        return SomeNameSpace.SubNameSpace.Instance.PropertyName;
        SomeNameSpace.SubNameSpace.Instance.PropertyName = value;

Is there any problem in doing like this ?

share|improve this question
Can't you just put a some sort of alias (e.g., in C# it would be using SomeNameSpace.SubNameSpace) at the top of any files that need the property (and that are outside of SomeNameSpace.SubNameSpace) and then use StaticClassName.PropertyName ? – Brian Jul 18 '12 at 13:55
are you aware about Law of Demeter aka "Don't talk to strangers"? The fundamental notion is that a given object should assume as little as possible about the structure or properties of anything else (including its subcomponents).... – gnat Jul 18 '12 at 16:38
Don't see any reason as to why this should be down voted. Although I really don't like the question I will +1 to compensate. – Apoorv Khurasia Aug 12 '12 at 12:18
up vote 5 down vote accepted

I think it's about consistency as much as readability. Other developers may miss the fact that you implemented a "proxy property" and still refer to SomeNameSpace.SubNameSpace.Instance.PropertyName directly.

Then you end up with code where sometimes ServerProxyAlias is used and sometimes isn't - even in the same method - and it's not obvious they're the same thing, lest one actually looks up how ServerProxyAlias is implemented.

I'm not saying it's a major problem, but you ask about any problems with your approach. Well, that's one that comes to my mind.

share|improve this answer

Referring the question in the title, it costs you as much as invoking a method does. Java's equivalent of properties for example would be getters and setters.

share|improve this answer

So you are creating a class for the sole purpose of being able to use a shorter name? Don't you have enough classes in your system already? Good software developers work hard to make their system easier to understand. You seem to be working hard to make it more convoluted and difficult to understand.

share|improve this answer

There's no problem with this code whatsoever.

As long as the actual PropertyName doesn't invoke a long running process then it should be OK.

However, you should really access the property directly. I don't see what the problem is with using the full name.

share|improve this answer
Problem comes when we change the Name or Namespace, however we can do a Re-factoring using VS. And also there will Long names seen in the code which disturbs me :) – Sreekumar Jul 18 '12 at 13:29

As mentioned, it will not make difference. Because once code is compiled into IL it will have almost same hit on performance. Maybe there would be only minor (nano-seconds) difference in compile time.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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