Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Does anyone know of a good/usable ASP.NET MVC code/solution generator. Ideally it would build from a domain model, but from a data model is also acceptable.
If you do, can you answer the following:
Does it produce "good" code?
Can it be extended?
What do you like and not like about it if you have used it?
What great fearures does it come with that stand out?
If there isn't one you know of then do you think this is something missing from the community or do you not think it is needed? What features would you like to see in one?
Can't wait to hear your answers...
Thanks
Scott
S#arp Architecture includes scaffolding generator using T4. It generates model, views, controllers, and tests from the template model definition. You get full CRUD. Since it uses T4 (Visual Studio template language I suppose) you can extend default templates as you want.
Here's an example of the template:
EntityScaffoldingDetails entityScaffoldingDetails =
new EntityScaffoldingDetails("Organization.Worker");
/*
* Property names should be PascalCase.
* Do not include a property for Id as it will be included automatically.
*/
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("FirstName", "string", "Joe", "[NotNull, NotEmpty]", true)
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("LastName", "string", "Smith", "[NotNull, NotEmpty]", true)
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("BirthDate", "DateTime", DateTime.Parse("1/1/1975"))
);
entityScaffoldingDetails.EntityProperties.Add(
new EntityProperty("Manager", "Employee", null, "[NotNull]")
);
///////////////////////////////////////////////////
// The first parameter should reflect the root directory of your solution
//ScaffoldingGenerator generator = new ScaffoldingGenerator(
//#"D:\Work\Project\", "Orders", entityScaffoldingDetails);
// Uncomment this line when you're ready for the scaffolding generator to fire...be sure to recomment after it completes to avoid accidental generating!
//generator.Run();
One small addition: I would not recommend using it as is, because, for example, I'd prefer controllers to work with ViewModel, not entities. And I don't use scaffolding much. But it is pretty flexible, though you may need to learn T4.
You could try a Visual Studio 2010 extension called Radarc. It has a repository of extensions (called Formulas) which allows you to generate solutions for different architectures and technologies. Using Radarc with MVC Formula you can create ASP.Net MVC 3 applications with EF Code First either from a new domain model or importing an existing database.
I am working in this product team so I am not too objective to reply all your questions, but yes it can be extended.
Have you taken a look at Naked Objects MVC ? at least for academic reasons is very interesting.
The Naked Objects MVC framework will take a Domain model (written as POCOs) and render it as a complete HTML application without the need for writing any user interface code - by means of a small set of generic View and Controller classes. The framework uses reflection rather than code generation.
The developer may then choose to create customised Views and/or Controllers, using standard ASP.NET MVC patterns, for use where the generic user interface is not suitable.
Try www.datatreepages.com.
You connect the designer at your database and it generates data entry pages with sorting/searching/paging. You can also design layouts which allow you to link data pages together on the screen for master/detail relationships.
The controllers, data access, models, view models, csthml, javascript/jquery, html/css are all written for you. The code produced is simple and extendable.
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 6 years ago.
Improve this question
In various articles on the web about ASP.NET MVC I've people mention that Microsoft's implementation of MVC is somehow different form the 'classic' MVC pattern.
But I've never seen anyone go into any detail on this, and at first glance I don't see how ASP.NET MVC is any different from what is described, say, here.
So my question is: does ASP.NET MVC really violate any MVC pattern principles?
The problem is really that MVC is a loosely defined pattern. The "M" could be interpreted as "everything in the business domain, from entities to business logic".
I wouldn't say that ASP.NET violate MVC, but rather interprets it loosely.
Some official MVC examples uses entity framework directly in the controllers which in my opinion is incorrect. Because then it doesn't act as a bridge between the model and the view. Instead it takes care of business logic (even if it's very basic logic) AND map the model info to the view.
ASP.NET MVC has something called view models which are not the M in MVC. They are instead used as an adapter between the model (or rather one of more entities in the Model) and the view, thus taking over a part of the responsibility that the controller has.
Generally yes, Microsofts implementation of the MVC pattern follows the main tenant of the MVC pattern. It has a Model, Controller and View that are responsible for slightly different aspects of the UI (remember MVC is a presentation pattern in this instance so it's only responsible for the UI (mostly))
Where Microsoft start to deviate is the introduction of some of the less clean (as in not 100% MVC) features, specifically
ViewBag
C# in the view (not razor as such but #helper
functions)
TempData
ViewData
Layouts
ViewModels
Some of the above are more contentious than others. Ultimately all these things are designed to speed up development, but move away from the idea that the controller builds a model that the view then renders (full stop).
Microsoft also has a tendency to explain MVC as a business logic pattern (as mentioned above it's a UI pattern).
So in the Microsoft world you often see example where the controller gets a model from (for example) Entity Framework does some business logic (business logic shouldn't really be in the controller) then passes it into a ViewModel (not really 100% MVC) and the view then renders it (manipulating the data using helper functions).
So they try and sell MVC as a one pattern fits all solution when it's not.
Although, I agree with other answers [in some respect], let me put it into a different perspective.
ASP.NET MVC is not a pattern but rather a framework in which you can write your software using MVC pattern, or rather its specific web-application version.
You shouldn't worry about Microsoft's implementation. Their implementation of MVC Framework has little to do with MVC pattern. To implement it, MS use many different patterns, I am sure. The key here, is to understand that MVC framework is not MVC. It allows you to develop using MVC pattern. And in this case, this pattern includes certain rules that you need to follow, like in other patterns - name controllers with Controller at the end, for example. But this is MS's implementation for you. So, you have View, Model and Controller. MVC Framework tells you, follow the rules and we will connect all these for you.
Now, if you go to MVC pattern as original pattern, all it tells you - separate view from controller and model. And separate model from controller. Because this way, you can reuse model and controller with different view, for example. Now, how you implement it - it is up to you. As long as it has characteristics I described above, this is MVC. So, again, MS gave you MVC framework, in which you have separate M-V-C. Therefore, when you write your M,V and C, you have separation which is original pattern describes. MVC framework takes care of the wiring for you.
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 9 years ago.
Improve this question
I've been using MVC for over a year now, and I like it alot. I've heard of Knockout.js. How is the comparison between these two? Which is better?
MVC seems to have reached its maturity with MVC5, with alot of support.
I do not see knockout.js as well supported. There examples on their site do not even work in Firefox. However, I can see the potential of this since it is written in javascript, client-side, and possibly faster since its client-side, like ajax.
What are the advantages of Model-view-controller vs Model-View-View-Controller?
You should not be comparing Knockout.js to Asp.NET MVC. The only similarities are that they both use the same Model-View-Controller pattern.
Knockout.js:
Knockout is a standalone JavaScript implementation of the Model-View-ViewModel pattern with templates. The underlying principles are therefore:
a clear separation between domain data, view components and data to be displayed
the presence of a clearly defined layer of specialized code to manage the relationships between the view components
The latter leverages the native event management features of the JavaScript language.
Asp.NET MVC:
ASP.NET MVC allows you to build a web application as a composition of three roles: Model, View and Controller.
A model represents the state of a particular aspect of the application. A controller handles interactions and updates the model to reflect a change in state of the application, and then passes information to the view. A view accepts necessary information from the controller and renders a user interface to display that information.
As you can see Knockout.js is an MVC implementation for JavaScript while Asp.Net MVC is an MVC implementation for a complete web application from front end to server. These technologies can even (and very often) be used together to build well structured applications on both the front end and the back end.
You are comparing apples and oranges...
Since you are now familiar with ASP.Net MVC (and the MVC design pattern in general), it is time to take the next step and use a JavaScript MVC framework WITH it.
There are many choices, some popular ones include Knockout.js, AngularJS, Backbone.js, Ember.js, and many more. The site TodoMVC will give you a flavor of what is out there.
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 am pretty new to grails. In the past I have created web applications with jsf 2.0. Usually I created every class by "hand". Therefore scaffolding of grails comes extremely handy to me.
So my question is:
Do you just create the domain layer and then just modify the scafolded views?
Whats your typical development process in grails 2.3.4?
I appreciate your answer!
The development process depends on your type of project and experience.
I personally create lots of crud applications with the same corporate identity. So I use the scaffolding as you described: create views and controllers, then modify them. In order to apply the corporate identity, I've modified the default stylesheet and apply it through a self made plugin.
If you create crud like applications, but the scaffolding doesn't fit, you can do a install-templates and modify the resulting scaffolding templates. This way, you can easily modify the structure of your scaffolded pages (for instance add an Excel-Export for all list pages as default)
In other projects, my main pages are not crud like, so I manually create them. But I still need a lot of admin pages which are crud like - these I still scaffold and even don't have to modify. That spares a lot of effort
If scaffolded pages do not fit and you are experienced enough in Grails, #moeTi is right that manually coding your controllers and views might be faster.
For now until your more familiar its a great starting point to generate contollers and views. I think you will need to get more specific as to what it is you want to do with your controller views outside of scaffolding.
Email Validation in a controller Grails
Take look here for an example of a validation class that you could makeup and add at a bottom of a controller. This then gives you the power to custom verify. Hand made forms
Take a look at spring security plugin and if needed restrict delete edit to certain group of users.
In a lot of my earlier controllers I did a basic generation and then ended adding extra functionality.
Personally I don't really like the scaffolded views, although you can modify the templates. It's a good way to get started quickly, but you will soon realize that it's a lot of work to modify them to your needs.
You can scaffold and modify until you understand the GSP underpinnings, but at some point you will realize that you could write the whole thing faster than create and modify everything. And you can outsource code into templates and/or taglibs.
On the other hand, if you really just need default layout CRUD operation UI for your database, scaffolded views are probably good enough
Here is a start and brief info about scaffolding
Scaffolding lets you generate some basic CRUD interfaces for a domain class, including:
The necessary views and Controller actions for create/read/update/delete (CRUD) operations.
static scaffold = true // by setting scaffold to true
With this configured, when you start your application the actions and views will be auto-generated at runtime. The following actions are dynamically implemented by default by the runtime scaffolding mechanism:
a)index b)show c)edit d)delete e)create f)save g)update
then you could customize the generated views of your need.
I am sure the default views never fit to your need, so i would always go with my own view from the beginning.
But Yes!, if you are a beginner and want grails to help you how the controller and view looks like you can always start with it and feel the ease of grails framework
Thanks
Motilal
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm looking to learn more about the .net MVC3 data model. Specifically, I'd like to learn details of how the system goes about automatically transferring data between client and server.
I'm looking for a documentation source which contains a level of detail that's sufficient for answering questions like these:
How is data automatically mapped from model to view and back?
What are the limitations of the mapping?
If I were to instrument, for example, custom logging or debugging tools for tracking data moving between controller and view, what are some good inflection points I can look at?
etc...
Any pointers would be appreciated, whether to documentation online or relevant books.
I really like the Pluralsight screencasts for describing the different pieces of MVC. They are on the left side of the MVC site. There are also a number of good articles on that page.
First, there is very little "automatic" in the mapping methods in a normal MVC application. If it were automatic, you would be more tightly coupled than you should be. As an example, you create a view to expose specific parts of the view. But, you can change how you display at any time by altering the view. Conversely, if you want a method to accept arguments from the client side (view after it is rendered), they become parameters.
As time moves on, I am sure you will see more and more Microsoft automagic bits bleeding into MVC to make it simpler for non-programmers to program. It happens, but there is a risk adding too much automagic will break down the "separation of concerns" in the MVC model.
Now, controller to view may seem a bit more automagic, but this is more of a ruse, as you can gain control of the model being passed to the view and alter it at any time. It appears even more automagic, in some cases at least, when you use page.
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 know you can use several different view engines with ASP.NET MVC:
ASPX, obviously
NVelocity
Brail
NHaml
et al...
The default ASPX view engine seems to make the most sense to me, coming from an ASP.NET WebForms background.
But, I wanted to get an idea of the pros and cons of each and see what most people are using.
Which does StackOverflow use?
I use Spark. It has nice flow between HTML and code. Scott Hanselman also did a post on it with his weekly source code review posts. I am really digging it a lot. One of the major features is pre-compilation of your views.
"Which does StackOverflow use?"
Web Forms.
I asked Jeff Atwood about his decision on his Tag Soup post. He didn't reply - I think he was busy hunting down a missing closing tag ;-)
NHaml is my favorite for its terseness. People either love it or hate it, given that it looks very different from a traditional "HTML with inserted code" template system like ASPX or NVelocity.
Edit:
#Ben,
There are other view engines which compile down (NHaml is one), so those do support custom HTML helpers. I wouldn't be surprised to see the currently interpreted view engines all eventually end up with a compilation model eventually.
Microsoft has recently announced a new view engine: Razor.
Looks pretty interesting:
http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx
Most people on the planet will just use ASPX because that's what they know. Another excellent benefit is the compiled-nature... so you not only get type-safety and intellisense, but you can get the perf benefit as well.
The drawback that I see is that it's so flippin' verbose. I converted an app to NVelocity and was astounded at how clean it looked. The problem is that there were a lot of things that didn't work with NVelocity (like your own custom view helpers) and there was a severe lack of documentation.
I added a feature to MvcContrib where you can register your own HtmlExtension types to it, but it's more of a bandaid until a better solution comes out.
I've used NVelocity in the past. For the most part it makes the code really clean and simple to follow; however, it normally ends up just being a few ViewData variables which have been filled up by XSLT files before hand. So I guess really my View Engine would be both XSLT (which is a love/hate thing - Extension Methods make it really useful) and NVelocity.
I've used NVelocity with MonoRail for some time but have recently switched to Spark for both Asp.Net MVC and MonoRail. The syntax seems very natural to me, but I guess that's to be expected. ;)