MySql wrapper using parameters

05/11/2013 19:53 Korvacs#16
Quote:
Originally Posted by Smaehtin View Post
Haha, have you ever used ReSharper?
I have not used it myself but I know that it is known to overuse var. That doesn't make it acceptable/better, nor good practice.

Yeah its use is debated over and over, in my view it should be used only as intended, using it for convenience should be avoided as it can cause confusion over the intent of the code.
05/12/2013 01:59 _DreadNought_#17
Quote:
Originally Posted by Smaehtin View Post
How do I force speedtest.net to localhost?? :confused:
Tell it to use a different server after it does a test using the recommended one.
05/12/2013 03:03 InfamousNoone#18
Quote:
Originally Posted by Korvacs View Post
'var' should only be used when working with anonymous types, beyond that your just making your code easier to read while sacrificing clarity. For example using 'var' in that case is easier than the full object name yes, but it isn't clear what 'DBCore.GetNewConnection()' returns except that its some form of new connection.

So in this case the type should be declared explicitly.
My point is, I don't see why you would even need to know what it returns. In this case, it's not like you're about to do anything with the connection other than invoke some method belonging to it. I mean at the end of the day I can see we disagree on this matter so I'll just leave at that, not everyone holds the same views as when to use var, we can at least agree on that :p
05/12/2013 07:55 Korvacs#19
Quote:
Originally Posted by InfamousNoone View Post
My point is, I don't see why you would even need to know what it returns. In this case, it's not like you're about to do anything with the connection other than invoke some method belonging to it. I mean at the end of the day I can see we disagree on this matter so I'll just leave at that, not everyone holds the same views as when to use var, we can at least agree on that :p
Indeed, we're looking at it from different angles though, alot of the problem with var is not to do with its use from a programming point of view, but from the point of view of team work and outside observers and users of the code.

Take this line on its own:

Code:
using(var conn = DBCore.GetNewConnection())
Tell me what type of database it is, what the type being returned is, what type of connection.

There are many issues with that line of course, DBCore offers no clues so the naming is pretty poor, so to an outside observer this line could mean pretty much anything. It potentially could be a socket connection to a core database server since we don't know the type.

Var has its uses like anything else, but its important to use it as intended.
05/12/2013 10:15 Smaehtin#20
Quote:
Originally Posted by Korvacs View Post
Take this line on its own:

Code:
using(var conn = DBCore.GetNewConnection())
Tell me what type of database it is, what the type being returned is, what type of connection.

There are many issues with that line of course, DBCore offers no clues so the naming is pretty poor, so to an outside observer this line could mean pretty much anything. It potentially could be a socket connection to a core database server since we don't know the type.

Var has its uses like anything else, but its important to use it as intended.
Sure, the naming could be better, but why would you want to know the type of database? A function like "GetSqlDbConnection" would be SUPER bad coding practice imo. You should make your code independent of what kind of database you're dealing with
05/12/2013 10:41 Korvacs#21
Quote:
Originally Posted by Smaehtin View Post
Sure, the naming could be better, but why would you want to know the type of database? A function like "GetSqlDbConnection" would be SUPER bad coding practice imo. You should make your code independent of what kind of database you're dealing with
I'm not suggesting you rename the method, the method name is fine, the solution is to not use var and to define the type explicitly, DBCore should be renamed to make it clear what the class is, if your writing something like this you need to consider that your application may need to support multiple database types, so DBCore is not a good naming convention.
05/13/2013 00:25 U2_Caparzo#22
#Updated.
first:
-Not using var (to avoid 2 pages discussions about it :p ^^)

-Renamed some variable names and classes.
-Removed the DBThread and ThreadFactory.
-Added checks to the ConnectionString and almost every method in the MySqlWiriter class.
-You can decide if throw exceptions or just return false from methods in MySqlWriter(using a bool, could have used pre-processors, but this was intendeed for be a dll).
-Support for multiple Where statments using And() - Or().
-Support for execute synchronously as asynchronously (Execute() and BeginExecute())

that is i think.
Hoping this time i did it a bit better :o