What is the best strategy ti return when business rule is not correct

T

Tony Johansson

Hello!

I have a GUI class and then another class is called(animalManager) where
some business rules are checked for example
that some food is not valid for some animals.
What is the best way to return to the GUI. ?
I think it's important for the GUI to know what kind of business rule that
failed.
Is it a good approach to throw exception telling some info

//Tony
 
A

Arne Vajhøj

I have a GUI class and then another class is called(animalManager) where
some business rules are checked for example
that some food is not valid for some animals.
What is the best way to return to the GUI. ?
I think it's important for the GUI to know what kind of business rule that
failed.
Is it a good approach to throw exception telling some info

If you need to propagate errors between layers or
over more than a single call within the same layer,
then exception is ab obvious pick.

Arne
 
A

Arne Vajhøj

Throwing exceptions are expensive.

Expensive is relative.

When it is user input, then the performance impact
is negligible compared to the cost of bringing that
user input in.
The business object should have an exception list/collection for
collecting error messages within the object that is cleared each time
the object is validate. Any and all broken rules validation messages
about the object should be loaded into the business object's error
collection.

If the errors.count > 0, then there was a validation error where you
would proceed to bind the collection to a control to be displayed to the
user. Otherwise, if the errors.count in the object is 0, then the object
passed the validation rules.

What would be returned to the UI is the object and the collection of
errors within the object.

That technique is frequently used in the UI. Several big
web frameworks use it.

It is not a very good fit for passing from business layer to
UI.

Arne
 
A

Arne Vajhøj

I disagree, since I have sent DTO(s) from the MVP over the WCF Web
service and injected the object graph into a Workflow to validate the
object and object graphs within the object. If it was not valid, send
the DTO back to the UI. No one said anything about passing anything to
the business layer, other than you.

Well - I did not. I talked about passing from business layer not
to business layer.
As a matter of fact, the objects can
validate themselves up at the UI before they are ever sent to the BLL.

That is what should be done.

But a couple of lines about you talk about validating them
after sending them via WCF to your workflow.
Also, I am somewhat getting tired of you trying to give your spin on
things. You need to keep it to yourself, as I could care less as to what
you are talking about or think.

That is not how usenet works.

You post.

You risk people comment.

Arne
 
A

Arne Vajhøj

No it doesn't. When people tell you to back off in real life, you are
not crazy enough not to back off and mind your own business. I am not in
your face about anything. So am telling you to back the hell off.

Somehow I am not surprised that you are the type that
in real life tell people to shut up when they tell you
that you are wrong.

But I am surprised that anyone voluntarily confesses
to that ...

Arne
 
A

Arne Vajhøj

No one has the nerve to do it, since I am 6ft 6inchs and about 305
pounds. The only reason you show any bravado, is because you are behind
a keyboard, monitor and mouse.

I repeat: amazing what people voluntarily admit to on
the internet.

Arne
 
A

Arne Vajhøj

One other thing here, you are an a-wipe that thinks what you say is the
gospel, and the only right way is your way, a typical lunatic.

Well - I explain why I consider this and that the best based
on good software engineering principles.

Other only have the intellectual capacity to name calling and
attempting to intimidate people via their size.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top