Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Spaghetti Code How to Make a Career Out of Playing With Computers
Spaghetti Code How to Make a Career Out of Playing With Computers
Spaghetti Code How to Make a Career Out of Playing With Computers
Ebook611 pages2 hours

Spaghetti Code How to Make a Career Out of Playing With Computers

Rating: 0 out of 5 stars

()

Read preview

About this ebook

This is a delicious compilation of assorted algorithms, programs, applications, and cartoons that I have created over the years using a variety of tools and programming languages, most notably Clipper and dBase, but also C, awk, sed, grep, perl, SQL, shell scripting, and india ink. DO NOT BUY THIS BOOK TO LEARN HOW TO PROGRAM! This is more of a book on how NOT to write computer programs. However, if you are an experienced programmer and enjoy viewing code as a logic puzzle, or you would just like to own a collection of some of the most hilarious cartoons and arcane algorithms you will ever be challenged to digest, then by all means, spend a few bucks! Bon Apetite!
LanguageEnglish
PublisherLulu.com
Release dateFeb 7, 2014
ISBN9781304885982
Spaghetti Code How to Make a Career Out of Playing With Computers
Author

Carl Allen Schoner

Carl Allen Schoner holds a degree in behavioral science and is a certified clinical hypnotherapist. In addition to practicing hypnotherapy, he has been a teacher, a consultant, and has conducted motivational and sales training seminars. He is also a writer and cartoonist, and his articles and cartoons have appeared in publications such as Consulting Magazine, The California Law School Journal, Chess Life Magazine, and The Saturday Evening Post. His brother, Steven Ronald Schoner, is an internationally known authority on meteorites, and is an avid meteorite hunter.

Read more from Carl Allen Schoner

Related to Spaghetti Code How to Make a Career Out of Playing With Computers

Related ebooks

Computers For You

View More

Related articles

Reviews for Spaghetti Code How to Make a Career Out of Playing With Computers

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Spaghetti Code How to Make a Career Out of Playing With Computers - Carl Allen Schoner

    Spaghetti Code How to Make a Career Out of Playing With Computers

    Spaghetti Code How to Make a Career Out of Playing With Computers

    By

    Carl Allen Schoner

    DBA

    Published by Carl Allen Schoner

    CAS Associates

    P.O. Box 4462

    Diamond Bar, CA 91765

    cschoner@netzero.com

    dreampsycles@yahoo.com

    www.lulu.com/carl_schoner

    All original artwork by Carl Allen Schoner

    © Copyright 2006, by Carl Allen Schoner

    ISBN: 978-1-304-88598-2

    All copyrights reserved by the author. No part of this publication may be reproduced or copied in any way without the express written permission of the author.

    Printed in the United States of America.

    Release 1.0

    This book is dedicated to everyone who has come to realize how little they know about what they are doing.

    "Real programmers favor devising solutions to problems

    which have already been programmatically solved."

    - Carl Allen Schoner

    PREFACE

    The road from writing BASIC programs that displayed little fish swimming back and forth on the screen of my beloved Radio Shack Color Computer to my current responsibilities as an Oracle DBA (database Administrator) for a one of the largest educational institutions in the state of California has been a long one. On my journey from novice to respected professional, I have participated in the development and implementation of a bevy of application systems and platforms ranging from stand-alone PC applications to LAN and WAN based enterprise-wide distributed database and information systems. I have seen single departmental applications built entirely on an old Wordstar word processing package, to large enterprise-wide mission critical systems and applications built on big-iron UNIX OS platforms hosting thousands of terminals and devices. While as a DBA I do very little application coding today - and in fact I have never really considered myself to be an expert at programming applications - in the past I have been responsible for either writing code or supporting code necessary for implementing these systems and applications. What I have learned from all this is nothing short of astonishing, for I discovered that under the hood of virtually every mature application lurks a quagmire of messy, sloppy, tangled, unintelligible Spaghetti Code. Programs that were initially tight but are subsequently revised always mature, and the more mature the release the greater the likelihood that it will bloat into a monstrosity so convoluted that it takes an army of highly paid Systems Analysts to support. They may look pretty on the surface, but under the hood most applications are really, really ugly. Real programmers do not produce pretty, well documented code. Nobody ever reads the documentation anyway, and I am no exception. Real programmers simply start coding new solutions, even if the problem they are attempting to solve has already been solved many, many times before. So don’t expect the code in this book to be pretty or well documented. It isn’t. I could have put some lipstick on this pig of a book, but it would still be a pig.  It’s ugly and always will be. That is why it’s called Spaghetti Code.

    INTRODUCTION

    When I graduated from high school back in (well, I’ll let you guess how old I am by everything else I say in this book), I didn’t have a clue, really, of what I wanted to do in life. You would think that I should have had at least some idea, because I had been working at all kinds of jobs since I was 11 years old. I had been a paperboy, a ranch-hand, a busboy, a dishwasher, a dog-catcher, a factory worker, a paint delivery man, a forklift driver, and I held several other blue-collar type jobs to support myself and my apartment after graduating from high school. I also attended community college part-time. After about two years I decided that I wanted to break into a more professional field. I was a gutsy 19 year old who believed I could anything I set my mind on, so when I saw an ad in the newspaper for an Assistant Manager position with Public Finance - which was then the Country’s largest consumer finance company - I boldly applied for the position, despite the fact that I had absolutely no applicable experience whatsoever in either consumer finance or personnel management. Nonetheless, my bold approach and over-confidence convinced them to hire me, and I became the youngest Assistant Manager ever hired by the company.

    I learned a very valuable lesson by that experience. I learned that what you believe you are capable of doing in life is a much more powerful determinant of your success than is the mere knowledge of what you are currently capable of doing today. If you really want to succeed in the cut-throat competition that defines the corporate labor market, you must sell your potential more than your accomplishments. I sold my prospective employer on the idea that not only could I fully perform the duties of this job, but I would perform them better than anyone else they might hire. They believed me, hired me, and within one year I was recognized as not only an excellent assistant manager, but also one of the best skip-tracers for Public Finance on the west coast (a skip-tracer is a consumer finance detective who specializes in locating dead-beat people who have skipped out on their loan obligations). I loved my job, and felt on top of the world.

    I think the reason I excelled at skip-tracing is that it involved solving problems, and combining creative processes with analytical problem solving skills was always one of my stronger suits. I have always been good at both inductive and deductive reasoning, and this coupled with well defined people skills gave me all the ammunition I needed to be successful at skip-tracing.  For a couple of years this was all I needed in life. I wore a nice suit and tie, made more money than any of my friends, drove a nice ’65 Buick Riviera, and was a hit with the ladies. But then two branch managers talked me into moving into an apartment that we would all share, and I stupidly did this, knowing that they were both married and really only wanted a convenient crash pad for weekend parties. I was not prepared for the infringement this living arrangement would make on my own lifestyle, and I eventually found myself in serious conflict with my new roommates. Eventually, this poor decision destroyed not only my friendship with them, but it also cost me my job. I walked out of the office and moved out of the apartment on the same day.

    That done, I returned to college and worked at a furniture store to support myself. I majored in Behavioral Science, a liberal arts field of study that was very popular back then, and my general intention at that time was to further my education to become either a psychiatrist, psychologist, counselor, or a college instructor, but as I said, I really hadn’t decided just what it was that I wanted to do. Upon graduation, I took a job as a counselor in a locked psychiatric facility for adolescent schizophrenics, and also obtained a teaching credential and worked as an adult education teacher for the next four years. I enjoyed teaching, but I had also had a taste of the corporate world at Public Finance, and I enjoyed those times too, so I started to think about persuing a career path that would incorporate a little of both worlds. Eventually, the idea of becoming a Corporate Trainer entered my mind. I began searching the employment section of the classified ads in the local newspapers looking for such a position. Every day I searched through the papers, knowing that somewhere there had to be such a position open for me. I knew that with my employment background, degree, and my teaching experience I would be a shoe-in for just about any corporate training position that I could find. The problem was I wasn’t finding any.

    Now, about this time my dad somehow came into possession of this strange contraption known as a personal computer. I don’t really know what he was going to do with it because he was always the kind of person who couldn’t set the correct time on his wristwatch, let alone operate a computer. And upon further investigation I discovered that unlike my brother’s calculators that produced results with the press of a few keys, this computer didn’t do anything. It had to be programmed to perform specific tasks. Now, I had taken a computer programming class at college in which we learned how to use a card punch machine to poke little holes in a stack of index cards, and these cards could then be fed into a great big computer that used a card reader to convert the holes into programs, but I really didn’t get how it all worked. This new personal computer didn’t have a card reader, so I wasn’t sure how my dad was going to program it. Nonetheless, he insisted he was going to learn, and for about six months the computer sat in his home office unused until one day when he brought it to my apartment and asked me if I could show him how to hook it up to the television. I did that, and for the next year or so my little Radio Shack Color Computer and I were very good friends indeed. I learned how to talk to the little guy, and he in turn taught me a whole lot about the world of computers.Miraculously, at about the same time that I matured into a corporate-bred college educated adult-education instructor computer expert, the college professor father of my then-girlfriend asked me if I would assist him with some research he was conducting on emerging business computer systems. I readily agreed to do this and immersed myself in an abyss of arcane articles in print about electronic mailing systems, data banks, databases, and computer technology. At times I felt so overwhelmed by all of this techno-jargon that I was tempted to throw in the towel on the whole project, but miraculously I stuck with it, thoroughly convinced now that my sixth-grade teacher’s prophesy of a rapidly approaching computer revolution was finally coming to fruition. When I was done, I had compiled an article that I submitted for publication in a leading professional journal for corporate business consultants titled Consulting 79 and the rest, they say, is history. The article, which I published long before Al Gore discovered the Internet, and which launched my new career, is reprinted below in its entirety.

    The Color Computer & Other Devices

    By the time I had written and published the Bridging the Information Gap article in Consulting 79, two transformations had taken place in my life. First, I suddenly knew more about electronic mailing systems, data-banks, computers and databases than anyone else I personally knew, and second, I had developed a budding interest in leaning how to make a computer do something. I had become totally obsessed with learning how to input instructions into my little CoCo computer using its chicklet keyboard, and having it respond to all of my instructions when I finally typed run and hit the key!  That is to say, I was becoming a real programmer.  Not a professional programmer, mind you, or even a good one. But I now had a new skill set that very few others could claim at the time, and even if I was only writing spaghetti code, it still gave me a tremendous advantage in the job market.

    TRS 80 COLOR COMPUTER (Circa 1980)

    My first Color Computer program was called Defendo. It presented the basic battle challenge of defending your position at the bottom of the screen from attackers rapidly descending from the top. A little arrow pointing upward from the bottom of the screen could be moved left to right by pressing the appropriate keys, and pressing the space bar would cause the arrow to fire projectiles upwards toward the rapidly descending attackers. It kept your score and congratulated you if you won, and offered condolences if you lost.  It was a worthy little programming effort that I think consumed about two or three days of my time to complete once I had the concept firmly established in my mind. While it did nothing more in terms of what such a simple battle program ought to do, it did one more thing that was nothing short of monumental: It allowed me to call myself a "coder."

    Here is the complete listing for Defendo in addition to a couple of other programs that I wrote for my beloved little CoCo. See if you can figure out what the programs will do by reading the listings. If you can, then maybe you, too, could write Spaghetti Code!

    My First Color Computer Program – Defendo!

    1 GOSUB 2000:CLS(0):PRINT @ 192,DEFENDO:PRINT @ 384,        BY CARL SCHONER:FOR X=1 TO 1000:NEXT X

    2 CLS(0):PRINTYOU MUST DESTOY ALL 10 ENEMY

    3 PRINT SHIPS BEFORE THEY DESTROY YOU.

    4 PRINTTHE ENEMY WILL FIRE ROCKETS

    5 PRINTAND LASERS...:PRINTBUT YOU CAN ONLY FIRE ROCKETS.

    6 PRINTFIRE WITH THE '^' KEY, AND MOVE WITH THE '.' AND '/' KEYS:INPUTPRESS ENTER> WHEN READY TO PLAY;A$:CLS

    7 E=10:G=10

    8 FOR X=1 TO 1000:NEXT X:CLS:PRINT @ 2,ENEMIES;E:PRINT @ 20,GUNS;G

    11 U=463

    12 PRINT @ U,^

    20 C$=   Y   :N$=       

    30 A=200

    40 PRINT @ A,C$:FOR X=1 TO 20:NEXT X:SOUND RND(10),1

    41 V$=INKEY$:IF V$=/ GOTO 400:ELSE IF V$=. GOTO 450

    42 IF V$=^ GOSUB 1000

    60 B=RND(4):IF B=2 GOSUB 500:ELSE IF B=3 GOSUB 600

    70 PRINT @ A,N$;

    75 M=RND(2):ON M GOTO 80,85

    80 IF A>=221 THEN 30:ELSE A=A+RND(2):GOTO 40

    85 IF A<=194 THEN 30:ELSE A=A-RND(2):GOTO 40

    90 CLS:PRINTSORRY, BUT YOU HAVE BEEN COMPLETELY DESTROYED!:GOTO 100

    95 PRINT YOU DESERVE A MEDAL!:PRINTYOU'VE BEATEN THEM ALL!

    99 PLAY L4.;A;L8;C;L4.;E;L8;C;E;C;E;C;L4;A

    100 INPUT PRESS TO PLAY AGAIN;A$:PLAYL4.;A;L8;C;L4.;E;L8;C;E;C;E;C;L;A:GOTO 1

    400 PRINT @ U, :U=U+1:IF U=497 GOTO 540:ELSE GOTO 12

    450 PRINT @ U, :U=U-1:IF U=448 GOTO 540:ELSE GOTO 12

    500 P=(A+3):FOR X=1 TO 3:P=(P+64):PRINT @ P,*

    510 FOR R=1 TO 20:NEXT R:SOUND 100,1

    520 PRINT @ P, :NEXT X

    530 IF P<>U-64 GOTO 70

    540 FOR X=1 TO 30:SOUND RND(255),1:NEXT X:PRINT @ 480,ENEMY POINT:G=G-1:IF G=0 GOTO 90:ELSE GOTO 8

    600 O=RND(6):T=(A+O):FOR X=1 TO 3:T=(T+64):PRINT @ T,'

    620 FOR R=1 TO 5:NEXT R:SOUND 50,1

    630 PRINT @ T, :NEXT X:IF T<>U-64 THEN RETURN:ELSE GOTO 540

    1000 R=U:FOR X=1 TO 8:R=(R-32):PRINT @ R,^:FOR T=1TO 5:NEXT T

    1010 SOUND 200,1:PRINT @ R, :NEXT X

    1020 IF R=(A+3) GOTO 1030

    1025 RETURN

    1030 FOR X=1 TO 30:SOUND RND(15),1:NEXT X:PRINT @ 480,PLAYER'S POINT:E=E-1:IF E=0 GOTO 95:ELSEGOTO 8

    2000 PMODE 4,1:SCREEN 1,1:PCLS

    2020 FOR X=0 TO 256

    2021 Y=(172-RND(15))-RND(10)

    2025 LINE(X,192)-(X,Y),PSET

    2030 NEXT X

    2040 FOR X=1 TO 50:A=RND(256):B=RND(162)

    2045 PSET(A,B)

    2050 NEXT X

    2055 X=10:Y=10

    2060 B=RND(3)

    2061 X=X+1:Y=Y+B

    2070 CIRCLE(X,Y),4:SOUND 250,1

    2075 CIRCLE(X,Y),4,0

    2076 IF Y>=160 THEN GOTO 2077:ELSE GOTO 2061

    2077 FOR V=1 TO 40

    2078 Q=RND(30):T=RND(30):SOUND RND(10),1

    2080 LINE(X,Y)-(X-Q,Y-T),PSET

    2090 NEXT V

    2100 FOR V=1 TO 300:Q=RND(30):T=RND(30)

    2110 LINE(X,Y)-(X-Q,Y-T),PRESET

    2120 NEXT V

    2130 RETURN

    My Second Color Computer Program – Blackjack!

    10 AA=1000:BB=1000:CC=1000:Z=3

    20 CLS:PRINT TWENTY-ONE:PRINT:PRINTTRY TO DRAW TO 21 WITHOUT GOING OVER.

    30 PRINT EACH PLAYER STARTS WITH 1000

    40 PRINT DOLLARS.

    50 PRINT IN THIS GAME, UP TO THREE PEOPLEMAY PLAY AT ONE TIME.:PRINT PLAY ALL THREE HANDS.:FOR X=1 TO 5000:NEXT X:CLS:GOTO 400

    60 CLS:A=0:B=0:C=0:D=0:P=0:T=0:M=0:I=0:Q=0:GOTO 180

    70 P=P+1

    80 I=I+128:T=0:N=I

    90 FOR X=1 TO 12:N=N+3:D=RND(10)

    100 PRINT @ N,D:T=T+D:SOUND RND(50),2

    110 GOTO 440

    120 IF T>21 THEN PRINT @ I+64,BUST:GOTO 160

    130 IF T=21 THEN PRINT @ I+64, T:GOTO 160

    140 PRINT PLAYER#(P);:INPUT DRAW(Y,N);A$

    150 IF A$=N THEN PRINT T:GOTO 160:ELSE NEXT X

    160 IF P=Z THEN 170:ELSE GOTO 70

    170 FOR X=1 TO 12

    180 M=M+3:D=RND(10)

    190 DRAW BM 120,100;C2;D30

    200 PRINT @ M,D:Q=Q+D:SOUND RND(200),2

    210 PRINT COMPUTER'S HAND

    220 FOR T=1 TO 50:NEXT T

    230 IF P

    240 IF Q>21 THEN 260

    250 IF Q>16 THEN 270:ELSE NEXT X

    260 PRINT BUST:FOR X=1 TO 3000:NEXT X:CLS:GOTO 320

    270 PRINT QSTAND:FOR X=1 TO 3000:NEXT X:CLS:GOTO 280

    280 IF A<22 AND A>Q THEN PRINT PLAYER#1 WINS:AA=AA+H:ELSE IF A=Q THEN PRINT "P

    LAYER#1 DRAWS:ELSE PRINT PLAYER#1 LOSES":AA=AA-H

    290 IF B<22 AND B>Q THEN PRINT PLAYER#2 WINS:BB=BB+J:ELSE IF B=Q THEN PRINT "P

    LAYER#2 DRAWS:ELSE PRINT PLAYER#2 LOSES":BB=BB-J

    300 IF C<22 AND C>Q THEN PRINT PLAYER#3 WINS:CC=CC+K:ELSE IF C=Q THEN PRINT "P

    LAYER#3 DRAWS:ELSE PRINT PLAYER#3 LOSES":CC=CC-K

    310 GOTO 360

    320 IF A<22 THEN PRINT PLAYER#1 WINS:AA=AA+H:ELSE PRINT PLAYER#1 LOSES:AA=AA-H

    330 IF B<22 THEN PRINT PLAYER#2 WINS:BB=BB+J:ELSE PRINT PLAYER#2 LOSES:BB=BB-J

    340 IF C<22 THEN PRINT PLAYER#3 WINS:CC=CC+K:ELSE PRINT PLAYER#3 LOSES:CC=CC-K

    350 IF A<22 AND B<22 AND C<22 THEN 460

    360 FOR X=1 TO 2000:NEXT X:CLS:PRINT PLAYER#1 HASAADOLLARS

    370 PRINT PLAYER#2 HASBBDOLLARS

    380 PRINT PLAYER#3 HASCCDOLLARS

    390 FOR X=1 TO 3000:NEXT X:CLS

    400 INPUT 1ST PLAYER'S BET;H

    410 INPUT 2ND PLAYER'S BET;J

    420 INPUT 3RD PLAYER'S BET;K

    430 INPUTPRESS TO CONTINUE;A$:GOTO 60

    440 IF P=1 THEN A=T:ELSE IF P=2 THEN B=T:ELSE IF P=3 THEN C=T

    450 GOTO 120

    460 PMODE 3,1:PCLS

    470 PRINT @ 198,OH NO--NOT AGAIN!

    480 CIRCLE (75,190),50,3:CIRCLE(175,190),50,3

    490 PAINT (75,170),2,3:PAINT (175,170),2,3

    500 CIRCLE (75,180),10,0:PAINT(75,180),0,0

    510 CIRCLE (175,180),10,0:PAINT (175,180),0,0

    520 CIRCLE (125,60),50,3,1.25

    530 CIRCLE (125,90),15,3,1.45

    540 CIRCLE (125,90),15,3,.65

    550 PAINT (125,75),0,3:PAINT (125,105),0,3

    560 DRAW BM 115,87;C3;R20

    570 PAINT (119,85),2,3

    580 CIRCLE (125,80),90,3,.45

    590 CIRCLE (125,60),70,3,.9,.5,0

    600 PAINT (125,10),0,3

    610 PAINT(75,22),3,3:PAINT (175,22),3,3

    620 PAINT (70,60),0,3:PAINT (180,60),0,3

    630 CIRCLE (125,60),9,3,.9,.5,0:PSET(122,60,3):PSET (127,60,3)

    640 PAINT (125,60),2,3

    650 DRAW BM 105,120;C3;D35:DRAWBM 143,120;C3;D36

    660 PAINT (120,130),2,3

    670 SCREEN 1,0

    680 FOR X=1 TO 500:NEXT X:CLS

    690 S=RND(7):ON S GOTO 700,710,720,730,740,750,760

    700 PRINT @ 200,NOW YOU STRIP!:GOTO 770

    710 PRINT @ 200,TRY THAT AGAIN!:GOTO 770

    720 PRINT @ 197,YOU LIKE WHAT YOU SEE?:GOTO 770

    730 PRINT @ 200,NOW SHOW ME SOME!:GOTO 770

    740 PRINT @ 199,I LIKE YOUR STYLE!:GOTO 770

    750 PRINT @ 200,GIVE ME A BREAK!:GOTO 770

    760 PRINT @ 196,I THINK YOU'RE SEXY TOO!

    770 GOTO 360

    HEXMONI.BAS – My first Coco

    Enjoying the preview?
    Page 1 of 1