aspnetcore-realworld-example-app icon indicating copy to clipboard operation
aspnetcore-realworld-example-app copied to clipboard

Class vs Namespace

Open ryanjerskine opened this issue 6 years ago • 4 comments

Is there a reason that something like Create.cs has Create as a class instead of a namespace? I have also been frequently told that I should follow one class per file. Would it be better to have create be a folder with The command/validator/handler as classes inside of that folder?

ryanjerskine avatar Jan 24 '19 17:01 ryanjerskine

I put tiny classes into one file because it's easier to see them. They're related commands and often dev with them together.

Usually, I do put classes in their own file but trying out something new.

adamhathcock avatar Feb 21 '19 13:02 adamhathcock

I totally get why they are in one file. I was more wondering why you had Create as a class instead of a namespace in that file.

ryanjerskine avatar Feb 21 '19 14:02 ryanjerskine

I guess you refer to this part:

namespace Conduit.Features.Articles
{
    public class Create // Class
    {
        public class ArticleData // Inner class

Why internal classes?

antonioortizpola avatar Sep 04 '19 06:09 antonioortizpola

See my previous answer. I was following a pattern for grouping small classes. May not be always the best decision.

adamhathcock avatar Sep 04 '19 07:09 adamhathcock