Sunday, December 20, 2015

I have finally finished reading that code complete book. Before I had been thinking of drawing diagram for every piece of code that I need to build. Now I am thinking that the best way to do everything is to ask a lot of questions at every level. For example, my next program is a back to basics windows program. I have done this dozens of times before so there is no point going over it again. However, while I always got it to work right, I can never get past it to build more complex code. Drawing a diagram or making a plan would not work simply because I have no idea what I am doing. The only way I can fix this properly is to ask a series of simple questions about why each small thing is done. First: What is the point of all this code. This code does three main things. One: It initializes a window object by defining a custom class and then creating it. Two: I runs a message loop to get event messages from the window object. Three: it processes those messages, using them to update the window and close the program. Question: Why does it take so much code to create the window. Windows are very generic objects that are used all over the operating system. They all have to work the same way because they must all work together on the same screen. All these options in the two create functions are there to allow a whole set of customizations that most people will not ever need. You can mostly pick a preference and stick with it. Question: Why do we need the running global variable. The problem with the message loop is that it controls the entire program, but there is not safe way for the loop to know by itself when the program is over. The running variable is set to true before the loop starts, and then set to true when the event procedure receives a message to terminate the entire program. The event loop simply checks each time if running is true, and exits the loop, and the entire program when it is not. Why does the event procedure call a default event procedure. The window objects works entirely by responding to messages. The program can respond to messages that it cares about and modify the window accordingly, it can just ignore the ones it does not need. However there are a large number of messages and some of them will cause the window to not work properly if they are ignored. The default window procedure is there to make sure that everything works properly why allowing a program to just ignore anything it does not need. How can I simplify all this useless code. Creating a window, like most things in coding, can be encapsulated. There are too many details to put it all inside one function, but we can put it inside a class. The parts that are required for the class are the application Instance, and the window procedure. The application Instance is obtained from the first parameter of the win-main procedure, the window procedure is created for each application. Why can't we just encapsulate the window procedure along with everything else. The window procedure is a function that is defined entirely by the operating system, and can only be called by the operating system. There is no simple way to tell it what window class it should be working on. There is a difference between our window class and the window object created by the operating system. While it is possible to make the window object point to our custom class, this is not an elegant solution. On top of all that, the window procedure takes care of things that are unique to each application, so it would not make sense to make a generic one for each class. Is there a point where a generic window procedure would be useful. Yes, there are window classes, like those that require scrolling ability, that need to respond to very specific messages. It would not make sense to have each application know about what those messages are and call the class to deal with them. This is a case where having a class would not make everything simpler.There are some big problems that I will have to solve tin the future if I am going to make this work properly, but this is enough just to get started.

Monday, December 14, 2015

I am really out of shape lately. I am starting an exercise program for the next little while. I am going to start slow to find out what I can do and gradually increase my limit. For today it is just running up and down the thirteen steps in my house for five. Later we will gradually increase as I get better.

1. Monday December Fourteen. Time : Five Minutes. Repetitions : Twenty One.
2. Tuesday December Fifteen. Time : Five Minutes. Repetitions : Twenty One.
3. Wednesday December Sixteen. Time : Ten Minutes. Repetitions : Thirty Seven.
4. Thursday December Seventeen. Time : Fifteen Minutes. Repetitions : Fifty Five.
5. Friday December Eighteen. Time : Fifteen Minutes. Repetitions : Fifty Five.
6. Saturday December Nineteen. Time : Fifteen Minutes. Repetitions : Fifty Eight.
7. Sunday December Twenty. Time : Fifteen Minutes. Repetitions : Fifty.
8. Monday December Twenty One. Time :  Fifteen Minutes. Repetitions : Forty One.
9. Tuesday December Twenty Two. Time : Fifteen Minutes. Repetitions : Forty Eight.
10. Wednesday December Twenty Three. Time : Fifteen Minutes. Repetitions : Forty Seven.
11. Thursday December Twenty Four. Time : Fifteen Minutes. Repetitions : Fifty Four.
12. Friday December Twenty Five. Time : Fifteen Minutes. Repetitions : Forty Eight.
13. Saturday December Twenty Six. Time : Fifteen Minutes. Repetitions : Forty Nine.
14. Sunday December Twenty Seven. Time : Fifteen Minutes. Repetitions : Fifty One.
15. Monday December Twenty Eight. Time : Fifteen Minutes. Repetitions : Forty.
16. Tuesday December Twenty Nine. Time : Fifteen Minutes. Repetitions : Fifty Three.
17. Wednesday December Thirty. Time : Fifteen Minutes. Repetitions : Fifty Five.
18. Thursday December Thirty One. Time : Fifteen Minutes. Repetitions : Fifty One.
19. Friday January First. Time : Fifteen Minutes. Repetitions : Forty One.
20. Saturday January Second. Time : Thirty Minutes. Repetitions : One Hundred and Two.

At this point, I have increased the time to thirty minutes and I do not feel anything like when I started. I don't think that I am really going to get any better from this point on. I am still sweating a lot and I feel out of breath while running, but I recover very quickly. At this point I feel like I am just wasting time. I need a way to improve my performance without taking more of my time. The solution that I am thinking of is weights. I have a set of adjustable dumbbells and I think that running with them on my shoulders will give be an extra kick. I am going to start with a low weight and gradually increase as I feel more up to it. I will still keep the time constant and record my score.

21. Sunday January Three. Time : Fifteen Minutes. Weight : Forty Pounds. Reps : Thirty Nine.
22. Monday January Four. Time : Five Minutes. Weight : Fifty Pounds. Reps : Thirteen.
23. Tuesday January Five. Time : Fifteen Minutes. Weight : Eighty Pounds. Reps : Twenty One.
24. Wednesday January Six. Time : Fifteen Minutes. Weight : Eighty Pounds. Reps : Twenty Eight.
25. Thursday January Seven. Time : Fifteen Minutes. Weight : Eighty Pounds. Reps : Twenty Four.
26. Friday January Eight. Time : Five Minutes. Weight : Eighty Pounds. Reps : Eleven.
27. Saturday January Nine. Time : Fifteen Minutes. Weight : Eighty Pounds. Reps : Twenty Seven.
28. Sunday January Ten. Time : Fifteen Minutes.  Weight : Eighty Pounds. Reps : Twenty Four.
29. Monday January Eleven. Time : Fifteen Minutes. Weight : Eighty Pounds. Reps : Twenty Four.
30. Tuesday January Twelve. Time : Fifteen Minutes. Weight : Eighty Pounds. Reps : Twenty.
31. Wednesday January Thirteen. Time : Five Minutes. Weight : Eighty Pounds. Reps : Ten.
32. Thursday January Fourteen. Time : Five Minutes. Weight : Eighty Pounds. Reps : Twelve.
33. Friday January Fifteen. Time : Five Minutes. Weight : Eighty Pounds. Reps : Fourteen.
34. Saturday January Sixteen. Time : Fifteen Minutes. Weight : Eighty Pounds. Reps : Twenty Six.
35. Sunday January Seventeen. Time: Fifteen Minutes. Weight : Eighty Pounds. Reps : Twenty Seven.
36. Monday January Eighteen. Time : Fifteen Minutes. Weight : Eighty Pounds. Reps : Twenty Two.
37. Tuesday January Nineteen. Time : Five Minutes. Weight : Eighty Pounds. Reps : Thirteen.
38. Wednesday January Twenty. Time Fifteen Minutes. Weight : Eighty Pounds. Reps : Thirty One.
39. Thursday January Twenty One. ///SKIPPED///
40. Friday January Twenty Two. Time Fifteen Minutes. Weight : Eighty Pounds. Reps : Twenty Seven.
41. Saturday January Twenty Three. Time Fifteen Minutes. Weight : Eighty Pounds. Reps : Twenty Seven.
42. Sunday January Twenty Four. Time Five Minutes. Weight : Eighty Pounds. Reps : Ten.

Wednesday, December 9, 2015

In the past month I made a point to read one full book a day for thirty days. I got there, mostly, but the problem is that I dd not learn as much as I wanted. I don't have that good a memory and most of those books were not that deep. Also I was spending four to eight hours a day reading right after coming from a full day at work. Also most of the time I was doing this reading well after midnight and almost falling asleep. This was not the best way to do things, but it was also not the point. The real point of this exercise was to jump start my self into a new set of habits. My current life plans for the future require that I completely change the way I look at myself and the world. I could have made a point to read a book a week or follow some kind of long term plan that would eventually get me somewhere in a year if I managed to stay with it, but there is no way that was going to happen. My view of how things are done as well as my habits from a month ago would have pushed me along for a few day of a week, but eventually I would have found some excuse to stop and move on to some other thing. The only way I was ever going to move past that was to do something stupid like read a lot of books in a short time and hope that one or more of those books would change my world view into something that could sustain a more healthy habit structure, and I think this is what happened. Every night so far my first thought has been to sit down and read something. I will not do this every night but I am doing other related things that involve absorbing new information. I cannot remember most of the facts that I read but I do remember the general idea. For the next little while, I will work on expanding on that.