Code as War Crime
-
Look at it hard. Study it. Do the opposite and you'll do well in your career. Best to you.
Thanks! Learning what not to do is also important, that's why I always take a look around here :)
-
I haven't been on these forums in a while. But I've come across a coding atrocity so horrible, so offensive, that I have to document it. This is a Windows service. Can you see how the developer accesses database data? (Answer below)
Dim ResultDS As New SqlDataSource
ResultDS.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("JaguarReportingConnectionString").ToString()
ResultDS.SelectCommand = ""ResultDS.[Select](DataSourceSelectArguments.Empty)
Dim dg As New GridView
dg.DataSource = ResultDS
dg.DataBind()
Dim dv As New DataView
Dim dt As New DataTable
dv = ResultDS.Select(DataSourceSelectArguments.Empty)
dt = dv.ToTable()Hint: GridView is from the Web UI control namespace. Did I mention this is a Windows service?
-
I haven't been on these forums in a while. But I've come across a coding atrocity so horrible, so offensive, that I have to document it. This is a Windows service. Can you see how the developer accesses database data? (Answer below)
Dim ResultDS As New SqlDataSource
ResultDS.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("JaguarReportingConnectionString").ToString()
ResultDS.SelectCommand = ""ResultDS.[Select](DataSourceSelectArguments.Empty)
Dim dg As New GridView
dg.DataSource = ResultDS
dg.DataBind()
Dim dv As New DataView
Dim dt As New DataTable
dv = ResultDS.Select(DataSourceSelectArguments.Empty)
dt = dv.ToTable()Hint: GridView is from the Web UI control namespace. Did I mention this is a Windows service?
Whoever wrote this; should be hanged, drawn and quartered...
CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...
-
I haven't been on these forums in a while. But I've come across a coding atrocity so horrible, so offensive, that I have to document it. This is a Windows service. Can you see how the developer accesses database data? (Answer below)
Dim ResultDS As New SqlDataSource
ResultDS.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("JaguarReportingConnectionString").ToString()
ResultDS.SelectCommand = ""ResultDS.[Select](DataSourceSelectArguments.Empty)
Dim dg As New GridView
dg.DataSource = ResultDS
dg.DataBind()
Dim dv As New DataView
Dim dt As New DataTable
dv = ResultDS.Select(DataSourceSelectArguments.Empty)
dt = dv.ToTable()Hint: GridView is from the Web UI control namespace. Did I mention this is a Windows service?
-
Doesn't that run the query twice, too? (Once to bind it to the GridView, which I assume is the big laugh here – does that even work in a service? – and once when initialising dv.)
You're probably right. I was given a task to get it working again. I later learned that it may have *never* worked.
-
I haven't been on these forums in a while. But I've come across a coding atrocity so horrible, so offensive, that I have to document it. This is a Windows service. Can you see how the developer accesses database data? (Answer below)
Dim ResultDS As New SqlDataSource
ResultDS.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("JaguarReportingConnectionString").ToString()
ResultDS.SelectCommand = ""ResultDS.[Select](DataSourceSelectArguments.Empty)
Dim dg As New GridView
dg.DataSource = ResultDS
dg.DataBind()
Dim dv As New DataView
Dim dt As New DataTable
dv = ResultDS.Select(DataSourceSelectArguments.Empty)
dt = dv.ToTable()Hint: GridView is from the Web UI control namespace. Did I mention this is a Windows service?
-
[Reads first line of code] Is that Visual Basic?? There's your problem right there! :laugh: Let the flame war begin (or fizzle out because nobody noticed/cared). :rose:
-
It could be worse. The developer could have started an instance of one of the Microsoft Office applications to do the job (in a service).
Software Zen:
delete this;
I've seen people try that - it normally fails, horribly.
"If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.
-
[Reads first line of code] Is that Visual Basic?? There's your problem right there! :laugh: Let the flame war begin (or fizzle out because nobody noticed/cared). :rose:
I still contend that Object Pascal is the better language! There, feel better? :D
-
I've seen people try that - it normally fails, horribly.
"If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.
Ignoring the legal implications (server usage of Microsoft Office apps violates the license), the Office apps fail in odd ways or cause unusual server failures when used in this fashion.
Software Zen:
delete this;
-
I haven't been on these forums in a while. But I've come across a coding atrocity so horrible, so offensive, that I have to document it. This is a Windows service. Can you see how the developer accesses database data? (Answer below)
Dim ResultDS As New SqlDataSource
ResultDS.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("JaguarReportingConnectionString").ToString()
ResultDS.SelectCommand = ""ResultDS.[Select](DataSourceSelectArguments.Empty)
Dim dg As New GridView
dg.DataSource = ResultDS
dg.DataBind()
Dim dv As New DataView
Dim dt As New DataTable
dv = ResultDS.Select(DataSourceSelectArguments.Empty)
dt = dv.ToTable()Hint: GridView is from the Web UI control namespace. Did I mention this is a Windows service?
-
I still contend that Object Pascal is the better language! There, feel better? :D
-
Nope. Befunge is the best. There is no better 2D programming languge. If there is any.
Greetings - Jacek
That's a win for Jacek! http://en.wikipedia.org/wiki/Befunge[^]
-
I haven't been on these forums in a while. But I've come across a coding atrocity so horrible, so offensive, that I have to document it. This is a Windows service. Can you see how the developer accesses database data? (Answer below)
Dim ResultDS As New SqlDataSource
ResultDS.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("JaguarReportingConnectionString").ToString()
ResultDS.SelectCommand = ""ResultDS.[Select](DataSourceSelectArguments.Empty)
Dim dg As New GridView
dg.DataSource = ResultDS
dg.DataBind()
Dim dv As New DataView
Dim dt As New DataTable
dv = ResultDS.Select(DataSourceSelectArguments.Empty)
dt = dv.ToTable()Hint: GridView is from the Web UI control namespace. Did I mention this is a Windows service?
You know that a Windows service can be allowed to interact with the desktop in which case you can use and you need UI controls. I don't know what the intention is from those few line of codes but this is far from a War Crime, so I think you're exaggerating. Yes, I know that :
Quote:
In most cases, it is recommended that you not change the Allow service to interact with desktop setting. If you allow the service to interact with the desktop, any information that the service displays on the desktop will also be displayed on an interactive user's desktop. A malicious user could then take control of the service or attack it from the interactive desktop.
I have seen worse.
giuchici