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".
8
votes
4answers
3k views
How would you refactor this if statement of a Rails controller?
I first saw this gigantic if and tried to refactor it. Could only end with a endless switch statement.
Old code -
...
6
votes
1answer
86 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 ...
5
votes
2answers
1k 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 ...
4
votes
3answers
553 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.
...
4
votes
3answers
5k 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.
...
4
votes
1answer
150 views
How to improve this design?
I have some design doubts regarding my controllers and I would like some advice...
Everything works. However, I'd like to improve it.
Basically I have one controller per screen(Swing).
I have created ...
4
votes
1answer
329 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 ...
4
votes
2answers
329 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 ...
3
votes
1answer
298 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 ...
3
votes
2answers
718 views
Loading content in page via jQuery
I'm doing a web site in CodeIgniter and I'm loading the content page via jQuery, but I don't know if this is a good practice or not. Could I improve it?
jQuery:
// Another question here: how can I ...
3
votes
1answer
49 views
Is it a classical MVC (Xerox Parc) implementation?
I've been trying to understand the original MVC implementation (the Xerox Parc's one). I'm sure it has flaws, but it's a simple code to practice/learn the original MVC.
Working example
View ...
3
votes
0answers
76 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 ...
3
votes
0answers
1k views
Review my 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 ...
2
votes
3answers
140 views
Controller with too many dependencies?
The main impetus for this review is to determine if my ASP.NET Web API controller has too many dependencies. I'm of the opinion that 3-4 is okay, but 6 seems like too many. I have many controllers ...
2
votes
1answer
141 views
is this producer-consumer implementation correct?
I want to ensure that, as much as possible given my skill level, that I'm using relevant patterns correctly and following naming conventions. This is a controller for a poor-mans MUD client using ...
2
votes
2answers
84 views
Can I make this admin method in CakePHP more streamlined?
I have a VenuesController and an EventsController. My venues controller has an admin_add ...
2
votes
0answers
84 views
What can I do better in this ViewModel Creator?
I'm currently creating a ASP.NET MVC page in C#.
I want to hide everything regarding the creation of our "models" and "viewmodels".
I have seen much of the fancy stuff regarding Dependency ...
2
votes
2answers
630 views
Repetition in Controller code
In the index view a user can search with any combination of one to all of the following parameters: firstname, lastname or ssn. The found search results are displayed in the search results view. In my ...
1
vote
2answers
84 views
How can I refactor this oversized Ruby method into smaller bits and have unit tests for them?
This is the existing code. Clearly way too much is going on in this index method and furthermore it's untested (and hard to test in its current form).
...
1
vote
1answer
674 views
Router Class In a Lightweight MVC Boilerplate
I'm trying to come up with a simple router class. I considered using a Request class but that will rather make simple to complex. That is why I did not consider creating one for my framework.
...
1
vote
1answer
88 views
Duplicate SQL code in controller
How I can rewrite or refactor my controller code? I have the same SQL query (@plan_gp_users) in all defs.
...
1
vote
1answer
115 views
Inserting using multiple contexts into LocalDB
I've written this ActionResult to model an Order that goes through. I couldn't think of another way to write this without using context ...
1
vote
1answer
76 views
Cleanup controller action
I would like some help to clean up this action, especially from @companies and downward. The comments should be enough to explain :)
...
1
vote
1answer
46 views
Linq to sql performance
I'm creating a system and I'm using EF with Linq. Model First.
So I create my Model (.edmx) and using it, I generated my database and my classes. like the Usuario (user in portugues. going to keep ...
1
vote
2answers
161 views
Rails - Loading data in controllers
I am refactoring my controllers, trying to improve the way common data is loaded for the actions.
Initially I was using before_filter methods to do this but read ...
0
votes
2answers
179 views
How could I make my controller a little less hideous?
I have a controller. It functions as follows:
A user imports a file and decides whether the files contents contain new entries to be placed into a database, or existing entries entries to be updated.
...
0
votes
1answer
33 views
Is it reasonable to have separate controller actions for different user registration paths? Or should I refactor into a fewer number of actions?
I have two registration paths in my app. They are very similar and I am curious if I should simplify 4 associated actions down into two actions that handle the same amount of work.
Here are my ...
0
votes
1answer
823 views
PHP MVC: how to do $_POST the right way
I am not sure if I am doing right on how to handle $_POST data in MVC pattern. Below is my attempt. Am I doing it right?
// Dummy $_POST data,
...
0
votes
2answers
100 views
Codeigniter - in the view or in the controller?
Is this correct? Or am I overloading the responsibilities of the view?
...
0
votes
1answer
193 views
Review: Finished router class for custom mini framework
I have finished my router and would like your thoughts on anything that may be inefficient of could be done better!:
class Router {
...