Programming Version 0.4 Page 1 of 356 Programming Peter Fox
Total Page:16
File Type:pdf, Size:1020Kb
Programming Version 0.4 Page 1 of 356 Programming Peter Fox A manual for everyone from novice to expert This is a tutorial, starting from the very beginning, on how to be a programmer. • Acquire the skills of writing computer programs • Find out what makes programmers different • Learn how to avoid the mistakes ordinary programmers make • Develop your of creativity and concentration • See the world afresh in the crystal sharp focus of precision analysis Whether you're thinking of trying some simple programming, already do a bit, get paid to program or work with programmers this book will open your eyes and put you on the right track. This is not a tome on Computer Science, and doesn't set out to teach a particular language. The ultimate objective is to show how to become an elite programmer, someone who can 'see through walls', asks the right questions of the right people, produces sleek and robust programs... ... and be well paid, well respected and enjoying a superior lifestyle. Programming Version 0.4 Page 2 of 356 About the author Early days Peter Fox has been a freelance jobbing programmer and business analyst since 1980. He started working on programming word processors from machine code to management awareness courses in the early days of office automation, including a fair stint as editor of the BCS's Word Processing and Office Automation specialist group newsletter. IT revolution During the 80's and 90's he cautiously exploited the developments in technology as PCs went from isolated single purpose tools - to locally networked departmental groups with a specific purpose and shared data - to fully networked, multi purpose systems. Applications included: A lot of critical programming for various financial services companies, stores, scientific inventory management, many odd databases, ad-hoc technical support and a multitude of small programming and consultancy jobs. In general his preferred approach is to establish a long term advisory and support role so that clients can 'pick up the phone' about urgent technical issues or general strategic matters. Business analysis His business insight has brought about significant changes to the quality and efficiency of clients. One instance of this is a thorough investigation of the way in which 'High street' optometry is managed within the National Health Service. Vague dissatisfaction with the procedures and confusion about how to manage professional standards was replaced by professionally designed procedures, an 'its so obvious when you put it like that' quality system, methodically designed formal protocols, and a strategic plan for implementation. The Bad-Good-Best model of competency (for clinical governance in this case) was a result of this work. The web Publishing on the web started out as an interesting hobby in 1995, developing as the technology, capacity and ubiquity of the web developed. Currently concentrating on PHP and mySQL, the object is to combine robust system design with efficient code production to exploit the many new ways organisations can operate in the new Internet age. Trivia BSc. Degree in engineering. Was chairman of and coach at Tiptree Rollerskating Club for 14 years. Qualified cycling instructor. Fool of Maldon Greenjackets Morris. Songwriter. Programming Version 0.4 Page 3 of 356 CHAPTER HEADINGS 0. Take aim 1. Begin! 2. The basic technology of programming 3. Logic 4. Control structures 5. First steps in coding 6. Data structures 7. Data gets intelligent 8. Progress review 9. Let us code 10. Databases 11. User interfaces 12. Good code (Anatomy of melancholy,Threads,Algorithms) 13. Testing and quality 14. Code interlude 15. Serving 16. Security 17. Assisted development 18. Get a life 19. Review Glossary A. Using Javascript B. Binary logic C. CD collection D. TinyDate object E. Compiling and linking. Libraries F. Filing system G. Quality in a nutshell H. Two quick management tools @@@ To be expanded. Needs to be presented as a dynamic progression not a bare catalogue. Programming Version 0.4 Page 4 of 356 Introduction Objective I was asked which was the better of two computer programming languages for a beginner to learn. Neither was brilliant, so I did what hackers do - rolled my own. Then I realised it was the wrong question, and I should have read between the lines: How does a non-programmer become a programmer? It soon became clear that the programming languages, development environments, computer science references and years of experience were secondary to: By thinking like a programmer. That is the objective of this book. You can use this book to go from complete novice to elite programmer, to learn how languages work, to discover how to design a program, how to convert ideas into high quality software and what techniques of logic and automation will give efficient and reliable results. • To begin with, for outright beginners, we'll work with a paper and pencil instruction language to get the feel for 'giving instructions'. • Then there's a look at the basics of computer languages - a bit of hands-on Javascript and HTML. • Followed by an introduction to Object Oriented design and programming with exercises that you can follow in whatever language you've chosen. • Gradually the subjects become more technical and the exercises more detailed giving you the opportunity to learn a little at a time both the knowledge and skill aspects. • As we go a theme is developed emphasising the importance of applying intellectual effort. The brain is a magnificent tool and I show you how to apply it to developing high quality software. • Finally we look at the necessary non-technical aspects of being a programmer such as inter-personal skills and self-discipline. This book is designed for anyone who is not afraid of applied brainwork. • the absolute beginner • the person who is doing 'a bit of programming' • non-computer people who wonder how to make the best use of the best programmers • career programmers who are wondering what is it that makes the best stand out and shine. Becoming a programmer Not only is programming creative, intellectually challenging and fun but people pay you well too! Programming Version 0.4 Page 5 of 356 •A technician is somebody who can understand instructions of a technical nature and if things go wrong can blame somebody else. • Management usually takes the responsibility of actually making workable systems work and even defining what "work" means. To make a workable system fail you have to be management. To insist a hopeless system is delivering results you have to be a suit. •An engineer is someone who has the responsibility for designing and building a workable system. As a Real Programmer1 you will be an engineer. You'll have far more knowledge about the technology than the technicians and a much better grasp of the Right Way to do things than the suits. If, by half-way through this book you've cottoned-on to the concept of 'a real programmer as an engineer' then by the end you'll have the knowledge and outlook (if not yet the experience2) to be able to make an impact. This 'impact' might be in personal achievement of being able to write a program to solve Sudoku puzzles, or to collect the data and draw the graph that gets the sales manager sacked3 for being a useless waste of space - or gives the sales manager the tools so they can achieve their aspirations.4 If all you want to do is learn how to program in language 'X' (where 'X' is your particular choice of language) then this book will help you a bit, but not enough to be an expert in 'X'. Go and get "How to program in 'X' in 27½ minutes". If you have already done a bit of computer programming then *this book is for you* even though you think you know the subject. Hey! Guess what books steam engine buffs read - Yes, that's right: Books on steam engines. This is a specialist subject and there are loads of wrinkles and fundamental concepts that you can miss even if you do the job every day. One of those might change your whole outlook, prevent grief and open the odd oyster or two. You should still browse the early chapters and you might find the exercises are useful refreshment. But most of all, without prejudice to the above, this book is for people who want to program who have never done this sort of thing before. There's a nice slow start and even though later on the concepts might be complex, you'll be surfing the crest of the wave and it will be easy. 1 This term Real Programmer will crop up a lot. The insights and exercises in this book should give you the necessary leg-up to become an elite programmer capable of useful performance far beyond the average code-wallah. (Some people say 5 to 10 times better!) 2 Or the knowledge that you have the knowledge - There's a bit of Zen in all this. 3 Dumping rubbish is unpleasant but necessary. First somebody has to identify clearly, backed with figures, what is rubbish. Real programmers tend to be detached from politics and are often ideally placed to supply wood, nails, and drawings for a cross. More at the end. 4 Don't expect adequate recompense for saving bacon and many thousands of pounds. That's why good programmers should get paid large amounts of money for all that they do even if only 2% of their (often extra curricular) work brings in the Big Wins. All Real Programmers can tell you of, literally, five minutes where they cracked the case - often against opposition from slugs in suits! No wonder they're a feisty bunch.