Home > Archive > Cobol > February 2007 > Re: My First C# (warning - long post)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: My First C# (warning - long post)
|
|
| andrewmcdonagh 2007-02-07, 6:55 pm |
| On Feb 6, 2:45 am, LX-i <lxi0...@netscape.net> wrote:
> andrewmcdonagh wrote:
[color=darkred]
>
>
>
>
>
>
>
>
> I guess I'm not seeing this... How does this help me run the code on my
> laptop against MySQL, e-mail to work, and run it on our server there
> against SQL Server? (I don't mean this to sound as harsh as it probably
> does, but I can't think of another way to word the question... Like I
> said, I'm probably just not connecting the dots.)
>
It helps, because depending upon a runtime flag, your application can
use either MySQL or SQL data. accessing classes.
By abstracting 'how' we talk to a db, from the actual talking, we can
use different mechanisms.
So, in your code base, we have the dbUtils class with aset of static
methods. If we created an Interface with the same methods on it and
changed the current dbUtils static methods to instance methods (by
deleting the 'static keyword) we can then use polymorphism to decide
which actual db to connect to.
e.g.
interface DbUtils
{
public void recordLinesOfComments();
...
}
class MySqlDbUtils : dbUtils
{
public void recordLinesOfComments()
{
....
}
....
}
class SqlDbUtils : dbUtils
{
public void recordLinesOfComments()
{
....
}
....
}
class OracleDbUtils : dbUtils
{
public void recordLinesOfComments()
{
....
}
....
}
Once you have these set of classes that implement the DB agnostic
interface your application just then needs to decide which one to
create an instance of to use. This could be done in the apps main
class, using a commandline paramerter, machine name, environment
variable, etc.
This technique is known as 'Inversion of Control'. Instead of the
control over what implementation to use being hard coded, we invert
that control by making it runtime configurable.
hth
Andrew
| |
| Howard Brazee 2007-02-12, 6:55 pm |
| On Sat, 10 Feb 2007 00:57:11 GMT, "Charles Hottel"
<chottel@earthlink.net> wrote:
>I just do NOT buy the "highly-modularized approach is bad for performance
>idea".
And I certainly do not buy "bad for performance" means the same thing
it meant when I started programming four decades ago.
Within mainframe CoBOL, I see that we have problems when we have
standards that still exist from old performance costs instead of new
performance costs.
CPU time is much cheaper than it was back then, while labor and
opportunity costs are relatively more expensive. This process will
continue. A program that is ready today but takes more CPU time can
be more cost effective for its lifetime than a more efficient program
that won't be ready until next month, as it is used this month to make
money for the company. Of course we generally aren't talking about
40 year program lifetimes here.
>Most performance problems are localized in a very small percentage of
>the code.
I still believe that some basic performance enhancing of I/O and loop
design is worth-while. But it isn't as worth-while as it used to be.
========
The U.S. opened up economically with the development of canals to its
interior. Canals were much more efficient than roads. But canals
were more expensive to build, and didn't adjust to transportation
needs. So gradually rail took over, also cheaper than roads. But
they also weren't flexible, and their initial cost was higher. While
canals, railroads (and also sea going transport) still exist and do
lots of business - the flexibility of trucks has meant that we don't
have a Montgomery Wards built around a train station shipping out to
your local train station - the goods are in your local mall.
Nowadays, people expect their data on their laptop today - even though
they just decided what they want. So we optimize our data processing
to give it to them in the most efficient way. This "most efficient"
means - buy a bigger CPU and more bandwidth - they're cheap. And set
up procedures that give them secure, accurate data *now*.
| |
| Howard Brazee 2007-02-14, 6:55 pm |
| On Wed, 14 Feb 2007 09:50:10 -0600, LX-i <lxi0007@netscape.net> wrote:
> Besides, I'm not happy with the way it's partitioned,
>and if I repartition, I'd have to reload the OS anyway...
I've upgraded Partition Magic over the years, but may be finished with
partition changing.
Especially if I go Mac.
| |
|
| Howard Brazee wrote:
> On Wed, 14 Feb 2007 09:50:10 -0600, LX-i <lxi0007@netscape.net> wrote:
>
>
> I've upgraded Partition Magic over the years, but may be finished with
> partition changing.
>
> Especially if I go Mac.
Macs don't use partitions?
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ daniel@thebelowdomain ~
~ _____ / \ | ~ http://www.djs-consulting.com ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e ~
~ h---- r+++ z++++ ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
"Who is more irrational? A man who believes in a God he doesn't see, or
a man who's offended by a God he doesn't believe in?" - Brad Stine
|
|
|
|
|