Re: what is the best practice?
Check the book POJOS in action , there are some good chapters about Ibatis On 5/25/06, Rafael [EMAIL PROTECTED] wrote: Hi, I've been enjoying these conversations about 'Architecture'/'Best Practices' etc.. Does anyone knows if there is a specific list somewhere to get more information about architecture decisions, etc ??? -Rafael T Icibaci - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Monday, May 22, 2006 6:49 PM Subject: Re: what is the best practice? Hi Joel, the methods you mention are all data access calls, not business methods, because business methods would actually carry out some form of business logic on the data. But anyway your methods are OK. It just corresponds to the number of ways your app needs to access the data. There would be no reason to reduce the number of methods, although you should make sure that you are not repeated large amounts of code. With iBatis I think you would avoid that. Regards Adam Joel Alejandro Espinosa Carra on 22/05/06 17:39, wrote: Thank you Adam, Paul: I will try iBATIS as you suggested to me. I have another question to you in the same context. In this MessagesManager class I have business methods like getAllMessages() that retrieves all the messages from the database, but I also have another business methods like getMessagesForUser(String user_id), getMessagesForMonth(int id_month), etc. in my opinion this will make this class have eventually a lot of business methods, what is the best way to handle that? Again, thanks for your help. Best regards. ps. Paul Benedict like Ocean's eleven? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: what is the best practice?
Hi, I've been enjoying these conversations about 'Architecture'/'Best Practices' etc.. Does anyone knows if there is a specific list somewhere to get more information about architecture decisions, etc ??? -Rafael T Icibaci - Original Message - From: Adam Hardy [EMAIL PROTECTED] To: Struts Users Mailing List user@struts.apache.org Sent: Monday, May 22, 2006 6:49 PM Subject: Re: what is the best practice? Hi Joel, the methods you mention are all data access calls, not business methods, because business methods would actually carry out some form of business logic on the data. But anyway your methods are OK. It just corresponds to the number of ways your app needs to access the data. There would be no reason to reduce the number of methods, although you should make sure that you are not repeated large amounts of code. With iBatis I think you would avoid that. Regards Adam Joel Alejandro Espinosa Carra on 22/05/06 17:39, wrote: Thank you Adam, Paul: I will try iBATIS as you suggested to me. I have another question to you in the same context. In this MessagesManager class I have business methods like getAllMessages() that retrieves all the messages from the database, but I also have another business methods like getMessagesForUser(String user_id), getMessagesForMonth(int id_month), etc. in my opinion this will make this class have eventually a lot of business methods, what is the best way to handle that? Again, thanks for your help. Best regards. ps. Paul Benedict like Ocean's eleven? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: what is the best practice?
Thank you Adam, Paul: I will try iBATIS as you suggested to me. I have another question to you in the same context. In this MessagesManager class I have business methods like getAllMessages() that retrieves all the messages from the database, but I also have another business methods like getMessagesForUser(String user_id), getMessagesForMonth(int id_month), etc. in my opinion this will make this class have eventually a lot of business methods, what is the best way to handle that? Again, thanks for your help. Best regards. ps. Paul Benedict like Ocean's eleven? -- Ing. Joel Alejandro Espinosa Carra CINVESTAV CTS - Centro de Tecnología de Semiconductores Tel. +52 (33) 3770-3700 ext. 1049 http://www.cts-design.com -- Este mensaje ha sido analizado por MailScanner en busca de virus y otros contenidos peligrosos, y se considera que está limpio. MailScanner agradece a transtec Computers por su apoyo. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: what is the best practice?
Hi Joel, the methods you mention are all data access calls, not business methods, because business methods would actually carry out some form of business logic on the data. But anyway your methods are OK. It just corresponds to the number of ways your app needs to access the data. There would be no reason to reduce the number of methods, although you should make sure that you are not repeated large amounts of code. With iBatis I think you would avoid that. Regards Adam Joel Alejandro Espinosa Carra on 22/05/06 17:39, wrote: Thank you Adam, Paul: I will try iBATIS as you suggested to me. I have another question to you in the same context. In this MessagesManager class I have business methods like getAllMessages() that retrieves all the messages from the database, but I also have another business methods like getMessagesForUser(String user_id), getMessagesForMonth(int id_month), etc. in my opinion this will make this class have eventually a lot of business methods, what is the best way to handle that? Again, thanks for your help. Best regards. ps. Paul Benedict like Ocean's eleven? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: what is the best practice?
Hi Joel, your English is fine. Best practices would normally dictate that you fetch everything you need from the database in one hit. It does depend on what framework or coding pattern you are using for your database access though. I assume you are coding simple JDBC API calls? I would strongly recommend a quick and easy lightweight object / relational mapping framework like iBatis. But generally I would obtain the Message DTOs in the data services layer and populate them with the user information from a resultset obtained joining both tables. A quick and dirty technique would be to put the UserName attribute directly on the Message bean. But be careful of anti-patterns! Regards Adam Joel Alejandro Espinosa Carra on 20/05/06 00:19, wrote: Hi all. I think this is kind of a basic question. I have an application that haves 3 tables: users, messages and user_inbox for the relationship of first 2 ones. I have a class named MessagesManager in order to manage the messages to-and-from the database throught the business methods, one of them is the public List getMessages(String user_id) method that returns a MessageBean's list and I need to display the messages of each user in a html table, the MessageBean only contains the user_id but I want to display their names, do I need to modify my business method in order to get the usernames? or do I need to add another method to get the usernames, something like public String getName(String user_id)?, the first aproach makes one query to the database and the second aproach makes two. What is the best practice here? As you can see english is not my navite language, I hope you guys can understand my issue. Thanks in advance. Have a nice weekend. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: what is the best practice?
I agree with Adam. Fetch everything you can with one database call. Perform multiple JOINs and then decode the ResultSet according to how you wrote the SELECT. You can use iBATIS (ibatis.apache.org) or use the JDBC templating of the Spring Framework (www.springframework.org); the former does XML configuration, the latter is strongly-typed Java. You should choose which is best for you. Also, sometimes it's impossible to fetch everything in one query if your DAO API is large and your SQL is overwhelmingly complex. It would require duplication and management of very-easy-to-break SQL, and sometimes in these cases you are not willing to duplicate the JOIN logic in every DAO method; you instead limit it to a few; and accept more database invocations. However, you need to make this up by adding caching to your DAO, otherwise your performance will be miserable. Paul --- Adam Hardy [EMAIL PROTECTED] wrote: Hi Joel, your English is fine. Best practices would normally dictate that you fetch everything you need from the database in one hit. It does depend on what framework or coding pattern you are using for your database access though. I assume you are coding simple JDBC API calls? I would strongly recommend a quick and easy lightweight object / relational mapping framework like iBatis. But generally I would obtain the Message DTOs in the data services layer and populate them with the user information from a resultset obtained joining both tables. A quick and dirty technique would be to put the UserName attribute directly on the Message bean. But be careful of anti-patterns! Regards Adam Joel Alejandro Espinosa Carra on 20/05/06 00:19, wrote: Hi all. I think this is kind of a basic question. I have an application that haves 3 tables: users, messages and user_inbox for the relationship of first 2 ones. I have a class named MessagesManager in order to manage the messages to-and-from the database throught the business methods, one of them is the public List getMessages(String user_id) method that returns a MessageBean's list and I need to display the messages of each user in a html table, the MessageBean only contains the user_id but I want to display their names, do I need to modify my business method in order to get the usernames? or do I need to add another method to get the usernames, something like public String getName(String user_id)?, the first aproach makes one query to the database and the second aproach makes two. What is the best practice here? As you can see english is not my navite language, I hope you guys can understand my issue. Thanks in advance. Have a nice weekend. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
what is the best practice?
Hi all. I think this is kind of a basic question. I have an application that haves 3 tables: users, messages and user_inbox for the relationship of first 2 ones. I have a class named MessagesManager in order to manage the messages to-and-from the database throught the business methods, one of them is the public List getMessages(String user_id) method that returns a MessageBean's list and I need to display the messages of each user in a html table, the MessageBean only contains the user_id but I want to display their names, do I need to modify my business method in order to get the usernames? or do I need to add another method to get the usernames, something like public String getName(String user_id)?, the first aproach makes one query to the database and the second aproach makes two. What is the best practice here? As you can see english is not my navite language, I hope you guys can understand my issue. Thanks in advance. Have a nice weekend. -- Ing. Joel Alejandro Espinosa Carra CINVESTAV CTS - Centro de Tecnología de Semiconductores Tel. +52 (33) 3770-3700 ext. 1049 http://www.cts-design.com -- Este mensaje ha sido analizado por MailScanner en busca de virus y otros contenidos peligrosos, y se considera que está limpio. MailScanner agradece a transtec Computers por su apoyo. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]