|
Cool, not what I had in mind, but definitely better than what I had in mind!
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 2 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Thanks. For what its worth, what did you have in mind?
|
|
|
|
|
Computafreak wrote: For what its worth, what did you have in mind?
For some reason I thought Timespan had a TotalYears property...
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 2 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
yet incorrect, since it assumes months and leap years evolve from day of birth in the same way as they do from DateTime.MinValue
The net result is that close to one's birthday the formula can be off by 1.
This one is much safer, although still not perfect:
DateTime.Today.Subtract(DateTime.Parse(birthday)).Days/365.242374
The perfect solution really uses ToDay.Years-DateTime.Parse(birthday).Years and adjusts by one according to the result of ToDay.DayOfYear < DateTime.Parse(birthday).DayOfYear
|
|
|
|
|
Ahh yes, I just noticed that 2 minutes ago
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 2 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Actually, after carefully looking at your solution, it appears to be wrong.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 2 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
|
Good answer in fact
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 2 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
For that approach to work, wouldn't you have to add 306 days to both the birthdate and the present time before using the Year and DayOfYear properties? The notion that someone born on 2/28/2000 would have had to wait 366 days to be "one year old", while someone born on 3/1/2000 would only have to wait 365 days, is somewhat artificial but it is certainly well-established.
#2/28/2000#.DayOfYear == 59
#2/28/2001#.DayOfYear == 59
#3/1/2000#.DayOfYear == 61
#3/1/2001#.DayOfYear == 60
#2/28/2000#.AddDays(306).DayOfYear == 365
#2/28/2001#.AddDays(306).DayOfYear == 365
#3/1/2000#.AddDays(306).DayOfYear == 1
#3/1/2001#.AddDays(306).DayOfYear == 1
Of course, adding 306 days has an ugliness all its own. My own preference would probably be to simply format the thing as MMDDHHMMSS, do a string compare, and adjust the year appropriately, but another option would be to format as YYYYMMDDHHMMSS, convert to a long or double, subtract, and divide by 10,000,000,000.
|
|
|
|
|
It needs to be done in true OOP style...
public static int GetAge(string birthDate)
{
DateTimeParser dtpc = new DateTimeParser() { DateAsString = birthDate };
DateTimeWithoutYearComparer dtwyc = new DateTimeWithoutYearComparer();
return dtwyc.PerformComparisonAndReturnDifferenceInYears(DateTime.Today, dtpc.Parse());
}
public class DateTimeParser
{
public string DateAsString { get; set; }
public DateTime Parse()
{
throw new NotImplementedException("We're too lazy to actually write code");
}
}
public class DateTimeWithoutYearComparer
{
public DateTimeWithoutYearComparer()
{
InitializeComponent();
}
private void InitializeComponent()
{
}
public int PerformComparisonAndReturnDifferenceInYears(DateTime a, DateTime b)
{
return 42;
}
}
Sorry, I was reading that thread in the Lounge about funny code comments, and, well, my mind is pretty warped to begin with... The scary thing is that if I typed this into Visual Studio instead of here, I think it might actually compile (and crash).
|
|
|
|
|
where do you think, the horror codes, plz send codz now, my code no work... stem from?
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
public static int GetAge(string birthDate)
{
throw new CoderIsABoorException();
}
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
It seems this coder didn't see the point of the Java "instanceof" operator:
protected void processException(Throwable e)
throws ParqProsaException
{
try
{
throw e;
}
catch(SQLException se)
{
ParqSQLSadException pre = new ParqSQLSadException(se);
throw new ParqErrorContainerException(pre, " ... ");
}
catch(Throwable exx)
{
super.processException(exx);
}
}
|
|
|
|
|
Here's another example of some great coding skills. I'm thinking he get's paid in CPU cycles used by application AND lines of code written.
'*********************************************************************
'* FindCharacters
'*
'* This subroutine finds and optionally replaces specific characters
'* with another chjaracter. It also returns the position(s) of
'* specific characters not in the string.
'*********************************************************************
Public Sub FindCharacters(ByRef strData As String, _
ByVal strValidCharSet As String, _
ByVal strReplChar As String, _
ByRef strMsg As String)
Dim strWork As String
Dim strCH As String
Dim intLoop As Integer
strWork = ""
strMsg = ""
For intLoop = 0 To strData.Length - 1
strCH = strData.Substring(intLoop, 1)
If strValidCharSet.IndexOf(strCH) = -1 Then
strWork = String.Concat(strWork, strReplChar)
strMsg = String.Concat(strMsg, (intLoop + 1).ToString, ", ")
Else
strWork = String.Concat(strWork, strCH)
End If
Next
If strMsg <> "" Then
strMsg = strMsg.Substring(0, strMsg.Length - 2)
End If
strData = strWork
End Sub
|
|
|
|
|
EyeYamFedUp wrote: It also returns the position(s) of
'* specific characters not in the string.
he must be genius
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
I think I need a lobotomy...
strCH = strData.Substring(intLoop, 1)
this is to extract the char of strData in each iteration, rigth?
Argh!
|
|
|
|
|
This guy is our point person for "process improvement". Guess how many years he's been coding? This is using VB.NET 2008. Great work don't ya think?
Let me know if you'd like to see more.
'*********************************************************************
'* Module modCommon
'*
'* This module contains objects referenced by the entire application
'* for various purposes.
'*********************************************************************
Imports System.Collections
Imports System.Data.OleDB
Imports System.Data.SqlClient
Imports System.IO
Imports System.Runtime.InteropServices.Marshal
Imports System.Text
Imports System.Xml
Module modCommon
'* Constants
Public Const constLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Public Const constDigits = "0123456789"
'* OLE Database Connections
Public oconnCSUtilities As OleDbConnection
'* SQL Database Connections
Public sconnCommonData As SqlConnection
Public sconnITProjectTracker As SqlConnection
Public sconnMZP As SqlConnection
'* OLE Database Variables
Public ocmdProjectTracker As OleDbCommand
Public odrProjectTracker As OleDbDataReader
'* SQL Database Variables
Public scmdAcctClient As SqlCommand
Public sdrAcctClient As SqlDataReader
Public scmdClientInfo As SqlCommand
Public sdrClientInfo As SqlDataReader
Public scmdClientTransactionFileTypes As SqlCommand
Public sdrClientTransactionFileTypes As SqlDataReader
Public scmdCompanyNameCompanyName As SqlCommand
Public sdrCompanyNameCompanyName As SqlDataReader
Public scmdDataLocks As SqlCommand
Public sdrDataLocks As SqlDataReader
Public scmdDataValidation As SqlCommand
Public sdrDataValidation As SqlDataReader
Public scmdJCLDSNOverride As SqlCommand
Public sdrJCLDSNOverride As SqlDataReader
Public scmdJCLSequence As SqlCommand
Public sdrJCLSequence As SqlDataReader
Public scmdLookupTable As SqlCommand
Public sdrLookupTable As SqlDataReader
Public scmdMasterFileCounts As SqlCommand
Public sdrMasterFileCounts As SqlDataReader
Public scmdMZPUser As SqlCommand
Public sdrMZPUser As SqlDataReader
Public scmdRecordTypes As SqlCommand
Public sdrRecordTypes As SqlDataReader
Public scmdReport As SqlCommand
Public sdrReport As SqlDataReader
Public scmdRequestData As SqlCommand
Public sdrRequestData As SqlDataReader
Public scmdTransactionFiles As SqlCommand
Public sdrTransactionFiles As SqlDataReader
Public scmdTransactionFileTypes As SqlCommand
Public sdrTransactionFileTypes As SqlDataReader
Public scmdUpdtSummCounts As SqlCommand
Public sdrUpdtSummCounts As SqlDataReader
Public scmdUserGroup As SqlCommand
Public sdrUserGroup As SqlDataReader
Public scmdUserNamesUserNames As SqlCommand
Public sdrUserNamesUserNames As SqlDataReader
Public scmdWorkorderDSN As SqlCommand
Public sdrWorkorderDSN As SqlDataReader
'* ADO.Net Variables
Public dsMZP As DataSet
Public dtDataValidation As DataTable
Public drowDataValidation() As DataRow
Public dtDSN As DataTable
Public drowDSN1 As DataRow
Public drowDSN2() As DataRow
Public dtHistoryEntries As DataTable
Public drowHistoryEntries1 As DataRow
Public drowHistoryEntries2() As DataRow
Public dtLookupTable As DataTable
Public drowLookupTable1 As DataRow
Public drowLookupTable2() As DataRow
Public dtMasterFileCounts As DataTable
Public drowMasterFileCounts1 As DataRow
Public drowMasterFileCounts2() As DataRow
Public dtStates As DataTable
Public drowStates2() As DataRow
Public dtSubcodes As DataTable
Public drowSubcodes1 As DataRow
Public drowSubcodes2() As DataRow
Public dtTransactionFiles As DataTable
Public drowTransactionFiles1 As DataRow
Public drowTransactionFiles2() As DataRow
Public dtTransactionFileTypes As DataTable
Public drowTransactionFileTypes1 As DataRow
Public drowTransactionFileTypes2() As DataRow
Public dtClientTransactionFileTypes As DataTable
Public drowClientTransactionFileTypes2() As DataRow
'* Enumerated Types
Public Enum UCDData As Integer
UCDRecordLength = 4000
UCDUpdateStartDate = 57
UCDCustomer = 210
UCDActivity30 = 223
UCDActivity40 = 236
UCDActivity50 = 249
UCDItem60 = 314
UCDItem70 = 327
UCDNAHist = 392
UCDMPHist = 405
UCDPromoHist = 418
UCDProsPromoHist = 470
UCDMZPXref = 444
UCDClientXref = 431
UCDCTable = 457
UCDStartMZPAcctNbr = 1820
UCDEndMZPAcctNbr = 1830
UCDStartALFNbr = 2685
UCDEndALFNbr = 2695
UCDEcomMaster = 3861
UCDGreatestTranDate = 3993
End Enum
Public Enum CountsFileData As Integer
CFRecordLength = 1000
CFProjNbr = 1
CFClientID = 8
CFUpdateStartDate = 14
CFMonthsKeptMP = 22
CFMonthsKeptPromo = 24
CFMonthsKeptNameAddr = 26
CFMzpCustMstrCount = 28
CFMzpMstr30 = 41
CFMzpMstr40 = 54
CFMzpMstr50 = 67
CFMzpMstr60 = 80
CFMzpMstr70 = 93
CFMzpNameAddrCount = 106
CFMzpMergePurgeCount = 119
CFMzpPromoHistCount = 132
CFMzpClientMzpXref = 145
CFMzpToMzpXref = 158
CFMzpClientSpecCount = 171
CFMzpProsPromoCount = 184
CFInputMp769Recs = 197
CFInputMp76910 = 210
CFInputMp76911 = 223
CFInputMp76912 = 236
CFInputMp76913 = 249
CFInputMp76914 = 262
CFInputActv30 = 275
CFInputActv40 = 288
CFInputActv50 = 301
CFInputActvDropCount = 314
CFInputItem60 = 327
CFInputItem70 = 340
CFInputItemDropCount = 353
CFInputMpTransCount = 366
CFInputPromoHstCount = 379
CFInputClientCCount = 392
CFInputProsPromoCount = 405
CFGb210CogMoveMths = 418
CFGb210NameAddrCnt = 421
CFGb210ActvCnt = 434
CFGb211NameAddrCnt = 447
CFGb211ActvCnt = 460
CFStartingAcctNumb = 473
CFEndingAcctNumb = 483
CFGb250MzpCmbCount = 493
CFGb263Mstrs769 = 506
CFGb250NewMzpAccts = 519
CFGb251CoaNohits = 532
CFGb271MpDropCount = 545
CFGb273PromoDropCount = 558
CFGb277DroppedNameAddr = 571
CFMonthKeepProsPromo = 584
CFExpProsPromoCount = 586
CFGb261GreatestTranDate = 599
CFEcomMthsToKeep = 607
CFMzpMstrEcomRecs = 609
CFExpEcomCnt = 622
CFMzpTranEcomE1Recs = 635
CFMzpTranEcomE2Recs = 648
CFMzpTranEcomE3Recs = 661
CFMzpTranEcomE4Recs = 674
CFFiller = 687
End Enum
'* Other Variables
Public gstructPromoHistJobClSpecColDesc As PromoHistJobClSpecColDesc
Public gstructMiscData As MiscData
Public gstructUCDDSNData As UCDDSNData
Public galErrors As ArrayList
Public gstrXMLFile As String
Public gstrLocalFolder As String
Public gstrLocalXMAFolder As String
Public gstrRemoteFTPFolder As String
Public gstrCommonDataFolder As String
Public gstrDataFolder As String
Public gstrClientFolder As String
Public gstrCSUtilitiesDataFolder As String
Public gstrITProjectTrackerDataFolder As String
Public gstrProdDocFolder As String
Public gstrTestPath As String
Public gstrLogoPath As String
Public gstrADOProvider As String
Public gstrADOExtendedProperties As String
Public gstrSQLProvider As String
Public gstrSQLServer As String
Public gstrMasterUserIDs As String
Public gstrCompanyName As String
Public gstrGroupName As String
Public gstrReportFile As String
Public gstrFullFileName As String
Public gstrMaintenanceMode As String
Public gstrStatsFileMask As String
Public gstrCountsFileMask As String
Public gstrOverlayFileMaskCustout As String
Public gstrOverlayFileMaskClntout As String
Public gstrOverlayFileMaskCultcode As String
Public gstrOverlayFileMaskLhi As String
Public gstrLookupTableFileMaskOrder As String
Public gstrLookupTableFileMaskGeneric As String
Public gstrQCControlFileMask As String
Public gstrVirtualTape As String
Public gstrDefaultRecipient As String
Public gstrLastMaintenanceDate As String
Public gstrCount999FileMask As String
Public gstrMaster999s() As String
Public gstrTrans999s() As String
Public gstrDataDictionaryDefaultColumns As String
Public gstrDataDictionaryDeletedDataValue As String
Public gstrDataDictionaryLastColumn As String
Public gstrAlterianFTPSite As String
Public gblnSuperUser As Boolean
Public gblnLogonOK As Boolean = False
Public gblnTraining As Boolean = False
Public gblnFTOK As Boolean
Public gblnCancelled As Boolean
Public gblnDone As Boolean
Public gblnPerformingUpdateQC As Boolean
|
|
|
|
|
|
Unfortunately not. This is a Winform project, that started it's life as VB.NET 2003. All new code this guy writes has the same stuff.
|
|
|
|
|
He definitely is not typing lazy...
|
|
|
|
|
EyeYamFedUp wrote: Guess how many years he's been coding?
10+ years in VB, 0 years in OO
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
Is your company pay for line of code you write?
|
|
|
|
|
This is clearly copied from somewhere. You can see that from the nonsense prefixes. Either from the net or from this VB6 Win32 API code snippet tool from MS (forgot the exact name).
Obviously this guy is a VB5/6 'programmer' who was under the earth for the last 10 years. Maybe he is coding for 30 years or so, but he is/was 'coding' exclusively in VB. He has no idea of OO programming, maybe he thinks VB5/6 IS OO...
And regarding modules named modCommon or Globals or the like: they are just crying out loud that there's a significant problem with the systems overall architecture (which is also obvious from the module description).
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
Thomas Weller wrote: He has no idea of OO programming, maybe he thinks VB5/6 IS OO
Blasphemy ...
OK maybe you're right about VB5.
But surely VB6 is a OO programming language.
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
BadKarma wrote: But surely VB6 is a OO programming language.
Right. I forgot that VB6 has 'classes', so it must be OO...
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|