Thanks for your input on this. Perhaps I didn't explain the structure very well. I do have controllers and they have the same as some of the BOs. But not every BO has its own controller. There are some BOs that only communicate with BOs and not with controllers. Also, the controllers have the usual CRUD functions which call the the BOs CRUD method. So, for example a user needs to be read here's how the application flow is designed like, The *browser *calls the *user *controller's *GET* method. That method calls the *User *BO's *read_user* method. This *read_user* method calls the *read* method in *dalUser * file (which is inside the *DALs* folder)
<https://lh3.googleusercontent.com/-CneFOwiOsb0/WC6QcgAUkEI/AAAAAAAAAAs/HwTIMj-Fu50DG7InpfDAC2sfUEXjgaIwwCLcB/s1600/Read%2BUser.png> So what you're saying is that instead of having the User (BO) and dalUser, I should have a file called *user* inside the *models *folder and that file should directly talk to the *DB*, is that correct? Should I convert the query result to a user object or use the query result as it is on the view? On Thursday, November 17, 2016 at 8:24:09 PM UTC+5, Leonel Câmara wrote: > > It seems you're replacing controllers with business objects, which seems > like unnecessary complexity for me. > > That's the usual style of programming in Java and very "enterprisey" but I > personally hate it as the business objects tend to grow and grow and > eventually you can't keep track of all the side effects you have when you > call one of their methods. > > The way I usually structure my web2py projects is, each entity (together > with related entities) is in their own model file, for each entity I also > have a controller file with the same name, the controller file has all the > usual CRUD methods for that entity. > > KISS (Keep it simple stupid) > > Eventually, you will want some of what you call "business objects" but > that's something that comes *late* in a project and that you get through > *refactoring*, when you can identify components that are quite well > self-contained and independent. For instance, in my projects, I have > extracted the user notifications logic into their own "business object" as > it's something that is independent from all the rest and saves a lot of > lines of code in each controller that will want to send notifications to > the user. The thing is, you don't know what will make the development and > maintenance of the code easier until you have a few regular controller > functions programmed and you can see what's worth refactoring into a > module/"business object". > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.