Click here to Skip to main content
15,909,242 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Worderful object names Pin
Tim Carmichael28-Dec-07 10:29
Tim Carmichael28-Dec-07 10:29 
GeneralRe: Worderful object names Pin
unrealweapon30-Dec-07 22:11
unrealweapon30-Dec-07 22:11 
JokeRe: Worderful object names Pin
SalarSoft31-Dec-07 0:42
SalarSoft31-Dec-07 0:42 
GeneralRe: Worderful object names Pin
Matt Sollars1-Jan-08 5:52
Matt Sollars1-Jan-08 5:52 
QuestionRe: Worderful object names Pin
Vikram A Punathambekar4-Jan-08 2:20
Vikram A Punathambekar4-Jan-08 2:20 
GeneralRe: Worderful object names Pin
KarstenK9-Jan-08 3:49
mveKarstenK9-Jan-08 3:49 
GeneralRe: Worderful object names Pin
Robodroid17-Jan-08 9:22
Robodroid17-Jan-08 9:22 
GeneralGod, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
Alaric_20-Dec-07 5:48
professionalAlaric_20-Dec-07 5:48 
God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence....and if it pleases you, oh God: can you send some of the "Non"s with them?


This was written in 2005 in a VB.NET project
GoTo Error_Trap
            End Try

            Me.LBL_status.Text = ""
        Else
            Me.DV_Search.Visible = True
            Me.DV_Results.Attributes("style") = "display:none"
            Me.LBL_status.Text = "No Rows Returned."
        End If

        Exit Sub

Error_Trap:
        ShowError()



...The "Business Logic", "Data Access" and "Presentation" layers are maintained not as separate projects inside a solution, but as FOLDERS!!! inside a single project. ...which results in a "hard-wired disgusting switch-boxed bastardization" of the layered pattern ...The mechanism that was chosen by our unqualified senior architect (who makes God knows how much a year) for accessing the database is to have the presentation layer do something like this:

Dim tbl As DataTable

        tbl = Common.GetDataTable(SQLScripts.GetBaseEmpSql(UserID))


rather than having stored procedures encapsulate the sql scripts, the choice was made to maintain them in code. (Granted, I obfuscated the schema name and each of the table names so that I could post)
Public Shared Function getSQL(ByVal aryPVIDs() As String) As String
        'aryPVIDs must be an array of pvids 
        Dim sql, strSelect, strFrom, strWhere As String
        Dim strPVIDs As String

        strPVIDs = Join(aryPVIDs, "','")

        strSelect = "Select p.ID, p.Ps_Project_NBr, " & vbCrLf & _
        " p.Project_Desc_txt, pt.Project_type_txt, p.project_type_cd, " & _
        " p.spread_method_cd, sm.spread_method_txt, p.project_mgr_id, pm.last_nm||', '||pm.first_nm ProjectMgrFullName, " & vbCrLf & _
        " p.asset_mgr_id, am.last_nm||', '||am.first_nm AssetMgrFullName, " & vbCrLf & _
        " p.lead_eng_id, le.last_nm||', '||le.first_nm LeadEngineerFullName, " & vbCrLf & _
        " p.start_dt, p.revised_start_dt, " & vbCrLf & _
        " p.orig_serv_dt, p.revised_serv_dt, p.projected_serv_dt, " & vbCrLf & _
        " p.host_flg, p.engineer_group_cd, eg.engineer_group_txt, " & vbCrLf & _
        " p.Trans_region_cd, tr.transmission_region_txt, p.comments_txt, " & vbCrLf & _
        " p.Distr_region_cd, dr.distr_region_txt, " & vbCrLf & _
        " p.project_status_cd, priority_cd , archive_flg, " & vbCrLf & _
        " ps.cpp, p.glbu, ps.ci_status_nbr ci_status, capital_flg, p.funding_type_cd, " & vbCrLf & _
        " ps.funding_id, ft.funding_type_desc, " & vbCrLf & _
        " p.outsourced_flg, p.asset_type_cd, at.asset_type_desc, p.asset_class_cd, ac.asset_class_desc, " & vbCrLf & _
        " p.voltage_class_cd, vc.voltage_class_desc, p.outsourced_cd, o.outsourced_desc, " & vbCrLf & _
        " p.budget_ind, pstat.project_status_txt, p.super_project, p.last_updated_by, p.last_updated_dt, " & vbCrLf & _
        " (Select count(1) from xxx.yyy where id = p.ID) as mn_est_cnt, " & vbCrLf & _
        " (Select count(1) from xxx.yyy where id = p.ID) as yr_est_cnt, " & vbCrLf & _
        " p.created_by, cb.first_nm||' '||cb.last_nm CreatedByFullName, pf.last_updated_dt forecast_upd_dt, pf.last_updated_by forecast_upd_by, " & vbCrLf & _
        " (select decode(count(*),0,0,1)  from xxx.zzz where id = p.id) HasReimbursable, " & vbCrLf & _
        " (SELECT first_nm || ' ' || last_nm FROM aaa WHERE employee_id = p.last_updated_by) lastUpdatedName, " & vbCrLf & _
        " (SELECT first_nm || ' ' || last_nm FROM aaa WHERE employee_id = p.created_by) createdByName, " & vbCrLf & _
        " get_states_by_project(p.id) as state_cd " & vbCrLf


        strFrom = " from xxx.aaa p, xxx.bbb PT, xxx.aaa pm, " & vbCrLf & _
        " xxx.aaa le, xxx.ccc eg, xxx.ddd tr, " & vbCrLf & _
        " xxx.aaa am, xxx.aaa cb, xxx.eee sm, " & vbCrLf & _
        " xxx.fff ps, xxx.ggg dr, " & vbCrLf & _
        " xxx.hhh ac, xxx.iii at, xxx.ccc vc, " & vbCrLf & _
        " xxx.jjj o, xxx.kkk ft, " & vbCrLf & _
        " xxx.lll pstat, " & _
          " (SELECT DISTINCT t1.id, t1.last_updated_dt, e.first_nm||' '||e.last_nm last_updated_by " & _
         " FROM xxx.project_forecast t1, xxx.aaa e " & _
         " WHERE e.employee_id = t1.last_updated_by and (t1.id, t1.last_updated_dt) IN " & _
         " (SELECT id, max(last_updated_dt) FROM mmm" & _
         " WHERE id IN ('" & strPVIDs & "') GROUP BY id   ) ) pf "


        strWhere = " where pf.id(+) = p.id and p.id in ('" & strPVIDs & "') and pt.project_type_cd(+) = p.project_type_cd " & vbCrLf & _
        " and p.Project_Mgr_Id = pm.Employee_ID(+) and p.created_by = cb.Employee_Id(+) " & vbCrLf & _
        " and p.Asset_Mgr_Id = am.Employee_Id(+) and p.spread_Method_cd = sm.spread_Method_cd(+) " & vbCrLf & _
        " and p.Lead_Eng_ID =  le.Employee_Id(+)  and p.trans_region_cd = tr.transmission_region_cd(+) " & vbCrLf & _
        " and p.engineer_group_cd = eg.engineer_group_cd(+) " & vbCrLf & _
        " and p.ps_project_nbr = ps.ps_project_nbr(+)  and p.distr_region_cd = dr.distr_region_cd(+) " & vbCrLf & _
        " and p.asset_type_cd = at.asset_type_cd(+) and p.asset_class_cd = ac.asset_class_cd(+) " & vbCrLf & _
        " and p.voltage_class_cd = vc.voltage_class_cd(+) " & vbCrLf & _
        " and p.outsourced_cd = o.outsourced_cd(+) " & vbCrLf & _
        " and p.funding_type_cd = ft.funding_type_cd(+) " & vbCrLf & _
        " and p.project_status_cd = pstat.project_status_cd(+) "

        sql = strSelect & strFrom & strWhere

        Return sql
    End Function


...There are no ObjectDataSources used, save for the ones in my sector of the system. All of the controls at the Presentation layer are bound directly to ADO.NET objects. Mad | :mad: ...Abso-frickin-lutely ridiculous

"I need build Skynet. Plz send code"

modified on Monday, January 21, 2008 11:02:39 AM

GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
Alaric_20-Dec-07 6:36
professionalAlaric_20-Dec-07 6:36 
JokeRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
Ri Qen-Sin20-Dec-07 13:46
Ri Qen-Sin20-Dec-07 13:46 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence PinPopular
Ray Cassick20-Dec-07 17:35
Ray Cassick20-Dec-07 17:35 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
PIEBALDconsult20-Dec-07 17:54
mvePIEBALDconsult20-Dec-07 17:54 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
sulu21-Dec-07 1:36
sulu21-Dec-07 1:36 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
Ri Qen-Sin21-Dec-07 3:56
Ri Qen-Sin21-Dec-07 3:56 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
PIEBALDconsult21-Dec-07 9:44
mvePIEBALDconsult21-Dec-07 9:44 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
SilimSayo30-Jan-08 3:47
SilimSayo30-Jan-08 3:47 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
MidwestLimey21-Dec-07 5:33
professionalMidwestLimey21-Dec-07 5:33 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
Alaric_21-Dec-07 5:46
professionalAlaric_21-Dec-07 5:46 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
Andrew Torrance4-Jan-08 6:40
Andrew Torrance4-Jan-08 6:40 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
Alaric_21-Dec-07 5:16
professionalAlaric_21-Dec-07 5:16 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
MidwestLimey21-Dec-07 5:41
professionalMidwestLimey21-Dec-07 5:41 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
Alaric_21-Dec-07 6:17
professionalAlaric_21-Dec-07 6:17 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
Paul Conrad22-Dec-07 12:20
professionalPaul Conrad22-Dec-07 12:20 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
Patrick Etc.26-Dec-07 13:06
Patrick Etc.26-Dec-07 13:06 
GeneralRe: God, I hate VB. All I want for Christmas is for you to smite the retards responsible for its existence Pin
Paul Conrad26-Dec-07 13:19
professionalPaul Conrad26-Dec-07 13:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.