Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have a controller method called GetCustomer(int id=0)
This smells weird in my opinion, but was already here, and I'm wondering if this is a good practice!
I would rather in this case use nullable type!
Assuming that action maps onto GET /customers/id, making the id optional (by means of a parameter with a default value or a nullable type) is bad API design.
Traditionally, GET /customers maps onto an action that retrieves all existing customers, not onto GET /customers/0. You can also simply not support calls to GET /customers.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
In Blazor, certain things like injected objects and parameters must use properties, that part is clear.
But what about those page-specific variables, such as data/DTOs and misc strings/booleans etc used to control the page content and flow?
Is it better to use automatic properties with these all the way (public or private?) or private fields?
I'm asking this because in the various examples, tutorials and documentations related Blazor, use of both properties and fields are all over the place. I cannot seem to find any official best-practice guides on this.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
In my smart client solution, I have a Project folder with:
IProjectView.cs
*ProjectView*
ProjectView.cs
ProjectView.Designer.cs
ProjectView.GeneratedCode.cs
ProjectView.resx
ProjectViewPresenter.cs
I want to define some constants for user by ProjectView.cs and ProjectViewPresenter.cs. Both of these classes implement IProjectView.cs, so were I back in Java, I'd put them there. If this were C++, I'd create a class ProjectConstants.cs and have the classes inherit it, but C# doesn't allow multiple inheritance.
How do I do this?
Can having a Read-Only Property in your interface solve your problem?
string MyReadOnlyProperty { get; }
I have no clue if this is very performance-wise compared to constant thought.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What is good API route template? I other words, is there template that i more expectable, or it is not important at all?
first:
"api/{controller}/{action}/{id}"
http://example.com/WorkItem/details/5
second:
"api/{controller}/{id}/{action}"
http://example.com/WorkItem/5/details
I consider it good practice to use your second approach in a RESTful szenario. Common frameworks handle it this way:
Example 1: Rails
see the docs at 2.2 CRUD, Verbs, and Actions, where
GET /photos/{:id}/edit refers to the PhotosControllers edit-method to return an HTML form for editing a photo
Example 2: Laravel
see the docs at RESTful Resource Controllers, where
GET /photo/{photo}/edit also refers to a PhotoControllers edit-method.
Also, see the section on Nested Resources below which looks a bit more like your use case:
Route::resource('photos.comments', 'PhotoCommentController');
registers a nested route in the way of photos/{photos}/comments/{comments} which is your use case and looks more like your second approach.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a question about C# naming convention rules.
I know that you write ex. CustomerId.
But what if it the property is a List of CustomerId's?
Should I write CustomerIds or CustomerIdS?
MSDN describes using pascal casing for member names. There is no specific guideline on plurals as far as I can see, but I would suggest CustomerIds since it feels more natural to me.
Also here the question between ID and Id is answered: use Id.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm using XmlManager to
do xml manipulations in several methods in a class.where I should declare XmlManager variable ?
1.locally within each method and do intialization.
2 declare at globally and initiate at the method level
As it is, in this question, there's absolutely NO difference whatsoever because there's neither performance gain nor significant design issues.
Maybe if the question is put into context there could be reason to choose one approach over the other, but as it stands now. None of the approach is better than the other one