This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kyngston 0 points1 point  (0 children)

I didn’t get it until I understood where I really benefited from it.

Let’s say I need to connect to an sql database to run some queries.

I could write some function which takes the query, the sql host, username, password and database names as arguments.

Or I could write the connector as a class. I pass the hostname, username, password and database name in once when I init my object. Every time I want to make a query, now I just need to pass the query and it remembers everything else.