Welcome Guest, Not a member yet? Register   Sign In
Controller Suffix
#10

Your mindset is very common amongst devs who have never worked in larger teams, but its understandable. I had typed a large text below giving examples on why routes are important, but at the end of the day I think it's better to just copy something off of wikipedia:

"In computer science, separation of concerns (SoC) is a design principle for separating a computer program into distinct sections, such that each section addresses a separate concern."
https://en.wikipedia.org/wiki/Separation_of_concerns

By using automagical routing, your controllers are directly tied to the URL. If down the road you need to change a URL, you're now forced to change the name of your controller. On top of separating your URL's from your controllers, as soon as you start working in a team, you'll find that your Routes.php file will be a perfect 'map' of your application. Like you said before, you have to hit the urls to see what's going on. With a fully mapped routes.php, your other developer could just look at the routes file and with a simple ctrl+F + 'reports', you can see every function that should be available to your users quickly.

Just to add, using routes also allows you to have urls like "users/1234/posts/2/edit" which can help simplify your front-end if you're used to working with rest styled interfaces.

At the end of the day, there's a reason why most modern frameworks used named routes and CI4 will now have the option to turn off magical routing. While it makes it easier to get started, it's not the best practice if you're building any app with more than just a few controllers.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply


Messages In This Thread
Controller Suffix - by ufhy - 08-05-2016, 08:56 AM
RE: Controller Suffix - by Avenirer - 08-07-2016, 10:31 PM
RE: Controller Suffix - by PaulD - 08-08-2016, 09:09 AM
RE: Controller Suffix - by ivantcholakov - 08-08-2016, 10:41 AM
RE: Controller Suffix - by Muzikant - 08-08-2016, 11:59 AM
RE: Controller Suffix - by PaulD - 08-08-2016, 01:56 PM
RE: Controller Suffix - by albertleao - 08-12-2016, 05:29 PM
RE: Controller Suffix - by marksman - 08-08-2016, 06:13 PM
RE: Controller Suffix - by PaulD - 08-12-2016, 05:57 PM
RE: Controller Suffix - by albertleao - 08-14-2016, 10:21 PM
RE: Controller Suffix - by PaulD - 08-15-2016, 03:00 AM
RE: Controller Suffix - by albertleao - 08-15-2016, 09:52 AM
RE: Controller Suffix - by spjonez - 08-15-2016, 07:41 AM
RE: Controller Suffix - by Ivo Miranda - 08-15-2016, 12:14 PM
RE: Controller Suffix - by albertleao - 08-15-2016, 02:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB