Skip to content
This repository has been archived by the owner on Oct 18, 2020. It is now read-only.

Validate Namespace organisation #8

Closed
danielpetisme opened this issue Feb 8, 2019 · 6 comments
Closed

Validate Namespace organisation #8

danielpetisme opened this issue Feb 8, 2019 · 6 comments

Comments

@danielpetisme
Copy link
Member

Currently the namespaces are inspired by the Java packages names of JHipster. The namespace organization and naming should follow the .Net convention and culture.

@kbeaugrand
Copy link

Hi Daniel,

I had fork this repository and working on the namespaces from web part.
I'll do a PR as soon as possible.

Regards,

@jdubois
Copy link
Member

jdubois commented Feb 14, 2019

OSS is awesome, this is so cool that JHipster.NET takes off so quickly.

@danielpetisme
Copy link
Member Author

danielpetisme commented Feb 14, 2019 via email

@danielpetisme
Copy link
Member Author

I propose to track the application structure choices here:
The purpose of JHipsterNet is to serve small/Medium applications.
So far, from what I have understood:

The points not clear

  • Controllers for REST API. In Java, we use a web.rest package and Resources. I understood .Net devs only relies on the Controllers concepts but I found controllers in the Areas, Api and Controllers namespace. Identity managemement, health and logs exposition looks a good candidates for the Areas but I've got a mixed feeling spreading controllers in many folders.
  • ViewModels. JHipster Java uses ViewModel to represent data objects only use to interact with the REST API without any data mapping or transformation to domain models (like a json to store a user and password).

@kbeaugrand @Authfix I need your help here!

@Authfix
Copy link
Contributor

Authfix commented Feb 20, 2019

In Asp.net core, everything is a Controller. There is no more distinction (via inheritance or attribute) between an "Api" controller or a "Mvc" controller. Today, I try to have a project Api-oriented (without view engine) and/or Mvc-oriented (with view engine) but not both.

By default, namespaces correspond to the Assembly name plus the folder hierarchy.

That said :

  • Areas exist to allow isolation of functionalities and are mainly used on large applications with large functional requirements. An area is a MVC structure inside the application. For each area, we find the default MVC folders structure Controllers/Views/Models.
    So, It's not an issue to have many Controllers namespace because each area is an MVC structure like a "sub-application". With it, we can easily add security/rules/routing... etc... to an entire part of the application.
    But, as you said, by default, it multiply folders and namespaces (we can use attributes but i'm not going to explain all mechanisms we can use to deal with areas).

Now, regarding JHipster.NET goals, I think usage of areas will add a complexity that is not necessary, especially in an Api-oriented context with Angular/React clients.

  • For ViewModels it's more "opinionated" (I often have this discussion with other developers). For me, ViewModels" are a "Presentation" tool. Unlike DTO which are a "Representation" tool.
    A ViewModel often does the round trip between GET (to create the presentation) and POST/PUT (to return value from the presentation) unlike the DTO who is just a representation of a ressource at a time.

So there is no room in an API-oriented application for ViewModels. But there is a shiny place for ViewModels in an MVC-oriented application (with views like razor pages).

My 2 cts ;)

@danielpetisme
Copy link
Member Author

@Authfix Thanks!
So, to start no Areas and everything is a Controller ✔️
In my first prototype I just mimic the Java jhipster structure view ViewModel.
I would be interested to have @jdubois vision on that point.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants