368 reputation
312
bio website dicasdotnet.blogspot.com
location
age
visits member for 4 years, 2 months
seen Jan 23 at 14:44

Jan
22
comment Where should I place business logic validations?
Ok, perfect. And the question is: how do I send the information about the result of the validation back to the caller?
Jan
22
comment Where should I place business logic validations?
So I would have a method public OperationModel createAccount() and this class OperationModel would have an attribute validationMessage, right? If I do that, for every model that is used in a method that contains has some sort of validation, I will have to take an approach like this, so operation models would end up with validation information and then in the controller I would have to check for something like an isValid property and errorMessage property. That seems interesting, but I have mixed feelings about have this isValid in a Domain Class, but as more as I write, the better it sounds
Jan
20
comment Where should I place business logic validations?
That is interesting and seems a very nice idea. Would you have an answer to the argument that there is still a business knowledge when the controller knows that he has to call that specific validator in order to call the "save" method after that?
Jan
20
comment Where should I place business logic validations?
Just let me know if I understood: you are telling me to use something like the Validator class from sprint (docs.spring.io/spring-framework/docs/2.5.x/api/org/…) and use it to check in the business layer, correct? But if the validation fails, how do I give this feedback to the caller so a message can be shown to the user?
Jan
20
comment Where should I place business logic validations?
@JeffO please correct me if I am wrong, but in a layered architecture, the presentation layer should not access the data layer directly, it should go through the service layer. In this case specially, the business knowledge ("If the user already has an account request, he should not request for another") would be in the controller, instead of the business layer, this is not recommended.
Jan
20
comment Where should I place business logic validations?
@BartvanIngenSchenau in these cases we throw an Exception, but usually this is a exceptional scenario, so the exception is (as far as I know) correctly used.
Jan
20
comment Where should I place business logic validations?
Yes, this is currently our problem. As you said these validations shuold reside in the business logic, but we should neither use exceptions nor out parameters nor an extra object. How shoul I perform the communication from business to view about which validation failed and why?
Dec
18
comment Is it better to use strings or int to reference enums outside the java part of the system?
Yes, we went down this path, but we are using hibernate and we had to add some extra code to be able to parse the value to/from the database and it seemed kind of strange, so we decided to use the .STRING relationship and go with the enum name.
Dec
16
comment Is it better to use strings or int to reference enums outside the java part of the system?
Hm, seems interesting :) We will try this approach here and let's see what happens :) Thanks for your reply!
Dec
16
comment Is it better to use strings or int to reference enums outside the java part of the system?
I've edited the question and I hope it is clearer now: by "reference to an enum" I mean referencing the value when exchanging data from JavaScript to the Server or the other way around or storing a value in the database
Sep
5
comment Does Play framework approach necessarily leads to confuse code?
Interesting point. I have a very limited experience with rails, but I really liked the language. The similarity to rails caught my attention in Play framework. I am starting the research now. I will make some prototypes to see it in action, thanks :)
Sep
5
comment How to use ViewModels in a layered architecture?
I feel relieved that it is normal. I like your separations ideas, I will propose to our team, thanks :D
Sep
3
comment Does Play framework approach necessarily leads to confuse code?
Yes, your points are valid. I just don't want to spend some time coding things and get with a confusing code that is hard to maintiain after some time (and then wasting more time getting around my code that implementing new things)
Sep
3
comment Does Play framework approach necessarily leads to confuse code?
I will take a look on this link, thanks :)
Apr
16
comment How to make my code decide which class to instantiate based on a parameter?
Yes, I used string in my example for sake of simplicity, but the idea is to use an ENUM. Java is OK, the important is the concept, not the implementation. Thanks a lot :)
Apr
15
comment How to make my code decide which class to instantiate based on a parameter?
Sure, I have queries that are going to be called against a database. I want to have the same flow for the queries that do not have any business logic applied to it (ex: get all users, get all students, and so on)
Mar
6
comment My architecture has a problem with views that required information from different objects. How can I solve this?
Perfect explanation! Thanks! I marked the post as answer, but I have to wait 2 hours to give you the bounty ;)
Mar
6
comment My architecture has a problem with views that required information from different objects. How can I solve this?
ps: the question was made before I read the links you sent because I would like to clear this and give you the points, then take my time to read everything :)
Mar
6
comment My architecture has a problem with views that required information from different objects. How can I solve this?
wow, while I know some of the concepts you talked about, there is a lot to read, so it will take a while, so one last question before I accept this answer (the points in this question will be the best points ever spent here :) ): I would receive the DTOs in my BL. So if I have a method foo() called by 2 views, I will have foo(DTOView1) and foo(DTOview2), each would instantiate a new BO object and populate it and then call the "real" foo(). Correct? This would cause my BL to have many foo's, is this correct?
Mar
6
comment My architecture has a problem with views that required information from different objects. How can I solve this?
Hey! thanks for the answer. I will read it during the day and get back to you! Tks! One last question (I'm still reading you answer, so sorry if you already answered): Would you agree with w/ @AndrewM when he says that BO should be created on the view layer? If so, how would you solve the issue that my business layer be coupled with my DTO's and, therefore, to my view layer, since DTO's represent the set of information required for a specific view?