Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Winforms - best directory / project structure

Tags:

c#

winforms

Wanted to see peoples thoughts on best way to organize directory and project structure on a project / solution for a winforms C# app.

Most people agree its best to seperate view, business logic, data objects, interfaces but wanted to see how different people tackle this. In addition, isolate third party dependencies into implementation projects and then have interface exported projects that consumers reference

  • View.csproj
  • BusinessLogic.csproj
  • Data.csproj
  • CalculatorService.Exported.csproj (interfaces)
  • CalculatorService.MyCalcImpl.csproj (one implementation)
  • CalculatorService.MyCalcImpl2.csproj (another implementation)

    Also, in terms of folder structure, what is better nesting:

    Interfaces
    ---IFoo
    ---IData
    Impl
    ---Foo
    ---Data

    or

    Product
    ---Interfaces/IProduct
    ---Impl/Product
    Foo
    ---Impl/Foo
    ---Interfaces/IFoo

    All trying to push for decoupled dependencies on abstractions and quick ability to changed implementations.

    Thoughts? Best practices?

  • like image 400
    leora Avatar asked Oct 07 '08 19:10

    leora


    2 Answers

    For me it depends on the model I'm following. If I'm using MVC it would be

    Project
    -Models
    -Controllers
    -Views
    

    Or for MVP it would be

    Project
    -Models
    -Presenters
    -Views
    

    Under the views I seperate them into namespaces relevant to the controllers, i.e. if I have a controller to handle inventory transactions I might have it as

    Project
    -Models
    --Inventory
    -Controllers
    --Inventory
    ---TransactionsController.cs
    -Views
    --Inventory
    ---Transactions
    ----EditTransactionsView.dfm
    

    For interfaces I put the interface in the same directory as the implementations.

    like image 189
    Odd Avatar answered Nov 08 '22 04:11

    Odd


    Bit of a late answer but may as well chime in.

    I have been personally using folders based on the actual type of item it is. For example:

    - Project
        + Forms
        + Classes
        + UserControls
        + Resources
        + Data
    

    So I end up with:

    new Forms.AboutForm().ShowDialog();
    Controls.Add(new Controls.UberTextBox());
    
    like image 32
    Nick Bedford Avatar answered Nov 08 '22 03:11

    Nick Bedford