Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 09:37

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



MySql wrapper using parameters

Discussion on MySql wrapper using parameters within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old 05/11/2013, 19:53   #16


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
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.
Korvacs is offline  
Old 05/12/2013, 01:59   #17
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
Quote:
Originally Posted by Smaehtin View Post
How do I force speedtest.net to localhost??
Tell it to use a different server after it does a test using the recommended one.
_DreadNought_ is offline  
Old 05/12/2013, 03:03   #18
 
InfamousNoone's Avatar
 
elite*gold: 20
Join Date: Jan 2008
Posts: 2,012
Received Thanks: 2,885
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
InfamousNoone is offline  
Thanks
1 User
Old 05/12/2013, 07:55   #19


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
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
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.
Korvacs is offline  
Thanks
1 User
Old 05/12/2013, 10:15   #20
 
elite*gold: 0
Join Date: Mar 2013
Posts: 118
Received Thanks: 95
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
Smaehtin is offline  
Old 05/12/2013, 10:41   #21


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
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.
Korvacs is offline  
Old 05/13/2013, 00:25   #22
 
U2_Caparzo's Avatar
 
elite*gold: 0
Join Date: Aug 2011
Posts: 314
Received Thanks: 90
#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
U2_Caparzo is offline  
Thanks
1 User
Reply

Tags
c#, mysql, wrapper


Similar Threads Similar Threads
[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



All times are GMT +1. The time now is 09:38.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.