|
So, what happened???
Jon
Smith & Wesson: The original point and click interface
|
|
|
|
|
I went back to work
|
|
|
|
|
martin_hughes wrote: I went back to work
Oh !@#$#@! Your post was great. Raised all sorts of questions in my head. Now I'm going to have to work on the answers? . . .Maybe I could post a PLS HELP URGNT about it. . .
Jon
Smith & Wesson: The original point and click interface
|
|
|
|
|
I have an Export Engine that uses an XML export definition to create mainly CSV files from a database. I would like to build in exception tolerance at the field and line level, so that when testing a new definition or a change to a definition, I just log all exceptions, and deal with them as a batch after a test run, rather than have the run abort at each new exception found. Exceptions that should be tolerated are invalid field names, null values etc.
Are there any established patterns for implementing this?
Pits fall into Chuck Norris.
|
|
|
|
|
I would use a validation engine for this, and just build up a list of validation failures. The beauty of a validation engine is that you can add rules iteratively and the engine should be able to cope. I wrote part of one a while back that you are more than welcome to take and add your rules to. Send me a mail for it.
|
|
|
|
|
Thanks Pete, I'd love to have a look at your engine, but what are you suggesting I validate? The definition, i.e. does the query execute, do all the output fields map correctly to input fields etc? Or validate every row of input data against the output schema?
Pits fall into Chuck Norris.
|
|
|
|
|
It's up to you what you validate, but you could do things like validate that mandatory fields aren't null, that field types don't conflict with field values - that type of thing.
|
|
|
|
|
I've decided, in light of this being a financial application, any exception handling or avoidance, is not worth the risk, so I'm revising my strategy to only possibly increase the number of exceptions thrown. Applying a validation engine here would be overkill, as most operations generate exceptions for fault conditions, e.g. invalid field names, but I'd still like to see your engine and maybe use it as inspiration elsewhere.
|
|
|
|
|
Brady - send me an email (through the email link here) so that I can get an address to send the project to.
|
|
|
|
|
Maybe have it raise events rather than throw exceptions, perhaps when in a "testing" mode or something.
try
{
}
catch ( System.Exception err )
{
# if Testing
OnExceptionCaught ( err ) ;
# else
throw ( err ) ;
# endif
}
|
|
|
|
|
Hi at all,
my team is stuck with a problem that we get not solved reading books as we do not get answers from reading rather than more questions.
To be honest, we are OO-novices.
Situation:
We are developing as 3-tier application with .Net 2.0 using remoting for the communication between the client and the application server.
We have some complex business logic to implement that requieres certain checks that may result in terminating the business process.
Problem: we have to give the user a exact status information what went wrong to give him a chance to correct the problem. A message "your action was not completed successfully" is not enough, we have to be very precise.
Our first approach was to use exceptions (user exception classes derived form "ApplicationExcpetion") but as far as we found out by further reading this is not recommended as exception should only be used as the "emergency exit" if something unexcpected happens. This is expected behaviour of the method.
And now the question: how else can we solve the problem?
Status values can not be return values (which is also bad design), and just returning "NOTHING" in a object doesn't do the job for us. Remote events are critical to coordinate with the running business process that will terminate.
Any solution or a hint for further reading on this problem is greatly appreciated.
Thank's in advance
Thomas
|
|
|
|
|
Hi,
I would use Exceptions for everything that isn't the normal flow of things; they are not
just for "emergency exit", they can signal whatever it is you want signalled. And the
advantages are clear: they are objects, can't get lost, and can be chained thru InnerException.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Theres nothing wrong with throwing an exception containing a list of business rule violations.
The "exceptions should not be used in normal program flow" is because exceptions take a non-trivial amount of time to throw. This rule refers to constructs like so:
while(i++)
{
if(i>10) throw;
}
If an action is occuring, and a business rule is broken such that the action can't proceed, then an exception is ideal to signal this. It backs up through the call stack, letting every catch/finally block perform its tasks, and effectively backs cleanly out of the action.
A benefit of exceptions is that its difficult to ignore them without explicitly 'eating' them. I've seen several bugs due to people ignoring return codes (usually with crappy code-generated data layers with bool businessObject.Save() - and people ignoring the return code).
|
|
|
|
|
I too wouldn't hesitate to use exceptions for exceptional circumstances, that being said, broken business rules are a little too common for exceptions:
Normally the business objects would do the validation, check business rules in the middle tier assuming your bottom tier is your data access tier. Also normally the business object has some state for the validity of itself so it should have something like an IsValid property that the ui layer can check and use to allow or disallow saving etc. Also a collection of the current broken rules and a easy to retrieve text property of all of them.
For example the UI layer has a save button, the save button is disabled as long as the IsValid property is false. It also has a little icon representing broken rules, maybe a red asterisk, you mouse over it and a list of broken business rules pops up. In my apps the property is linked to the field on the form so that each field can display a red asterisk if a rule is broken on that input field or area of the app, when you mouse over it you get the localized text of the problem.
I.E. the UI layer should check *before* attempting to save / update so that there is no need to throw an exception in the first place.
In my code it throws an exception mostly if someone using my business objects in my api ignore the isvalid and attempt to save anyway.
So let's say you have a middle tier business object with a set of properties, upon setting a particular property it checks a business rule / validates, something is wrong then it sets the IsValid flag to false and sets a text of the broken rule in the collection.
Of course if an error develops at the remote server then the practical way to pass back that status is through an exception and you can easily set the text of the exception to anything you want so detailed info can come back this way as well.
"The pursuit of excellence is less profitable than the pursuit of bigness, but it can be more satisfying."
- David Ogilvy
|
|
|
|
|
Hi,
Please try to implement Single Tone pattern design in you Application:
Managing Methods and events in listener place hold.
1.Using event Listeners Pattrens
Eg:If You want Display Exact error messages for your events: You need to develop cusstome message class.
this class having methods and properties to get data and relevent data it compare in DB.
If any Action is going wrong those data recorded in event Logs:
Process Like: Create Custome Message class
2.Inherite properties at event firing place.
3.All record your meesages in Db
4.Compare control Id and Status with message.
5.Dispaly Your Message.
If you wana more clear let me know on mail: msudhanreddy@gmail.com
with Regards,
MAdhu.k
|
|
|
|
|
|
A minor, but somewhat important nit to pick. When you talk about passing data between tiers, you imply that you are talking about physical machines. From your question, however, it would appear that you mean that you have three layers. Although it's possible, even likely, that each layer will be hosted on a separate machine, that is not a requirement of multi-layer design. (It's also possible, even likely that you'll end up with more than three layers, but its usual to only have three tiers. For instance you might have a UI Layer that hosts both a UI Component layer and an Application layer that serve both a Win and a Web version of the app.)
Jon
Smith & Wesson: The original point and click interface
|
|
|
|
|
Hi All,
I'm been task to migrate a classic ASP website to ASP.NET - I intend to migrate to ASP.NET 2.0 (bare min.) using C#.
There is a processing engine which is causing much problems and dims the lights out when this is run.
What the processing engine does:
From a conceptual level it's a very straightforward process. What this processing page does is reconciles data against two data sources and if there is match on the first level of Ids then it goes to the next level of Ids and checks if there are mismatches for that level. If there are then it records those mismatch records. If there are matches at this level then it goes to the next level and check for mismatches between records at this level. Keep in mind that all these ids need to be linked together back to the master Id. My Id structure is like this:
Master ID - check datasource 1 against datasource 2
Match goto to second level
Child1 ID- check ds1 against ds2
Match goto to third level
GrandChildID - check ds1 against ds2
Match goto to fourth level
GreatGrandChildID - check ds1 against ds2
How this is handle in classicASP:
Currently this contains a huge initial openrecordset which is never closed. It does a 4000 code line do loop and creates embedded SQL with "Select * From" queries and creates recordsets and opens the recordsets but never closes those recordsets. Mind you when a user has to process say 50k to 100k records this thing absoultely bombs out. And in the creation of SQL on the fly it creates an IN function with over 1,000 ids in that IN clause which maximizes the the total number of Ids you can have in IN functions.
Design Questions:
1. Where to begin with this?
2. Should I go database processing or business rule engine?
3. How to improve workflow and performance for records reaching close to 1 million?
4. Should I create an interface for the user to add more rules?
Any starting points or case studies to at least get me to design mode. I would be most grateful.
Thanks,
|
|
|
|
|
I'm sorry, but I'm not really seeing your design here. Where do these Ids come from? Could you give a sample of data so that we can see what the problem really is. Instinctively, I can see that there are easier ways to achieve this but without more information from yourself there's not a lot I can do to help (except state that a BRE isn't going to help you here).
|
|
|
|
|
Sounds almost like a search engine or document searching app that is querying a dictionary and matching document ID's.
I've written one of those before although that's not entirely relevant, but what is is that all the hard work should be at the sql server, also it's potentially possible to do almost any query in one trip, not in a loop if you do some hard refactoring of the data and or add speciality tables just for this process. Those thousands of id's, that just sounds..well wrong. I would look first at the database and potentially refactoring it before I'd even consider anything else.
You say you've been tasked with going to asp.net from classic asp, to be honest that's not related at all to the real problem, you need to find a solution that *doesn't* involve looping, separate queries with thousands of id's in the IN clause before you do anything else.
And don't say you can't touch the data, there's always a way to simplify this stuff, sometimes building a separate table entirely from the existing data, who knows but what you are describing is just wrong.
"The pursuit of excellence is less profitable than the pursuit of bigness, but it can be more satisfying."
- David Ogilvy
|
|
|
|
|
I want to develop an application in .NET. Basically i am answering one question but using different algorithms. So therefore, i prefer it doing it seperately. And once i get all the algorithms working, then i can bring all the implementation together under one single project. Yeh i will be defining classes not assemblies.
So what is this design methodolgy called so that i know what i am doing. I can see so many designing methods and i am confused like which one is best for me..I have read waterfall approach, agile methodology, etc etc...
Thank You
|
|
|
|
|
What you need to do is define an interface that exposes the public face of the algorithms you want to develop. Then you could create individual classes that implement the interface using something like Test Driven Development. Bringing them together is the easy part - and you may want to look at something like a Class Factory to choose the relevant implementation at run time.
|
|
|
|
|
|
ok Test Driven Development
|
|
|
|
|
Julia4u wrote: Basically i am answering one question but using different algorithms.
Sounds like a classic case of designing by contract (a la plug-ins).
See the Bridge[^] pattern and for a concrete implementation of plug-ins, see .NET 3.5's new System.AddIn [^] namespace, although I think that may be overkill at this point (unless you want discoverability, versioning, etc. for free).
/ravi
|
|
|
|