14
votes
Accepted
ASP.NET REST controller with try-catch error handling
throw ex;
This is a fatal mistake. It'll create a new stack-trace and you won't be able to tell where the actual exception occured. If you want to rethrow it then ...
6
votes
Baseball player statistics controller
Bearing in mind that you claim that you do not to maintain this code anymore1, there are a few suggestions I would have about this code:
define functions and accept parameters- that should allow the ...
6
votes
User controller for a .net core WebAPI dating app
Errors
An assumption: you never ever want to return a 500 HTTP status code (Internal server error). It may leak information you do not want to expose and it's not informative enough. Do not throw ...
5
votes
ASP.NET REST controller with try-catch error handling
Typically in an ASP.NET app (and in fact in any app), you should only catch and handle the base System.Exception in a single place as close to the application entry ...
5
votes
Update person name in database
PersonUpdateModel
Depending on how sophisticated your Person model is, you might need to consider to extend your update model with middle name
Prefixing first name ...
4
votes
Accepted
Request dispatcher for PHP JSON web service
Now, to my best knowledge, $this->request in PHP always points to the HTTP-request when a HTTP-request has just been made
My guess is that you are thinking of the super-global ...
4
votes
Accepted
Business logic inside MVC Cart Controller method
I think there is more to discuss here then business logic inside your controller. I'm going to generally keep it to a high level of discussion, but feel free to comment and ask for specifics. I'm ...
4
votes
Accepted
Table View Controller class in Swift
There are quite a few issues here:
In switch statement, you don’t need/want break statements. Unlike C languages, Swift ...
4
votes
ASP.NET REST controller with try-catch error handling
The linked post adds a neat summary:
So, to sum up:
Don’t catch fatal exceptions; nothing you can do about them anyway, and trying to generally makes it worse.
Fix your code so that it ...
3
votes
Accepted
Validation and business logic for a form for milling jobs
The class is not a "business logic layer" class, because it is still deeply rooted in the user interface. You cannot execute the logic of this class without a valid form control, and therefore you ...
3
votes
Accepted
Simple login with jsp
Object Oriented
So, from a object oriented perspective, stuff is a bit chaotic.
Servlet
What bothers me the most is that there's "too much code" in the servlet. Just think about that: What ...
3
votes
Spring MVC dynamically adding form elements
Use interface List instead of concrete class for the fieldArrayList
field.
Make the ...
3
votes
Request dispatcher for PHP JSON web service
I don't recommend emitting these headers so early, and also not as a side-effect of a constructor:
...
3
votes
Accepted
Decoupling of validation and data access in ASP.NET
I guess you'll find a lot of redundancy in the code since its been held by the controllers.
Your idea of making a service is a good idea, you may need to add different services, but at the end you'...
3
votes
Accepted
An efficient way to order content in controller [Spring Boot]
Well, you found a workable solution.
One thing that strikes out at me is, that you expose the inner structure of your
ContentOrderMap by accessing ...
3
votes
'Lean controller'/'Business logic on service' and filtering, sorting, pagination methods on controllers
Is this separation correct?
While helper methods/classes (e.g. EmployeeService::getEmployees()) are nice to have, I would only do that if the same actions are ...
2
votes
Video editing form controller action method
The method is 37 lines total, which does seem somewhat long yet is not uncommon in many projects. One could move things around a bit to avoid assigning variables like ...
2
votes
Laravel LoginController
Just refactored the one function.
It is hard to tell what your intentions are in some places.
Comments are inline, with reasons as to why I changed things
...
2
votes
Logging Window system
if model is not None:
You do this all over the place. You should change it to:
if model:
...
2
votes
Business logic inside MVC Cart Controller method
I agree with many of the points in Conor Mancone's answer. Sanitation of data is important - one could utilize PHP's Sanitize filters with filter_var(). However, ...
2
votes
Laravel voting system
The Question
Could anyone advise a better way to create [cookies]?
Like your code already uses, setcookie() is the traditional way of setting cookies. And yes, ...
2
votes
Accepted
Codeigniter 3 micro-blogging application
Foreword
I haven't used CodeIgniter in the past so I am not as well-versed with the idiomatic ways it is used but I have used similar frameworks like Laravel.
I did look at the code in the github ...
2
votes
Validation and business logic for a form for milling jobs
I'm just gonna add some observations on top of already mentioned
suggestions:
If there's any way you can incorporate automatic layouting and some
sort of declarative UI, or use a UI builder, methods ...
2
votes
Accepted
Passing argument to a constructor and using it only in some class methods
As far as I can see in the code example you've provided, it seems that the getStatistics and recordClickedLink methods are ...
2
votes
Update person name in database
Quick remarks (in addition to Peter Csala's review):
Your controller does too much. Keep it thin and lean, and create other classes to implement the logic etc. For instance, use MediatR.
Right now ...
2
votes
Laravel Event Filtering Controller
I think overall your code is pretty good. It was a little hard to tell what your view would call if the form was submitted (maybe you aren't using that part??)
Anyway, I took a stab.
I think, based on ...
2
votes
Handling HTTP requests in existing Web Api
Honestly, I'd advise against this.
Your approach seems to me a naïve view of how things work. Are there methods that just get data from a DB and return it? Sure. But a lot of the time business logic ...
1
vote
Accepted
1
vote
Accepted
JavaFX controller for a poker game
Logic:
If statements differs only in 2 variables: canvasPlayerX and playerCardsWidthX.
playerCardsWidthX: looks like this var can be converted to local, just like playerCardsHeightX;
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
controller × 159php × 51
mvc × 37
ruby × 29
ruby-on-rails × 29
c# × 28
javascript × 24
java × 19
laravel × 19
object-oriented × 13
angular.js × 13
beginner × 9
design-patterns × 7
codeigniter × 7
performance × 6
json × 6
swift × 6
api × 5
asp.net × 5
authentication × 5
ios × 5
rest × 5
javafx × 5
url-routing × 5
jquery × 4