1

I need to understand the difference and the application of both words (route/routes and router/routers). I plan to apply one of words to define the route of a URL for a website. For instance:

URL /route/example will be routed to a specific callback.

The problem is that I need to understand the definition of these words to decide which one I will use for this purpose.

3
  • I wonder if this is a good site to get a reliable answer for very technical terms used in very specific and narrow way, or if an answer is more likely to be human equivalent of machine translation. These words even mean different thing in visible user interface and in source code comments.
    – hyde
    Jul 6, 2014 at 6:49
  • This topic is off-topic here, as it is about technical vocabulary. A correct answer would be entirely about the technical subject, not about the English language. This might be on-topic at Webmasters. Jul 6, 2014 at 7:57
  • What did a dictionary say about those two words?
    – Mitch
    Jul 7, 2014 at 2:07

1 Answer 1

5

It might be confusing that "route" is also a verb. So the following sentence is correct:

The router routes you to a route.

I'm guessing you're referring to some of the popular web frameworks, such as Express or Grails, that use this terminology. You can think of a route as the name of a function or resource, which is requested by the user via URL.

For example, say you want to show the user a color of car. You might define a route like this:

  • /car/:color
    • Returns the car of color :color
    • Example: the URL /car/blue returns a blue car.

If we were to write a function that did this, it might look like this:

  • function car (color) { ...
    • Returns the car of color color
    • Example: car('blue');

The web framework will setup this mapping: route -> function. So the route here is the key, and the function is the value. The router is the mechanism in the framework that uses the route specified by the user to figure out what function to invoke.

2
  • I'm talk exactly about frameworks. So, can I say that I need add a new route to the router? Like $router->add_route()? Or I need use same term like $router->add_router() or $route->add_route()? Jul 6, 2014 at 2:38
  • 1
    $router->add_route() is correct. Also I would say that a router routes via a route.
    – Jim
    Jul 6, 2014 at 4:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.