[Mono-list] Questions about coding style
James Wright
james.wright at jigsawdezign.com
Mon Aug 20 19:45:23 UTC 2012
I'd create ConnectionFactory class, although feel free to ignore me,
just thinking off the top of my head! :-)
public class ConnectionFactory
{
private static MySqlConnection _connection;
public MySqlConnection GetConnection()
{
if (_connection == null)
{
_connection = new MySqlConnection();
}
return _connection;
}
}
On 20/08/2012 20:28, Philippe Grohrock wrote:
> Thanks for the reply already and I'm sorry, I should've added the
> lines of code.
> static class GlobalVariables
> {
> public static MySqlConnection connection = new connection();
> }
> This way the whole program has access to it and can modify/query the
> DB when needed (this is what I meant with global). At the moment I
> have 2 of my windows using that connection, but there might be more in
> the future. So is this a bad way of doing it? Would it be better to
> have the connection be internal static? Should I declare it once after
> the start of the program and then hand it over to the windows? I think
> I also need to open a new topic about assemblies ;)
> ------------------------------------------------------------------------
> View this message in context: Re: Questions about coding style
> <http://mono.1490590.n4.nabble.com/Questions-about-coding-style-tp4656301p4656321.html>
> Sent from the Mono - General mailing list archive
> <http://mono.1490590.n4.nabble.com/Mono-General-f1490591.html> at
> Nabble.com.
>
>
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20120820/f626327f/attachment.html>
More information about the Mono-list
mailing list