Skip to main content

Questions tagged [controller]

In MVC architecture (Model-View-Controller), the object responsible for passing and receiving data to and from views, acting as a bridge between the "Model" and the "View".

Filter by
Sorted by
Tagged with
28 votes
4 answers
15k views

Unit-testing a controller in Ruby on Rails

I intend this to be a general question on writing an effective set of test cases for a controller action. I include the following ingredients: Ruby on Rails RSpec: A testing framework. I considered ...
Steven's user avatar
  • 281
15 votes
2 answers
528 views

My final sign up controller

I've asked a couple of questions here before regarding my controller, but I think I've finally gotten to understand controllers completely, but I'll never be sure unless I get my code reviewed. I've ...
Kid Diamond's user avatar
  • 2,591
14 votes
2 answers
8k views

AngularJS Todo List - too much controller logic?

I am starting an angular app and I was wondering if I am on the right track with this. I worked on my last angular app when I was just a youngun who didn't understand the important of designing the ...
evwill's user avatar
  • 143
14 votes
2 answers
38k views

Using a BaseController in MVC asp.net to reuse the repository

I have a repository class that impliments a repository Interface. In my Controllers I want a way to access the repository without creating constructors each time in the controller. So now all my ...
Stone Temple Aviators's user avatar
11 votes
1 answer
10k views

Generic ASP.NET MVC controller that generates many pages

I recently set out to create an open-source ASP.net MVC web development framework. Specifically, I wanted to automate some of the tasks associated with the creation of data-driven applications. I've ...
Vivian River's user avatar
10 votes
1 answer
184 views

ASP controller for tracking equipment

This was originally posted here. I'm hoping Code Review will be a little more helpful in giving me a concrete direction. I've been working on a project based off of this tutorial. Unfortunately, ...
J Hache's user avatar
  • 161
10 votes
1 answer
222 views

Baseball player statistics controller

I'm somewhat new to JavaScript and AngularJS, and read in Doug Crockford's book that hoisted function declarations can lead to issues. If you have any pointers on how to structure my file, those would ...
dusk's user avatar
  • 101
9 votes
2 answers
5k views

Rails controller method that conditionally filters results

This code for my blog checks to see if tags are in the params hash. If they are, then only posts that are tagged will be paginated. Otherwise, all of the posts are paginated. ...
Dylan Richards's user avatar
8 votes
3 answers
3k views

Linking issues, classifying the relationship as a cause, effect, superset, etc

I first saw this gigantic if and tried to refactor it. Could only end with a endless switch statement. Old code - ...
eLobato's user avatar
  • 181
8 votes
2 answers
3k views

Sails.js controller method for an admin to update a user account

I am new to Sails.js, Node.js, and web application development in general. My current understanding is that well-written controllers should be "skinny" meaning they should be as simple as possible, ...
Adam's user avatar
  • 191
7 votes
1 answer
958 views

C# Rental Program

I knew a little Java, and thought what the hell, I'll help my school and design this program that'll help checkout phone chargers and calculators and things to students. So I got in way over my head, ...
John Russell's user avatar
7 votes
2 answers
1k views

A controller on a .net core API

BACKGROUND I am working on a .Net Core API to drive a lyrics application. Users can sign up, submit artists & lyrics, and earn kudos / XP points in the process. Basically a community-driven ...
J86's user avatar
  • 414
7 votes
2 answers
169 views

Action based controller using reflections

I'm modeling a reflection-based controller. I would like to know if you agree with my implementation and about what could be enhanced. I'm starting with reflection and I would like to know if I'm ...
user1618606's user avatar
7 votes
1 answer
123 views

Controller action to process orders and payments

I'm trying to reduce the if statements and simplify this create action. ...
mnort9's user avatar
  • 241
7 votes
2 answers
278 views

Dispatcher for a JSON API without routes

I am using this code for a fast JSON API without routes. Does this code contain any useless parts? Is the class loader efficient enough? Are there any better options? Is ...
Aalex Gabi's user avatar
6 votes
3 answers
21k views

ASP.NET REST controller with try-catch error handling

Yesterday someone guided me through this article and I'm wondering whether I should use try-catch implementation or not? I have the following code below which is actually a RESTful service and I have ...
Sahil Sharma's user avatar
6 votes
2 answers
161 views

Controller for classrooms and students

The actions I'm wondering about are members, add_student, and remove_student. They work ...
Rob Sobers's user avatar
6 votes
1 answer
21k views

Spring MVC dynamically adding form elements

I made a simple form with an option of adding one text field dynamically on mouse click. And I will be grateful for suggestions on how I may improve the code. ...
Ivan T's user avatar
  • 61
6 votes
1 answer
136 views

Logging Window system

(I originally asked this on Stack Overflow and was directed here) So I have 2 classes, one is a PyQT window widget, and the other class is a stack which holds a dictionary pointing to all of the ...
e15purple's user avatar
6 votes
1 answer
2k views

Drawing Routes on a Map

I have this class: ...
iCantSeeSharp's user avatar
6 votes
1 answer
193 views

Controller to manage athletes

I would appreciate if you could give me some advice about the code below. I am a student learning PHP programming and programming fundamentals. I have learned a lot from Stack Overflow but there are ...
Kalpa Perera's user avatar
6 votes
1 answer
123 views

Uploading file for related entity

I see that my code smells. The first file is a controller, and createAction. But I don't know where to delegate this. BookController.php - Whole controller class So this is most 'smelly' code to ...
matiit's user avatar
  • 61
5 votes
3 answers
740 views

Not feeling 100% about my Controller design.

Basically, I'm uploading an excel file and parsing the information then displaying what was parsed in a view. ...
user avatar
5 votes
2 answers
363 views

Request dispatcher for PHP JSON web service

Below you can find the constructor method and related fields of the main class of my REST API (note that the class contains more code than displayed) written in PHP 7.1. It does various things with ...
Belle's user avatar
  • 207
5 votes
1 answer
191 views

Email Controller

I'm developing a Social Engineering Awareness Training Application. This is the focus of my thesis for my undergraduate degree. This will be a multi-part review request, however, if you want to see ...
Trojan404's user avatar
  • 818
5 votes
1 answer
33k views

Developing an alert notification in AngularJS

I'm studying Angular and want to develop my own notification alert. This is what I done, I like it and it's working like a charm but I think that it can be improved: Do I need to use it in conduction ...
Thales P's user avatar
  • 153
5 votes
2 answers
129 views

Rails controller to manage EC2 instances

I did a small sample application for an Interview. Since I didn't got accepted I would like your opinion on how to improve it. The aux methods are private. I have a ...
Manoel Rebelo Abranches's user avatar
5 votes
1 answer
148 views

Is my blog controller too "Fat"?

I would like some advice which relates to the "fat model skinny controller" concept in Rails. See my show action in the Micropost controller ...
GhostRider's user avatar
5 votes
1 answer
100 views

Defining routes and controllers relationship for given pages

I'm building a CMS app with the help of a custom framework. The back-office is composed of the following pages: post list page list user list post edit page edit user edit Actually, my routes are ...
ClemC's user avatar
  • 161
5 votes
1 answer
709 views

Laravel - Authentication Controller

I'm developing a Social Engineering Awareness Training Application. This is the focus of my thesis for my undergraduate degree. This will be a multi-part review request, however, if you want to see ...
Trojan404's user avatar
  • 818
5 votes
1 answer
849 views

AngularJS trivia game - separating controller from directive

I am creating a trivia game (purely for learning purposes) using AngularJS, NodeJS and MongoDB. My concern is related to the way I am organising the code in AngularJS. So far the game is functional, ...
Roco CTZ's user avatar
  • 153
4 votes
2 answers
17k views

Search and filter in MVC3 Razor using Linq

This code works fine, but I just don't like all the if else. If I keep adding field to filter, it's going to get messy. I am not using EF and cannot on this. ...
Stone Temple Aviators's user avatar
4 votes
1 answer
206 views

User controller for a .net core WebAPI dating app

I have this user controller that follows the repository pattern. It works perfect, but is it easy to understand? Is this good quality work? ...
Andre's user avatar
  • 41
4 votes
1 answer
3k views

Connect to MySQL and fetch a list of customers asynchronously using C#

I am connecting with a database and returning values from a Web API controller. For better performance, I am doing it completely asynchronously with a new task. Am I doing it the correct way? Am I ...
srv8's user avatar
  • 41
4 votes
1 answer
364 views

Need help with cleaning up this Controller

I've written the following controller and i was looking for some input/advice on how i could go about cleaning this up or rewriting it. I feel like i'm repeating myself a lot or that there might be a ...
zSysop's user avatar
  • 141
4 votes
1 answer
347 views

Codeigniter 3 micro-blogging application

I am working on a basic blog application in Codeigniter 3.1.8 and Bootstrap 4. The application allows Registration (as an author), Login, adding Categories and Posts. I have created an installation ...
Razvan Zamfir's user avatar
4 votes
1 answer
2k views

Laravel voting system

I have written a voting class in Laravel. It uses the voting sites API to check if the user has voted today. A user is only allowed to vote once every day. All votes reset at midnight (i.e. 12:00 AM ...
begoing's user avatar
  • 49
4 votes
1 answer
1k views

Laravel LoginController

I have a LoginController in Laravel, but I think it could use some improving, can anyone tell me where I am going wrong? It just seems overall a bit messy, but I can't think of a logical way to ...
Tom Johnson's user avatar
4 votes
2 answers
2k views

CakePHP static pages (without entity) but with dynamic content

I have a few pages that is not connected with entities (index page, terms of use page, email page). Detailed description: In CakePHP, when you want to have a static page (such as index for example), ...
Ricardo's user avatar
  • 265
4 votes
2 answers
700 views

Controller for searching with certain parameters

In the index view a user can search with any combination of one to all of the following parameters: firstname, lastname or ...
Theja's user avatar
  • 143
4 votes
1 answer
991 views

Laravel - Revised Authentication Controller

I'm developing a Social Engineering Awareness Training Application. This is the focus of my thesis for my undergraduate degree. This will be a multi-part review request, however, if you want to see ...
Trojan404's user avatar
  • 818
4 votes
1 answer
2k views

REST API that allows creating/removing users, CRUD ToDo tasks

My project is supposed to be used as back-end for a simple to-do web app that lets you create an account, add, edit, complete, and delete todos. It could be used with some front end consumer like ...
doublemc's user avatar
  • 285
4 votes
1 answer
145 views

CakePHP change 'miniMap' action and respect template

I have some questions on how I can improve this "action" (method) in "controller": My template has a navbar with dynamic content (if the user is logged in a special button appears, his name appears ...
Ricardo's user avatar
  • 265
4 votes
1 answer
84 views

Is this approach correct when testing an Angular controller?

I'd like someone to review these tests to make sure I'm along the right lines in Angular testing. Note - They do all pass (great) but I feel like I'm struggling to understand the finer points of ...
Katana24's user avatar
  • 327
4 votes
1 answer
521 views

Code structure for a login modal dialog.

I'm using twitter mobile and I have a login-dialog. login-Dialog is a modal dialog. To call it the user calls loginDialog.show(); I'm not all that comfortable ...
JonWells's user avatar
  • 323
4 votes
2 answers
436 views

PHP MVC controller code needs diet?

This is the dashboard controller code in PHP Symfony 2. It collects some aggregate data and points for charts, but i don't like it very much. Do you think that this code belongs to what a controller ...
gremo's user avatar
  • 439
4 votes
0 answers
171 views

Swift iOS app for showing motivational quotes, with multiple screens

I'm one month into self-learning Swift, and I would like some advice to improve my coding skills. I have listed 2 situations that I think I need to improve. I'd like some feedback focusing on my use ...
andy's user avatar
  • 61
4 votes
0 answers
132 views

Salesforce controller to implement a dynamic form

The code below is a controller for a Visualforce page (form). The controller determines if the form was previously created and saved or saved in progress in a previous action. If the form is new it ...
user2355809's user avatar
4 votes
0 answers
854 views

Update UI once all API calls are done

I'm learning Swift at the moment but I would like to produce well-organised code. The goal of my little app is to display the weather of my current location. I use : the API of Darksky : https://...
miko7358's user avatar
3 votes
2 answers
570 views

Business logic inside MVC Cart Controller method

I have a controller method, invoked when a user adds the product he is viewing to the cart. The way I understand how MVC works, this can be considered a fat controller already, but I'm still not ...
herondale's user avatar
  • 145