SAFE-Stack / SAFE-template

dotnet CLI template for SAFE project
MIT License
282 stars 88 forks source link

Remove Shared namespace #425

Closed isaacabraham closed 3 years ago

isaacabraham commented 3 years ago

Do we really need Shared as a namespace? Why not just leave that a level up? If the user wishes, they can prefix everything with e.g. ProjectName and be done with it.

theimowski commented 3 years ago

image If you remove top level namespace then you need to make module top-level, so we'd need to make e.g. Route top-level module

isaacabraham commented 3 years ago

You can put it in the global namespace?

theimowski commented 3 years ago

Oh I didn't know you can do that! So literally we'd have something like following?

namespace global

module Route =
    let hello = "/api/hello"
olivercoad commented 3 years ago

I've never seen that before and would probably find it confusing if I saw that without context. If it was my first time using SAFE I might think that shared code has to be directly in the global namespace for some reason and then copy it when making other shared files.

What's the purpose of removing the Shared namespace?

If the user wishes, they can prefix everything with e.g. ProjectName and be done with it.

If it starts as Shared you can do that with just a rename. Not so quick if it starts as global.

theimowski commented 3 years ago

That's a valid point. I've never used global namespace myself either. @isaacabraham thoughts?

isaacabraham commented 3 years ago

True.

I'm just thinking of making it simpler that both client and server can access "common" stuff without a Shared namespace.

Maybe I should create a sample SAFE app with some renames etc. - we can chuck it around and see where it goes?

isaacabraham commented 3 years ago

Either that or you have multiple files for each top-level module e.g. Routes etc.. But this feels a bit of an overkill (as it is, I'm not convinced we should even have the Routes module in the minimal template).

theimowski commented 3 years ago

I like the Routes module in minimal as it's the only small thingy that you can actually use to share code between server and client