gothinkster / aspnetcore-realworld-example-app

ASP.NET Core backend implementation for RealWorld
https://realworld.io
MIT License
1.93k stars 548 forks source link

Class vs Namespace #65

Open ryanjerskine opened 5 years ago

ryanjerskine commented 5 years ago

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?

adamhathcock commented 5 years ago

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.

ryanjerskine commented 5 years ago

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.

antonioortizpola commented 5 years ago

I guess you refer to this part:

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

Why internal classes?

adamhathcock commented 5 years ago

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