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.
'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
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
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.
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
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.
#Updated.
first:
-Not using var (to avoid 2 pages discussions about it ^^)
-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
[Release] Fixed MySql Wrapper 09/22/2013 - CO2 PServer Guides & Releases - 11 Replies Hey everyone.
This was a request from a close friend of mine who's having issues with his mysql wrapper from Impulse's source.
MySql tables, columns, and values can have spaces... so here's a wrapper that fixes any issues that you might have with spaces (note: the structure was coded by Impulse, all I did was fix it):
public class MySqlCommand
{
private MySqlCommandType _type;
MySQL wrapper used in Albetros/Impulse 03/31/2013 - CO2 Private Server - 3 Replies Hey there, this is a question for Pro4never / Impulse.
I'd like to use the MySQL wrapper used in Albetros/Impulse and implement it in my source (with you guys credits ofcourse). It's easy to use when pulling data from a database compared to how I have it setup now (1 huge SQL line lol).
I referenced the MySqlHandler.dll, Could you explain how to open a connection that will pair with the dll? I tried the same method used to connect with MySql.Data.dll but it doesn't seem to work.
Much...
G1's 9D startup parameters 11/18/2010 - 9Dragons - 5 Replies This one may be useless but if you want to start G1's 9D w/o a launcher try these codes - pass then as parameters:
-C2EZWTWTCTRCC5T3956JWA43XU
-Q2NWVUHQBJR3F6N390C0Q5N3XU
-A2CSOEI3RVRCENT393BCCSG3XU
-U2BZAV1QBCRQX0Q39NO5SQ23XU
-Q2DOUQ8S6GR0IQ0Q90NSRU63XU
-A2NRSTXC3HRQ6UA39SC0ZZY3XU
-E2NRTO2CNQRSRDJQ9T3JSNG3XU
-U2RCD50TQVRNINCQ9QO0ASI3XU
Parameters? 10/15/2009 - Cabal Online - 2 Replies This is the reply from Nova I got when I asked what some things did... and quite honestly I didn't fully understand his reply, to my knowledge basically only parameter 4 is the only one that is needed to be changed but my issue is that every time I craft a get a different "EBP+0x0546: Return Address of Calling Function" the only real constant that I notice between the different SocketTrace tests is the "flag" which according to Nova would be EBP+0x27 <<<<<<<<<<<<&l t; yes that's the REAL numbers I...
what are the Parameters of being banned 07/26/2009 - Grand Chase Philippines - 25 Replies just want to know up to what extent of hacking will you be banned
what are the process
and is there a safe way to hack? (not to mention public hacking?)
thanks