Examples Delphi

Title: Reducing code complexity
Question: How many settings do you have to set just to send an email? How many settings do you have to set just to get a ado recordset? Many times there is way too much effort on "setup" compared to what we want to do. I have a solution.
Answer:
I have done something interesting. Its about program architecture. To forwarn you, at first sight it appears to "hard code" your program and kill reusability. But thats not the case... here is the idea, and I have been using it with success.
I will call it "embedding settings within an object".
The alternative is to pass or assign the settings to the object.
Here are 2 examples to show you what I mean.
1. An emailer. An emailer requires the mail server and any authentication. Two possible designs A and B are: A. Pass the email settings to the mailer through some property. B. Make the emailer load the settings from an INI file. In case B, this is "embedding settings within an object".
2. A function called OpenSQL that returns a recordset. Two possible designs: A. Pass the connection string or a connection object to the function along with the sql statement. B. Pass only the SQL statement to the function and make the function choose the connection to use. In case B, this is the same idea as "embedding settings within an object". except this is just a function but the point is the same.
So, at first sight this seems to kill reusability by making the functions or objects application specific. This is not the case because settings can be stored outside of the program, for example in an ini file.
What happens when you use this method is that it makes using those objects or functions as easy as possible because you do not have to think, "Oh, I need email settings... how do I get that".
=====================
- ps: If you think this artical sucks then if you would add a comment explaining why, I can improve my articles and you can benefit.