Tag Info

Hot answers tagged

202

Yes you should. It not only makes your back end re-usable but allows for more security and better design. If you write your backend as part of a single system, you're making a monolithic design that's never easy to extend, replace or enhance. One area where this is popular at the moment is in Microservices. Where the backend is split into many little (or ...


124

I developed ASP .Net WebForms applications for 3 years, and after one day of doing an MVC tutorial I was sold. MVC is almost ALWAYS the better solution. Why? The page lifecylce is simpler and more efficient There is no such thing as controls besides html controls. You don't need to debug your output to see what ASP .Net is generating. ViewModels give you ...


104

The single best reason to not use the repository pattern with Entity Framework? Entity Framework already implements a repository pattern. DbContext is your UoW (Unit of Work) and each DbSet is the repository. Implementing another layer on top of this is not only redundant, but makes maintenance harder. People follow patterns without realizing the purpose of ...


75

Webforms vs. MVC seems to be a hot topic right now. Everyone I know touts MVC to be the next great thing. From my slight dabblings in it, it seems ok, but no I don't think it will be the end of webforms. My reasoning, and the reasoning as to why webforms would be chosen over MVC, has more to do with a business perspective rather than what one is better ...


60

I emailed Scott Guthrie, an MVC expert at Microsoft. And probably the most qualified man to answer this question. He was kind enough to reply: "Different customers look for different programming approaches, and a lot love WebForms and think it is great. Others love MVC and think it is great. That is why we are investing in both. " So, to me ...


60

You are conflating the Razor syntax with separation of concerns. Separation of concerns has to do with how you structure your code. Being able to use C# in views doesn't prevent that. It has nothing to do with separation of concerns as such. Sure, you can structure the code in your view to not comply with separation of concerns, but what about C# code ...


53

I know microservices are all the rage right now, but they aren't always worth it. Yes, loosely coupled code is the goal. But it shouldn't come at the expense of a more painful development cycle. A good middle ground would be to create a separate data project in your solution. The data project would be a .NET class library. Your ASP.NET MVC project would ...


51

You cannot possibly avoid building an API. Even if you build "just a Website", it will still need to get its data from your backend somehow. However you decide to do this, that is your de facto API. Knowing this, the real question isn't whether to build an API, but how to build it. You can do it on-the-fly as an ad hoc thing -and indeed, many Websites are ...


47

Stateless - There's no memory (state) that's maintained by the program Stateful - The program has a memory (state) To illustrate the concept of state I'll define a function which is stateful and one which is stateless Stateless //The state is derived by what is passed into the function function int addOne(int number) { return number + 1; } ...


39

I don't see any reason for the Repository pattern to not work with Entity Framework. Repository pattern is an abstraction layer you put on your data access layer. Your data access layer can be anything from pure ADO.NET stored procedures to Entity Framework or an XML file. In large systems, where you have data coming from different sources ...


37

I recently switched from using in-line SQL queries to using EF and here's what I've found: Pros Much faster to build the DAL (love not writing the SQL queries!) Much easier to maintain No longer need to remember to parse my input before building an in-line sql statement, which means less chance of a SQL injection attack (of course, it's still possible ...


33

stateless means there is no memory of the past. Every transaction is performed as if it were being done for the very first time. statefull means that there is memory of the past. Previous transactions are remembered and may affect the current transaction.


33

Generally, you want your Controllers to do only a few things: Handle the incoming request Delegate the processing to some business object Pass the result of the business processing to the appropriate view for rendering There shouldn't be any data access or complex business logic in the controller. [In the simplest of apps, you can probably get away ...


33

Rather than directly answer the question, my response questions the assumption made in the question. That is, the assumption that Razor was built for MVC is incorrect. I work at Microsoft on the ASP.NET team and have first-hand knowledge of this. Razor did not start out as a view engine for MVC. It was created for ASP.NET Web Pages, which is probably as far ...


32

I am a complete and total convert to ASP.NET MVC and have not looked back, that said I do still have to maintain several very large WebForms apps. Here's my take on it: WebForms Use these when you have some serious heavy lifting to do with grids. The grid controls are really very nice when you have a simple dataset that fits nicely in a tabular format and ...


28

No you shouldn't. If you don't have immediate plans to create alternative frontends (like mobile or desktop apps or separate web application) which access the same backend, then you shouldn't introduce a web service layer. YAGNI. Loose coupling is always desirable (along with high cohesion), but it is a design principle and does not mean you have to ...


27

My company has one application built like this. Initially we were commissioned to build a back end with API for a front end that another developer was creating. When the other developer couldn't develop that front end we were commissioned to build the front end too. While there are definitely benefits to this approach there is a huge disadvantage: cost. The ...


25

Actually there is a push back in the .NET world against these very things you mentioned. In the first example you gave however, the routing engine is given a convention for mapping the default route. The very fact that the routes are dynamic make it nigh impossible to use a static configuration. You also mention XAML/WPF, both of which were under ...


24

Here's one take from Ayende Rahien: Architecting in the pit of doom: The evils of the repository abstraction layer I'm not sure yet whether I agree with his conclusion. It's a catch-22 - on the one hand, if I wrap my EF Context in type-specific repositories with query-specific data retrieval methods, I am actually able to unit test my code (sort of), which ...


23

I have developed real applications with both Rails and ASP.NET MVC, but this answer comes with a significant caveat: I learned and developed with pre-version 2 Rails, so it is entirely possible that I am vastly out-of-date with my Rails knowledge. That being said, I don't think that there is anything that can be done with one but not the other. Given any ...


22

This answer is going to get downvoted into oblivion but, on the whole I see WebForms as being for cargo-cult programmers, while MVC is the technology of choice for more seasoned developers who understand the importance of simplicity & maintainability.


22

Stateless means that HTTP doesn't have built in support for states. i.e. you can't store if a user have logged in or done something else. The most common solution is to use sessions to overcome that problem. This means that you have to be able to include a session identifier in each response or request. It's either done by creating a session cookie or by ...


22

You should try to meet two goals: Uniqueness, and usefulness. Using a GUID guarantees uniqueness, but one day the files may become detached from their original source, and then you will be in trouble. My typical solution is to embed crucial information into the filename, such as the userID (if it belongs to a user) or the date and time uploaded (if this is ...


19

Here is a basic syntax comparison Razor @foreach(var item in View.List) { <span>@item.Name</span><br/> } XSLT <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="item"> <xsl:for-each select="name"> <xsl:value-of ...


19

private void Demo() { // Do something, given that the result doesn't matter. } public void Do() { Task.Factory.StartNew(this.Demo); // The following line will be executed without waiting for the result. DoSomethingElse(); } Note that starting a method without caring about the result or about exceptions it can throw is risky. If an ...


18

I'll share the way I ended up doing this, that was part of the original question. First, the problems I encountered: With customErrors on (i.e. in production) the global HandleError attribute swallows exceptions and renders your error view, but then you can't log it with an addon tool like elmah, since elmah never sees it. You could log it in your view I ...


18

I HAVE successfully used XSLT as a web presentation tier... in 1999. In the last 12 years, much better options have come along. Do yourself a big favor, and use Razor. It's a pleasure.


17

Process that people should be doing on a job as a new hire Initially look at the code Small bug fixes Bigger bug fixes Feature Requests - Adding something to an existing piece of the puzzle New things - Creating something from nothing Rushing a green developer with no domain experience too far too fast will cause way too many problems. You're going to ...


17

Is there maybe a more stripped down starting point I should use if the VS template is adding a lot of stuff I don't need? These VS templates are good to trim down initial setup and learning curve in the beginning, however you would need to customize them for your real project needs. For example, on this site http://www.reviewstoshare.com, my friend ...


17

This sounds suspiciously like an inner platform. Here are the potential problems: You'll be writing queries that query the database for what information to query (metaqueries) first, rather than queries that simply retrieve the needed information. You'll be subverting the role of the database, which already provides metadata capabilities such as rows, ...



Only top voted, non community-wiki answers of a minimum length are eligible