It's important to be prepared- but not too prepared. A common trap developers fall into is "premature abstraction"- trying to solve the general case of a problem when you only need to solve a very specific case.
Frequent contributor Argle sends us some very old BASIC code. The task was to convert this ancient language into C#.
Someone decided that, instead of waiting to learn specifically what variables they'd eventually need, they'd just declare all the variables they could ever want right at the top.
Which gives us this block, included in its entirety.
COMMON PRICE1, PIECE1, PRICE2, PIECE2, PRICE3, PIECE3, PRICE4, PIECE4
COMMON PRICE5, PIECE5, PRICE6, PIECE6, PRICE7, PIECE7, PRICE8, PIECE8
COMMON PRICE9, PIECE9, PRICE10, PRICE11, PIECE11, PRICE12, PIECE12
COMMON PRICE13, PIECE13, PRICE14, PIECE14, PRICE15, PIECE15, PRICE16, PIECE16
COMMON PRICE17, PIECE17, PRICE18, PIECE18, PRICE19, PIECE19, PRICE20
COMMON PRICE21, PIECE21, PRICE22, PIECE22, PRICE23, PIECE23, PRICE24, PIECE24
COMMON PRICE25, PIECE25, PRICE26, PIECE26, PRICE27, PIECE27, PRICE28, PIECE28
COMMON PRICE29, PIECE29, PRICE30, PRICE31, PIECE31, PRICE32, PIECE32
COMMON PRICE33, PIECE33, PRICE34, PIECE34, PRICE35, PIECE35, PRICE36, PIECE36
COMMON PRICE37, PIECE37, PRICE38, PIECE38, PRICE39, PIECE39, PRICE40
COMMON PRICE41, PIECE41, PRICE42, PIECE42, PRICE43, PIECE43, PRICE44, PIECE44
COMMON PRICE45, PIECE45, PRICE46, PIECE46, PRICE47, PIECE47, PRICE48, PIECE48
COMMON PRICE49, PIECE49, PRICE50, PRICE51, PIECE51, PRICE52, PIECE52
COMMON PRICE53, PIECE53, PRICE54, PIECE54, PRICE55, PIECE55, PRICE56, PIECE56
COMMON PRICE57, PIECE57, PRICE58, PIECE58, PRICE59, PIECE59, PRICE60
COMMON PRICE61, PIECE61, PRICE62, PIECE62, PRICE63, PIECE63, PRICE64, PIECE64
COMMON PRICE65, PIECE65, PRICE66, PIECE66, PRICE67, PIECE67, PRICE68, PIECE68
COMMON PRICE69, PIECE69, PRICE70, PRICE71, PIECE71, PRICE72, PIECE72
COMMON PRICE73, PIECE73, PRICE74, PIECE74, PRICE75, PIECE75, PRICE76, PIECE76
COMMON PRICE77, PIECE77, PRICE78, PIECE78, PRICE79, PIECE79, PRICE80
COMMON PRICE81, PIECE81, PRICE82, PIECE82, PRICE83, PIECE83, PRICE84, PIECE84
COMMON PRICE85, PIECE85, PRICE86, PIECE86, PRICE87, PIECE87, PRICE88, PIECE88
COMMON PRICE89, PIECE89, PRICE90, PRICE91, PIECE91, PRICE92, PIECE92
COMMON PRICE93, PIECE93, PRICE94, PIECE94, PRICE95, PIECE95, PRICE96, PIECE96
COMMON PRICE97, PIECE97, PRICE98, PIECE98, PRICE99, PIECE99, PRICE100
COMMON PRINSUL, PRPARTS
COMMON PART1$, PRIWIRE$, SECWIRE$
COMMON MAT1$, MAT2$, MAT3$, MAT4$, MAT5$, MAT6$, MAT7$, MAT8$, MAT9$
COMMON MAT11$, MAT12$, MAT13$, MAT14$, MAT15$, MAT16$, MAT17$, MAT18$, MAT19$
COMMON MAT21$, MAT22$, MAT23$, MAT24$, MAT25$, MAT26$, MAT27$, MAT28$, MAT29$
COMMON MAT31$, MAT32$, MAT33$, MAT34$, MAT35$, MAT36$, MAT37$, MAT38$, MAT39$
COMMON MAT41$, MAT42$, MAT43$, MAT44$, MAT45$, MAT46$, MAT47$, MAT48$, MAT49$
COMMON MAT51$, MAT52$, MAT53$, MAT54$, MAT55$, MAT56$, MAT57$, MAT58$, MAT59$
COMMON MAT61$, MAT62$, MAT63$, MAT64$, MAT65$, MAT66$, MAT67$, MAT68$, MAT69$
COMMON MAT71$, MAT72$, MAT73$, MAT74$, MAT75$, MAT76$, MAT77$, MAT78$, MAT79$
COMMON MAT81$, MAT82$, MAT83$, MAT84$, MAT85$, MAT86$, MAT87$, MAT88$, MAT89$
COMMON MAT91$, MAT92$, MAT93$, MAT94$, MAT95$, MAT96$, MAT97$, MAT98$, MAT99$
COMMON WINDINGLENGTH, SHORTERWINDINGLENGTH, FILLER, FILLERSHORTERWINDINGLENGTH
COMMON WINDINGLENGTH$, SHORTERWINDINGLENGTH$, PARTS$
COMMON ADD1, ADD2, ADD3, ADD4, ADD5, ADD6, ADD7, ADD8, ADD9, ADD10
COMMON ADD11, ADD12, ADD13, ADD14, ADD15, ADD16, ADD17, ADD18, ADD19, ADD20
COMMON ADD21, ADD22, ADD23, ADD24, ADD25, ADD26, ADD27, ADD28, ADD29, ADD30
COMMON ADD31, ADD32, ADD33, ADD34, ADD35, ADD36, ADD37, ADD38, ADD39, ADD40
COMMON ADD41, ADD42, ADD43, ADD44, ADD45, ADD46, ADD47, ADD48, ADD49, ADD50
COMMON ADD51, ADD52, ADD53, ADD54, ADD55, ADD56, ADD57, ADD58, ADD59, ADD60
COMMON ADD61, ADD62, ADD63, ADD64, ADD65, ADD66, ADD67, ADD68, ADD69, ADD70
COMMON ADD71, ADD72, ADD73, ADD74, ADD75, ADD76, ADD77, ADD78, ADD79, ADD80
COMMON ADD81, ADD82, ADD83, ADD84, ADD85, ADD86, ADD87, ADD88, ADD89, ADD90
COMMON ADD91, ADD92, ADD93, ADD94, ADD95, ADD96, ADD97, ADD98, ADD99, ADD100
COMMON ADD101, ADD102, ADD103, ADD104, ADD105, ADD106, ADD107, ADD108, ADD109, ADD110
COMMON ADD111, ADD112, ADD113, ADD114, ADD115, ADD116, ADD117, ADD118, ADD119, ADD120
COMMON ADD121, ADD122, ADD123, ADD124, ADD125, ADD126, ADD127, ADD128, ADD129, ADD130
COMMON ADD131, ADD132, ADD133, ADD134, ADD135, ADD136, ADD137, ADD138, ADD139, add140
COMMON ADD141, ADD142, ADD143, ADD144, ADD145, ADD146, ADD147, ADD148, ADD149, ADD150
COMMON ADD151, ADD152, ADD153, ADD154, ADD155, ADD156, ADD157, ADD158, ADD159, ADD160
COMMON ADD161, ADD162, ADD163, ADD164, ADD165, ADD166, ADD167, ADD168, ADD169, ADD170
COMMON ADD171, ADD172, ADD173, ADD174, ADD175, ADD176, ADD177, ADD178, ADD179, ADD180
COMMON ADD181, ADD182, ADD183, ADD184, ADD185, ADD186, ADD187, ADD188, ADD189, ADD190
COMMON ADD191, ADD192, ADD193, ADD194, ADD195, ADD196, ADD197, ADD198, ADD199, ADD200
COMMON ADD201, ADD202, ADD203, ADD204, ADD205, ADD206, ADD207, ADD208, ADD209, ADD210
COMMON ADD211, ADD212, ADD213, ADD214, ADD215, ADD216, ADD217, ADD218, ADD219, ADD220
COMMON ADD221, ADD222, ADD223, ADD224, ADD225, ADD226, ADD227, ADD228, ADD229, ADD230
COMMON ADD231, ADD232, ADD233, ADD234, ADD235, ADD236, ADD237, ADD238, ADD239, ADD240
COMMON ADD241, ADD242, ADD243, ADD244, ADD245, ADD246, ADD247, ADD248, ADD249, ADD250
COMMON ADD251, ADD252, ADD253, ADD254, ADD255, ADD256, ADD257, ADD258, ADD259, ADD260
COMMON ADD261, ADD262, ADD263, ADD264, ADD265, ADD266, ADD267, ADD268, ADD269, ADD270
COMMON ADD271, ADD272, ADD273, ADD274, ADD275, ADD276, ADD277, ADD278, ADD279, ADD280
COMMON ADD281, ADD282, ADD283, ADD284, ADD285, ADD286, ADD287, ADD288, ADD289, ADD290
COMMON ADD291, ADD292, ADD293, ADD294, ADD295, ADD296, ADD297, ADD298, ADD299, ADD300
COMMON ADD1$, ADD2$, ADD3$, ADD4$, ADD5$, ADD6$, ADD7$, ADD8$, ADD9$, ADD10$
COMMON ADD11$, ADD12$, ADD13$, ADD14$, ADD15$, ADD16$, ADD17$, ADD18$, ADD19$, ADD20$
COMMON ADD21$, ADD22$, ADD23$, ADD24$, ADD25$, ADD26$, ADD27$, ADD28$, ADD29$, ADD30$
COMMON ADD31$, ADD32$, ADD33$, ADD34$, ADD35$, ADD36$, ADD37$, ADD38$, ADD39$, ADD40$
COMMON ADD41$, ADD42$, ADD43$, ADD44$, ADD45$, ADD46$, ADD47$, ADD48$, ADD49$, ADD50$
COMMON ADD51$, ADD52$, ADD53$, ADD54$, ADD55$, ADD56$, ADD57$, ADD58$, ADD59$, ADD60$
COMMON ADD61$, ADD62$, ADD63$, ADD64$, ADD65$, ADD66$, ADD67$, ADD68$, ADD69$, ADD70$
COMMON ADD71$, ADD72$, ADD73$, ADD74$, ADD75$, ADD76$, ADD77$, ADD78$, ADD79$, ADD80$
COMMON ADD81$, ADD82$, ADD83$, ADD84$, ADD85$, ADD86$, ADD87$, ADD88$, ADD89$, ADD90$
COMMON ADD91$, ADD92$, ADD93$, ADD94$, ADD95$, ADD96$, ADD97$, ADD98$, ADD99$, ADD100$
COMMON ADD101$, ADD102$, ADD103$, ADD104$, ADD105$, ADD106$, ADD107$, ADD108$, ADD109$, ADD110$
COMMON ADD111$, ADD112$, ADD113$, ADD114$, ADD115$, ADD116$, ADD117$, ADD118$, ADD119$, ADD120$
COMMON ADD121$, ADD122$, ADD123$, ADD124$, ADD125$, AD1D26$, ADD127$, ADD128$, ADD129$, ADD130$
COMMON ADD131$, ADD132$, ADD133$, ADD134$, ADD135$, ADD136$, ADD137$, ADD138$, ADD139$, add140$
COMMON ADD141$, ADD142$, ADD143$, ADD144$, ADD145$, ADD146$, ADD147$, ADD148$, ADD149$, ADD150$
99% of these variables are never used. The hypothesis was that, once they were used, they'd get renamed into something more meaningful. If you skim through, you'll see that there are some named variables in that code, like PRIWIRE$
and SECWIRE$
. Those variables are not used anywhere in the code. But don't worry, PRICE31
is. Somewhere.
At least they'll never have to declare a new variable again.