Hi, "Concurrency is a problem that can make or break a software package, depending on how it is solved. Simply saying "Our O/R mapper supports optimistic/pessimistic concurrency." doesn't help you one bit, because can you write more efficient software when
these two are supported? In 100% of the cases you can't, simply because BOTH cause loss of work and thus are not efficient." In tipical n-tier client/server (ex: Web Browser/Web Server/DB Server) environment optmitimistic locking is used almost always in one
way or another. You only have two options: 1) Code business rules in SP's on the Database Server. This is the most effective way to control concurrency, and it is the fastest. 2) Code business rules on the midle-tier and leave a transaction open blocking the
data that will possible be updated (BAD realy BAD, dead lock problems) 3) Code business rules on the midle-tier and make use of SELECT FOR UPDATE before update co-related data. You need to be able to SELECT precisely the fields you need to calculate or update
data, in order words you need to have full access to the Database to be efficient (no super-dup DAL is needed), Note that a DB transaction needs to be in open while business rules are being applied (thus sometimes not quitly following the policy, use con late,
release con soon), otherwise there is no way one can guess that a value used is the most current (again deadlock problems can occcur). 4) Code business rules on the midle-tier and use pessimistic locking. This one of the most used strategies becouse it avoids
deadlocks, allows one to use a con late and release cons very very soon so optimizing resources. It suffers the problem failed update attempts. 5) Code business rules on the midle-tier and use pessimistic locking with eavy caching. It increases the problem
failed update attempts. O/R Mapper use heavely 4) 5). DAL Generators use heavely 4) and allows one to use 1) easely. Like most of the people I guess, I've been using 1) and 4) heavly. And I must say with success (more 4 then 1). The question I ask to the forum
is why do we need Business Entities as defined by Microsoft or Entity Beans as defined by J2EE? I have one opinion. Mainly becouse we want them to be able to be serialized so that they can be passed on across mutiple tiers independently of their physical location.
In terms of application model Business Entities don't change a thing (they works as DTO's and we have been doing that with Structs and custom data formats, etc etc). In fact DAL's where and could be build pre-.NET era. Business Entities facilitates the development
of web-services, remoting in terms of data transmission, that is why they are so important for .NET as it is a framework built to develop distributed applications. Nuno PS: There is also another good thing about using Custom Business Entities, but that is
only if you are working with Visual Studio. For me using Custom Business Entities due to this is silly, but hey I bet most prople use them becouse of this :)
Nuno: all fine, but you completely ignore the aspect about concurrency I was trying to illustrate: loss of work, no matter what kind of low(er) level concurrency scheme you use. EVERY piece of software which allows users to do work which is then later discarted
due to a concurrency violation is badly designed and costs money. Therefore talk about optimistic/pessimistic concurrency is not that useful: it's the ability to lock out functionality for a user A so A will not do work which will never be persisted anyway.
Read my article about concurrency, it contains examples about the loss of work I refered to. You focus on implementation details in lower tiers of the application. That's beyond the point: you already have decided to use one of the schemes, which automatically
implies software which will be less efficient, simply because there WILL BE situations which will cause loss of work and thus loss of time and THUS loss of money. Developers should more focus on the total aspect of software development for a change: implementation
details are important AFTER design decisions have been made, not before. Oh, and before you say: "But concurrency is about data-integrity": deciding when and who will change which data and thus preventing loss of work implies data-integrity implicitly.
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
Frans, thanks for your reply. I agree, the term 'prototyping' has its own meaning, especially in the IT world. But as stated before, I'm currently evaluating the DeKlarit tool, and they provide a 'Business Framework Prototyper' for working with the business
components right after generating the code. That's why I used the term in this context. Two more question regarding LLBLGen Pro: - Are there any sample applications based on LLBLGen code that you would call best practices examples? (The Northwind examples
on your website?) Since I want to delve into the LLBLGen concepts it would be nice to have some blueprint applications for orientation... ;-) - Does LLBLGen Pro support iterative programming? I.e. is it easy to create derived classed that need not to be completly
reworked each time the underlying catalog definition changes? Thanks, PontiMax Ps. What does your statement 'The future of LLBLGen Pro will be near what Microsoft has shown with MBF' mean for a LLBLGen Pro user?
FYI, for the open source version of LLBLGen, I've written the first part of an examination of it
here. As Frans says, he is not working on the open source version, so keep in mind the softwares not going to be upgraded, except maybe by you. But I have found it helpful to play with
LLBLGen open source. I don't think you can consider the open source version a true O/R mapper, but more of a DAL generator. From what Frans has posted, the Pro version more fits the O/R mapper definition. HTH
Eric Landes
MADNUG President http://www.madnug.net
Crystal Alliance Editor
Blog http://aspadvice.com/blogs/elandes
Microsoft MVP
I agree, the term 'prototyping' has its own meaning, especially in the IT world. But as stated before, I'm currently evaluating the DeKlarit tool, and they provide a 'Business Framework Prototyper' for working with the business components right after generating
the code. That's why I used the term in this context. Ok. The prototyper tool is ok, it just has the danger inside itself that it will end up being the base of the app which will be build :) (which is not that good ;))
Are there any sample applications based on LLBLGen code that you would call best practices examples? There is an example indeed which shows some aspects of what can be done. 'Best practises' are things that are different for a lot of people. People in
this thread for example have sometimes very different visions of what is 'best'. This results thus in 'best practises' based on these visions and will probably not be what others think would be best practises. The tool tries to create the overhead-code that
is between BL code and the database, so you can start developing BL code right away.
Does LLBLGen Pro support iterative programming? I.e. is it easy to create derived classed that need not to be completly reworked each time the underlying catalog definition changes?
I don't know what you mean by 'completely reworked', but you can't avoid having to alter some code when your database changes significantly: products who advertise differently simply lie: a table is split into two tables, a table gets 2 non-nullable fields,
a relation is removed/added, a PK is changed etc. The current template set will generate code which gives 2 classes per entity: one to put your own code in, and one for the plumbing code for the framework. Extending these classes is ok, however corresponding
collections can't automatically be filled with these new classes, unless you also extend the factories and the property descriptor classes. This month we'll release a different template set which will allow deeper inheritence (unlimited) in combination with
collections and property descriptors. Ps. What does your statement 'The future of LLBLGen Pro will be near what Microsoft has shown with MBF' mean for a LLBLGen Pro user? That they will get the update for free.
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
Eric: LLBLGen 1.x is a dal generator, nothing more. It does no mapping whatsoever, it simply generates CRUD procs, some extra procs and classes to call them :). So considering the open source version even close to an O/R mapper is not correct, it has nothing
to do with it. :)
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
Hi Frans thanks for your reply, "Nuno: all fine, but you completely ignore the aspect about concurrency I was trying to illustrate: loss of work, no matter what kind of low(er) level concurrency scheme you use. " At low level and whent it comes to data storage
and maintanence I see that concurrency is about mantaining data-integrity in the midst of multiple simultaneous accesses/updates. I agree with you that this alone as impact at the higher livel, possibly turning it to be a problem of scheduling "work". But
I don't see how this is related to DAL Generators and O/R Mapper. Why? As you say it is a higher level problem so it needs to be dealt by the Business Layer and possibly using some kind of meta-data around Data Objects or Business Objects. Your white paper
using different words actually seams to imply that the problem of scheduling work mostly is solved by using a checkin/checkout policy. Meaning that when a peace of data is checked out no one can check it out until is checked in (if not then I take this back).
This is basically a Business Rule to me as you are basically serializing work (what if they don't want it to be serializable). This solution (checkin/checkout) alone does not solve the problem of scheduling work for all intents and purposes (even the most
common). Before proceeding note that sometimes you don't even need to use this simple work scheduling policy (checkin-checkout) becouse you know that there is a minimal possibility that the same resource will be updated concurrently. But if you do use this
policy at least allow one to force a check-out otherwise work may be lost as an item is checked-out for ever, and possibly incuring in work dead ends. A few more comments regarding checkin/checkout. In you article you seam to consider that record is the atomic
unit in the context of checkins/checkouts. Having worked as a Product Manager of a CMS I must say that we considered that the field might be the atomic unit of check-ins check-outs (even in terms of versioning, take an Image on a web page for instance). Sometimes
we even consider that is not only a record that is the unit of "work" but a set of records (Take an Order and its Orderlines). Moving further from checkin-checkout there also another way to schecule work. This is through Workflows. Basically a workflow is
composed by a set of Activities, each perfoming a set of possible Task. When a task of set of Tasks is peformed then another acitivity starts. It is quite common to find workflows engines (or build your own) that allows one for reach Activity to set up the
set of users that can edit/change or create a set of Data Objects or Business Objects. The point is that just a small set of users participate on an activity. This concepts actually map very well into what is considered a Business Process. Basically this minimizes
concurrency problems and avoids explicit work serialization as it can be annoying and counter productive. "That's beyond the point: you already have decided to use one of the schemes, which automatically implies software which will be less efficient, simply
because there WILL BE situations which will cause loss of work and thus loss of time and THUS loss of money. " None of the concurrency handling mentioned where developed to make ones solution efficient in its problem domain, but assure data integrety, so it
is quite natural that they don't address the problems that you have mentioning. You never loose Data or Data gets corrupted, at most you waste time. I agree with you that is the solution that should be built in order for one not to waste time, but hey that
is why we build IT solutions. I think I never implied the contrary. All in all I miss how can a O/R Mapper or DAL Generator help me build workflows and implement check-in check-out policies based on the state of data or Business Object. Becouse in the end
when we talk about scheduling work the is no unified mechanism to dealt with the issue and this are part of things that we code on the Business Layer, and unless you providing me with an workflow engine, plus some bells and whisless I missed, the point of
this when it comes to the title of this thread "O/R Mapping tools for .NET" Frans the article is very nide indeed, but IMHO it uses a false dictonomy. Becouse the best method as you put it does not fall in the scope of handling data integrety or lost of work
but scheduling work towareds effciciency (not to wasting of the user in perfroming an task that is already being performed or was already performed), so the Business Layer (the Problem Domain solution). Nuno Lopes
One more thing, the locking strategies such as "Optmistick locking" and the respective strategy to deal with write-write conflics (in sum your First Save wins, Last Save wins) where developed to deal with two things within the scope of data access concurrency:
* Data Integrety; * Resource contention. And not concurrency in terms of business tasks or activities (work) and its optimization. For the later we can use multiple implementation strategues such as checkin/check-out, workflows, to enforce work policies. The
only thing that can be comparable between both contexts is that within both the term (concept) "concurrency" can be used to describe its dynamics. But similiarity stops there IMHO as the forces driving the strategies needed to deal with the their problem scopes
are different in nature. Nuno Lopes
I don't see why optimistic / pessimistic concurrency is not related to scheduling work: the actions they are used in are the result of actions taken by processes and/or users. ANY action taken on the database using optimistic or pessimistic concurrency schemes
will result in loss of work and are therefore inefficient and should therefore be avoided: if a concurrency conflict arises in a system, and that can happen, the system should be optimized to avoid it the next time, because the conflict WILL result in actions
which were void: they can't be executed or are overwriting work of others. The nature of the problem is the same IMHO: you have 1 resource and 2 or more concurrent executed mutation actions. What to do? Well, that's very simple: be sure you don't have 2 or
more concurrent mutation actions to execute. optimistic / pessimistic schemes can help you keep data-integrity up (however this is also a false assumption) to a given level, but scheduling the work more efficiently will also achieve this implicitly! Data-integrity
protection using optimistic or pessimistic locking is a farce. Here's why: two processes do the same work. Based on the concurrency scheme process A or process B is doing work which will be abandoned. However, who says that that work isn't required? If B mutates
a user row, and A has done that already, making B's changes void, who says A's data is correct and B's isn't? (Semantically speaking). After all, data-integrity is about semantic values given to data inside a database: all mutations on multiple tables are
done in transactions anyway which protect data-integrity. Also, for the user it's very stupid to see a screen popping up "You can't save your work because of concurrency schemes" or similar. Every developer who cooks stuff up like that should be abandoned
to filling up printers and coffee machines ;). The reason for that is that the user DOES have to save the work, why otherwise letting the user perform the work? So what to do with a conflict which arises with the optimistic/pessimistic scheme used? This is
UNSOLVEABLE. You can't solve it, because the only thing you can do is tell the user one of two things: 1) you have just voided the work of user ABC or 2) Your work can't be stored because of user ABC who has made some changes already. Concurrency problems
are always related to badly written software-flow: software parts who are allowed to start actions which can LEAD to concurrency problems should be scheduled better and problems should not be solved with a concurrency scheme in the end which will stop mutations
which will make a database inconsistent in some areas (on a semantical basis). Declaring the problems as two different things is the wrong way to go: you thereby ignore the fact what the REASON for concurrency problems is and because of that you will never
solve the real problem, you can only solve the consequences of the problem (by inserting some kind of concurrency scheme). Concurrency problems are caused by something. Solve that, not the results the problems give, because any solution, optimistic or pessimistic,
will always be triggers after the work/process is already finished, which is the worst possible spot you can think of to stop a process/user to do work.
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
nbplopes
Participant
1745 Points
349 Posts
Re: O/R Mapping Tools for .NET
Dec 04, 2003 10:15 AM|LINK
FransBouma
Participant
1509 Points
312 Posts
Re: O/R Mapping Tools for .NET
Dec 04, 2003 10:50 AM|LINK
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
PontiMax
Member
415 Points
83 Posts
Re: O/R Mapping Tools for .NET
Dec 04, 2003 11:57 AM|LINK
ericlandes
Contributor
5475 Points
1095 Posts
ASPInsiders
MVP
Re: O/R Mapping Tools for .NET
Dec 04, 2003 12:15 PM|LINK
MADNUG President http://www.madnug.net
Crystal Alliance Editor
Blog http://aspadvice.com/blogs/elandes
Microsoft MVP
FransBouma
Participant
1509 Points
312 Posts
Re: O/R Mapping Tools for .NET
Dec 04, 2003 12:29 PM|LINK
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
FransBouma
Participant
1509 Points
312 Posts
Re: O/R Mapping Tools for .NET
Dec 04, 2003 12:33 PM|LINK
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
ericlandes
Contributor
5475 Points
1095 Posts
ASPInsiders
MVP
Re: O/R Mapping Tools for .NET
Dec 04, 2003 12:36 PM|LINK
MADNUG President http://www.madnug.net
Crystal Alliance Editor
Blog http://aspadvice.com/blogs/elandes
Microsoft MVP
nbplopes
Participant
1745 Points
349 Posts
Re: O/R Mapping Tools for .NET
Dec 04, 2003 02:51 PM|LINK
nbplopes
Participant
1745 Points
349 Posts
Re: O/R Mapping Tools for .NET
Dec 04, 2003 03:47 PM|LINK
FransBouma
Participant
1509 Points
312 Posts
Re: O/R Mapping Tools for .NET
Dec 04, 2003 04:12 PM|LINK
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)