Programming/Comparisons: Difference between revisions
Jump to navigation
Jump to search
(Created page with "== Frameworks == === Ruby on Rails and Blazor === {| class="wikitable" !colspan="6"|Ruby on Rails and Blazor |- | !Ruby on Rails !Blazor |- !Language |Ruby |C# |}") |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
{| class="wikitable" | {| class="wikitable" | ||
!colspan="6"|Ruby on Rails and Blazor | !colspan="6"| Ruby on Rails and Blazor | ||
|- | |- | ||
| | | | ||
!Ruby on Rails | ! Ruby on Rails | ||
!Blazor | ! Blazor | ||
|- | |- | ||
!Language | ! Language | ||
|Ruby | | Ruby | ||
|C# | | C# | ||
|- | |||
! Models | |||
| | |||
* /app/models/*.rb | |||
| | |||
* /Models/*.cs | |||
* Package dependencies | |||
|- | |||
! Views | |||
| | |||
* /app/views/*.html.erb | |||
| | |||
* /Pages/*.razor | |||
* /Pages/*.cshtml | |||
* /Shared/*.razor for partials | |||
|- | |||
! Controllers | |||
| | |||
* /app/controllers/*.rb | |||
| | |||
* Part of /Pages/*.razor | |||
* /Pages/*.cshtml.cs for corresponding /Pages/*.cshtml | |||
|- | |||
! Routing | |||
| | |||
* /config/routes.rb | |||
| | |||
* Defined by `@page "/<path>"` on each /Page/*.razor page | |||
|- | |||
! Layout | |||
| | |||
* Usually defined in /app/views/layout/application.html.erb | |||
* Usually used in /app/controllers/application_controller.cs, or the root controller of the application | |||
| | |||
* Usually defined in /Shared/MainLayout.razor and /Shared/MainLayout.razor.css | |||
* Usually used in /App.razor | |||
|- | |||
! Using Partials | |||
| | |||
* `<%= render '[partial name]', param_name: param_value_variable %> | |||
| | |||
* <[PartialName] ParamName=@ParamValueVariable /> | |||
* <[PartialName] @bind-ParamName=@ParamValueVariable /> for updating the parent on value change in partial | |||
|- | |||
! Permissions/Authentication | |||
| | |||
* Defined in /app/models/powers/*.rb | |||
* Used in /app/controllers/*.rb | |||
* /app/controllers/application_controller.rb to rescue Consul::Powerless | |||
| | |||
* Configured in /Startup.cs | |||
* Used in /Pages/*.razor | |||
* /App.razor to rescue unauthorized | |||
|- | |||
! Data Services | |||
| | |||
* /app/controller/*rb for basic data access | |||
* /app/services/*.rb for more complicated data access/manipulation | |||
| | |||
* /Data/*.cs | |||
** However, these classes are usually wrappers around API calls to other services - C# .NET best practices usually entail a series of micro-services instead of a monolith, meaning the frontend does not directly interact with the database. | |||
** Since this folder can get pretty big, you'll have to split this up yourself. Some folders I've used are Services, API, Authentication, and Exceptions. | |||
|- | |||
! Dependency Injection | |||
| | |||
* Rails doesn't really do dependency injection - usually objects are created on demand in the controllers. | |||
| | |||
* Defined in /Startup.cs | |||
* Used as regular parameters in /Data/*.cs | |||
* Used with `@inject <Class> <VariableName>` in /Pages/*.razor | |||
|- | |||
! JS/CSS | |||
| | |||
* /app/client/packs/*.js & /app/client/packs/*.css for Webpacker | |||
| | |||
* /wwwroot/css/*.css | |||
* /Pages/Shared/*.razor.css | |||
* Blazor does not use Javascript | |||
|- | |||
! Asynchronous Calls | |||
| | |||
* Ajax/HttpRequest | |||
| | |||
* SignalR/WebSockets | |||
|- | |||
! Calling Server Code | |||
| | |||
* Setup | |||
** Make a routing endpoint | |||
** Connect to controller | |||
** Return json | |||
* Use | |||
** Use endpoint in link | |||
** Parse json | |||
** Use JS to update page | |||
| | |||
* Define method on same razor page. | |||
* Add `@onclick="@(() => MyCSMethod(MyParam))` to html item. | |||
|} | |} |
Latest revision as of 10:27, 9 August 2021
Frameworks
Ruby on Rails and Blazor
Ruby on Rails and Blazor | |||||
---|---|---|---|---|---|
Ruby on Rails | Blazor | ||||
Language | Ruby | C# | |||
Models |
|
| |||
Views |
|
| |||
Controllers |
|
| |||
Routing |
|
| |||
Layout |
|
| |||
Using Partials |
|
| |||
Permissions/Authentication |
|
| |||
Data Services |
|
| |||
Dependency Injection |
|
| |||
JS/CSS |
|
| |||
Asynchronous Calls |
|
| |||
Calling Server Code |
|
|