Array question

C

CSharper

I was reading Eric Lippert's blog (old one, catching up the missing
ones)
http://blogs.msdn.com/ericlippert/archive/2008/09/22/arrays-considered-somewhat-harmful.aspx

In this blog he was stating the you have to be careful on how to use
Arrays. In the essense the is stating, If you are return an immutable
values then do not use Arrays, Instead use IList, IEnumerable etc., If
you would return Array, it has to create a new array collection and if
they are IList or IEnumerable, it returns the link. Is this a correct
statement?

Thanks,
 
P

Pavel Minaev

I was reading Eric Lippert's blog (old one, catching up the missing
ones)http://blogs.msdn.com/ericlippert/archive/2008/09/22/arrays-considere...

In this blog he was stating the you have to be careful on how to use
Arrays. In the essense the is stating, If you are return an immutable
values then do not use Arrays, Instead use IList, IEnumerable etc., If
you would return Array, it has to create a new array collection and if
they are IList or IEnumerable, it returns the link. Is this a correct
statement?

Apart from subscribing to everything that Peter has said, my other
advice for you is to acquire a copy of the excellent book titled
"Framework Design Guidelines: Conventions, Idioms, and Patterns for
Reusable .NET Libraries", specifically its 2nd edition that
covers .NET 3.5. It's written by MS people who work on .NET, and used
for internal development as well, so it is effectively the "official"
API design guideline. Here's the link to it on Amazon:

http://www.amazon.com/Framework-Design-Guidelines-Conventions-Development/dp/0321545613/

It covers a lot of these API design issues, and, perhaps more
importantly, it has annotations explaining why the guidelines are the
way they are.
 
C

CSharper

Apart from subscribing to everything that Peter has said, my other
advice for you is to acquire a copy of the excellent book titled
"Framework Design Guidelines: Conventions, Idioms, and Patterns for
Reusable .NET Libraries", specifically its 2nd edition that
covers .NET 3.5. It's written by MS people who work on .NET, and used
for internal development as well, so it is effectively the "official"
API design guideline. Here's the link to it on Amazon:

http://www.amazon.com/Framework-Design-Guidelines-Conventions-Develop...

It covers a lot of these API design issues, and, perhaps more
importantly, it has annotations explaining why the guidelines are the
way they are.

Thanks to both for excellent answers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top