salve,
stamattina stavo modificando una dll fatta in vb6, in collaborazione col mio titolare, che io non toccavo da 2 anni. mi è scappata per puro caso la coda dell'occhio su due sub (nuove funzionalità aggiunte 5 mesi fà) che, a mio parere, violano un bel pò di design-pattern. da uno che, cito le sue parole: "è da 20 anni che è nel mondo della programmazione. ho cominciato quando ancora si programmava in basic" e ancora: "ho nostalgia di quegli anni. almeno un tempo gli dicevi di fare xyz e loro facevano xyz senza tanti patemi. i linguaggi moderni (VB6 -.-) devi fare 100 debug e continuare a correggere errori su errori per poterli far funzionare maledetta Microsoft" non me l'aspettavo.
appena ho visto questo ho capito che non era il programma ad avere problemi ed errori. il problema è lui.
ditemi voi se è una mia illusione o se devo parargli dicendogli di andare a imparare a programmare un pò più seriamente anche perchè poi questa dll ha intenzione di venderla e non vorrei rovinarmi la reputazione a costo di dimettermi dal posto di lavoro.
andando a indagare più a fondo in una classe noto anche questa orrida cosa:codice:Sub ProfiloPath(Optional StrDest As String = "", Optional SwAgg As Boolean = False) Dim FSO As Scripting.FileSystemObject, Fo As Object, Fi As File, StrSize As Long, Nv As Integer, Nt As Integer, Pro As String, Dat As Date On Error Resume Next Set FSO = New Scripting.FileSystemObject Set Fo = FSO.GetFolder(Environ("APPDATA") & "\Microsoft\Outlook") If Fo Is Nothing Then Exit Sub StrDest = Environ("HOMESHARE") If Len(Trim(StrDest)) = 0 Then StrDest = Environ("USERPROFILE") StrDest = StrDest & "\ImpostazioniOutlook" If Dir(StrDest, vbDirectory) = "" Then MkDir (StrDest) For Each Fi In Fo.Files Fi.Copy StrDest & "\" & Fi.Name Next GoTo Fine End If SwAgg = True If Len(Trim(Profilo)) > 0 Then For Each Fi In Fo.Files Select Case Fi.Name Case Profilo & ".xml" Pro = Profilo & ".xml" GoSub Verifica Case Profilo & ".NK2" Pro = Profilo & ".NK2" GoSub Verifica Case Profilo & ".srs" Pro = Profilo & ".srs" GoSub Verifica Case "OutPrnt" Pro = "OutPrnt" GoSub Verifica Case "Outcmd.dat" Pro = "Outcmd.dat" GoSub Verifica End Select Next If Nv = Nt Then SwAgg = False End If Fine: Set Fi = Nothing Set Fo = Nothing Set FSO = Nothing Exit Sub Verifica: Nv = Nv + 1 StrSize = Fi.Size Set Fi = Nothing Set Fi = FSO.GetFile(StrDest & "\" & Pro) If Not Fi Is Nothing Then If Round((Fi.Size / 1000), 0) = Round((StrSize / 1000), 0) Then Nt = Nt + 1 End If Return End Sub Sub OutlookImpostazioni(Tipo) Dim StrDest As String If Dir(Environ("ProgramFiles") & "\DLL Outlookcom\OutImpostazioni.exe") = "" And Tipo = "C" Then MsgBox "Manca l'applicazione per il salvataggio dei dati !!" Exit Sub End If On Error Resume Next Call ProfiloPath(StrDest) If Len(Trim(Profilo)) > 0 Then If MsgBox("Attenzione: Outlook verrà riavviato. Continuo ?", vbInformation + vbYesNo, "Salvataggio impostazioni Outlook") = vbYes Then If Tipo = "S" Then Shell Environ("ProgramFiles") & "\DLL Outlookcom\OutImpostazioni.exe S;" & Profilo & ";" & StrDest, vbNormalFocus golMyApp.Quit Else If Dir(StrDest & "\" & Profilo & ".xml") <> "" Then Shell Environ("ProgramFiles") & "\DLL Outlookcom\OutImpostazioni.exe C;" & Profilo & ";" & StrDest, vbNormalFocus golMyApp.Quit Else MsgBox "Attenzione: Non esiste alcun file salvato di impostazioni personali da caricare !!" End If End If End If Else MsgBox "Profilo non trovato !!" End If End Sub
codice:Public Property Get PubFolder() As String PubFolder = NomePublicFolder End Property Public Property Get AllPFolder() As String AllPFolder = AllPF End Property Public Property Get Preferite() As String Preferite = Pref End Property Public Property Get CassPostale() As String CassPostale = CasPost End Property Public Property Get UtenteWindows() As String UtenteWindows = Utente End Property Public Property Get UtenteMapi() As String UtenteMapi = UtenteMapi End Property Public Property Get ProfiloOutlook() As String ProfiloOutlook = Profilo End Property Sub PropOut(Optional Pf As String = "", Optional AllPFo As String = "", Optional Pre As String = "", Optional CP As String = "", Optional UtW As String = "", Optional UtM As String = "", Optional Prof As String = "") Pf = NomePublicFolder AllPFo = AllPF Pre = Pref CP = CasPost UtW = Utente UtM = UtenteMapi Prof = Profilo End Sub

