thanks in advance.
Somewhere else I asked the same question but about scalability. Please let's not confuse both terms. I'd really like to understand what particular parameters I should look at when assessing if a framework performs acceptably.
I mean parameters such not over-querying the database for simple tasks just because the ORM above is not very well written, etc... Please let's try to answer this question without diving into a particular technology.
Lastly, let's assume that the underlying hardware is any that allow you to perform well, that is to say, there is no hardware bottleneck. I don't want a software that uses a cannon to kill mosquitos :).
Thanks again.
I mean parameters such not over-querying the database for simple tasks
just because the ORM above is not very well written, etc... Please
let's try to answer this question without diving into a particular
technology.
Succesfull ORM technologies are not under-performant. But if your web application is extremely simple (you don't define the scope of your question) then introducing a robust ORM that would be an overkill. Do a DAO pattern yourself instead.
Finally you can always do test measurements yourself to evaluate if the performance suits you
Related
I was wondering about the best practice when using the MVC pattern.
When you develop an app for a client, you want to think business. You want to think as the customer would. That's why I'm wondering :
Isn't it better to develop the view part, without any data treatment, so the customer can validate it ?
I see this practice as powerful as TDD is, I mean if you clearly know what your program will look like, you know which treatment it will require, making the model part a bit more concrete and business oriented, instead of making it too abstract and global.
I can not see downsides to this, so if you can see some, or explain me why it's not a good idea, please do.
Thanks :-)
The main benefit, as I see it, would be the ability to provide the client with hands-on prototype.
It not uncommon for clients to change their mind, because often, when they hire a developer or company, they actually have only a vague goal for the end product. This way you would mitigate the risk of large scale changes late in the projects life-cycle.
As for implementation of such approach, I would recommend for you to look into concept of "presentation objects" (Fowler has this annoying habit of slapping "model" on every damned term).
With presentation objects you would gain an ability to "shim" the data from model layer's services. And it also would let you figure out, what exactly services (and service calls) will you *UI layer( interact with).
Note: of course I am assuming that with "MVC" you do not mean some Rails-style abomination, where "views" are just dumb templates.
question:
i'm building (or trying to build) a front end for an enterprise level web-app. the existing structure is driven by stored procedures (sql 2008 db). A stored proc is implemented as a class that ultimately handles the execution and the results are returned as an object.
i'm new to this game and would welcome an explanation about how my time would best be served...i read a repository pattern is a best practice, but all of the examples i read implement Entity Framework or Linq, etc..do i need an ORM? why or why not? i'd like to be able to have a maximum performance environment so that users can play with those result sets. thanks in advance
Well, I would suggest deciding on your use cases.
Some of the things that nHibernate / ORM's generally are not good for are:
Batch jobs.
Reporting
So if your work primarily involves either of those then you're best off not wasting your time, that being said there's nothing wrong with having multiple strategies... Building out a domain model is great for simplifying complex business rules, performance is generally very good too... Reporting and batch jobs can be built out separately, there's no reason why the different strategies can't co-exist... I woul however do my best to keep them decoupled...
So if you've got a big hairy business logic layer and it's littered with datasets / data access code and business logic IN your stored procedures then you will likely find it worth your while to invest in an ORM, but consider it a re-factoring step... IE you're improving existing code and making it testable before extending it...
In any case there's no one 'best' answer, the smartest thing I've done at previous companies has been to build new functionality (Test driven of course) in whichever data access pattern that seems to make sense to the functionality... Keep interfaces clean and decoupled... After doing that for awhile it usually becomes obvious which strategy / pattern is best suited for the application overall...
Good luck
Your question is somewhat unclear. Stored Procedures are SQL queries stored on the database which are used to interact with the data. However, it sounds like you already have an existing data access layer (DAL) which uses stored procedures and returns objects to you to play with. If this is the case, I would not throw away the entire data access layer and replace it with EF or any other ORM. Unless the existing DAL isn't working for you for either design or performance reasons, there's no reason to reinvent the wheel.
Have you applied test driven development to purely sql scripts? if so what has been your experience. Is it worth it? What are the rewards? disadvantages ? etc.
I have played around a bit, to be honest I would rather generate my regular DB code. I was this awhile ago and thought it was interesting. http://sourceforge.net/apps/trac/tsqlunit/
Most (all?) of my database "scripts" are generated, not hand-written. And, I avoid stored procedures and views. I basically treat my database as a file. The testing and logic stays in the application layer (where it belongs, IMO).
This approach works pretty well for me and the kinds of applications that I develop. It might not work so well in other situations.
For me the answer to your question is "not applicable".
SQL was the vehicle for one of my very first TDD collaborations. This was in a setting where I was an application developer (C++, I think, but it's been a while) and we had a DBA with responsibility for all queries. I wouldn't choose to go that route again, but that's another story. The time came when I needed a new query, so I wrote up some test data and expected results and sent it to the DBA; he wrote the script and thanked me for making the requirements so clear and precise.
TDD as it's usually practiced doesn't fit well with SQL (or maybe the other way 'round), but it's not really all that hard to adapt the practice to work well with the language. One-button testing may be a little harder to bring into the mix, but it's rarely hard to run a query.
I'm a little hesistant against to use it because I believe there can be some issues with it, but I don't really know it before I've tried it. Or is it good enough to use it or should I do plain sql statements? Does anyone know?
It has it's advantages and disadvantages. One advantage is that all queries are automatically formatted, escaped, and optimized. This is a big plus on the security side because we all forget to do everything that can be done to protect ourselves sometimes. Active Record doesn't forget.
One disadvantage is that it sometimes is difficult to construct complex queries with it but that's easily taken care of by just running your own. All in all i would highly recommend using Active Record. We have been using it for our enterprise level application for the last 1.5+ years and it hasn't failed us yet.
How do you like your CRUD programs. Code-generated, framework-driven, or manually written?
My experience with code generators is that they're a good start but after the changes have settled down I usually want to rewrite the modules by hand. Of course, that can become a maintenance problem. But it really turns into a "how long is a piece of rope" question. Which generators, frameworks, and resources are you dealing with? Some of them are horrors to deal with, others work all right.
I like code generators with custom templates for the following reasons:
Reduces coding effort
Easy to make global changes
Embed architecture in templates ensures developer compliance.
Less chance of coding errors.
Consistent functionality
Less to test.
In fact, using code generators I was able to create, or recreate, the store procedures, entity classes, and DAL from a modified database with 60+ tables in minutes when the schema was updated. By using custom templates, I was ensured that the all layers worked with my naming rules and ensured proper error handling and prevention of double insertion.
Great for fixed price contracts. If it is hourly, then you might want to do it by hand :-)
I like a mixture of framework driven and manually written. I've done a little bit with NHibernate and LinqtoSql and sometimes the queries they generate for me need a little bit of help.
This really depends on the size of your application. Hand-crafted Data Access Layers make the most sense for a very small application as you have ultimate control but for any medium to large size application I would recommend a code generator. I've had various experience with APEX SQL (not great), LINQ and Subsonic (both very good). I'm just about to evaluate a Telerik ORM shortly but I imagine that will be pretty good also.
If you use .Net use Linq, then it is easy to maintain. LinqToSql makes it easy to update your data model with out having to change the code a whole lot.
In my opinion code generators are a sign of bad design and violate DRY. Where as a good framework will have you maintaining less code. With frameworks you also end up extending and refactoring code rather than a code template.
Frameworks are choice one, if I need to use a code generator I like to throw together a quick Perl script that generates the code so I understand exactly what is getting generated and why.
They are useful if you view your users as data entry clerks to maintain your database tables for you. They help minimize the programming time required to meet minimum requirements.
If you want the quality of your work to reflect something better than that, the best that can be said for them is they might give you a jumpstart if you're not too sure how to do simple consistent UI screens yourself.
Personally I find that refactoring them into something useful and attractive based on real Use Cases takes longer than doing it from scratch. They're the kind of technique Dilbert's pointy-haired boss would love.
I find a good framework for CRUD logic better than code generators. I have run into situations when a complex set of tables generated a terribly slow query to produce the result.