Archive for December, 2009

20
Dec
09

Evaluating Object Oriented Designs

When you’re trying to come up with a software architecture, you’re typically trying to define an ontology of objects. What do objects give us? Code reuse. Therefore any software architecture you create must take into consideration the future changes that are likely to occur. It’s difficult to foresee what problems will come up, which is where experience helps a lot. But when writing the actual code you must always ask yourself “If I write the code this way, will I be able to reuse this code without touching its internals?”

I’ve seen people pay lip service to architectures such as MVC but it’s quite clear when reading the code that they don’t understand that all MVC is really trying to do is allow you to separate the presentation and control logic from the actual data.

Another important aspect of this question is having single source data. For example, in a database you wouldn’t usually want to store a value in two different places where there’s a constraint that the two values must be the same, because if you change one, there’s a potential for a programmer to make a mistake and not change the other.

20
Dec
09

Software Development Scheduling

Scheduling relieves stress. However it is difficult to do accurately predict how much time tasks will take. They must be decomposed and thought about before the actual amount of work can be determined.

Some helpful tips:

  1. Decompose tasks into sufficiently small tasks such that you can determine the length of each task
  2. Give yourself extra time for mistakes and unforeseen costs, I’d say somewhere between 25-50% of what you’ve already allocated.
  3. Give yourself time to learn and evaluate the best way to do something. This is the intellectual of task of examining other people’s work and thinking about interface design, software use cases and requirements, and software architecture as well as various technologies. This depends on how well you know the technologies you’re working with, but it always seems there are things you don’t know about that could help you write better programs. Exploration is key here.
  4. Communication about the software itself is a large cost that is mostly fixed.
20
Dec
09

What Makes a Good Programming Language

1) A good module/namespace/package system. Polluting a global namespace is a terrible idea. Sometimes you’ll see a function in code and have no context for where it’s coming from and it could very likely be ambiguous in a language like php.

2) Static Typing is a required feature despite the increased verbosity because it makes functions well-defined. They take very specific inputs and produce very specific outputs. Without this restriction you must rely on the programmer to not make the mistake of returning different types. For example, in Elgg core which is written in php, a function that fetches objects will either return an array of objects or… false. If you write code that uses this function it’s retarded to write a special case check for “false” instead of iterating over an empty array.

3) Regular expressions and strings library – doing this stuff by hand is a pain in the ass and has been done a million times. Every language should make this extremely easy to do and special case it so its not ridiculously verbose to do as well. (ahem, Java).

4) First class/anonymous functions – this allows for some particularly simple code. e.g. map(func(x){},array()) turns multiline code into one line. It also allows for concurrency, i.e. concurrent_map(heavy_function, big_array);

5) Large, well written library – why rewrite the wheel?

6) Community/Open Source – learn how to write this language well by reading others code.

…and more to come

19
Dec
09

The Algorithm For Getting Better at Anything

Step 1: Attempt to do what it is you want to learn – you will either succeed or fail

Step 2: Analyze why you succeeded or failed

Step 3: Take data from step 2 and modify your behavior when you repeat Step 1 to improve performance.

18
Dec
09

Stress and eating

I think when people are under stress they look for sources of comfort. They play video games, or they eat, or do anything that produces comfort. Sometimes these activities are destructive. For example, comfort eating makes your health worse. Some people advocate exercising or eating well as remedies for stress, but this is difficult to do since stress causes you to stop doing these things. This is attempting to fix the symptoms and not the source of the problem. The fundamental problem is that something in your life is producing stress. From my own self-observations, I get stressed when I don’t work on things that I need to get done. Working hard is not stressful, but not working hard on something that you care about is. Some of the reasons that people don’t work hard on something they care about is maybe they think it’s too hard, or an overwhelming amount of work. This means the best way to reduce stress is first to identify what you care about that must be done. Then you must solve this problem. If the problem is extremely difficult or forbidding, then you must use techniques to break down the problem. I hypothesize that stress is a subconscious belief of the mind that you may be unable to cope with something going on in your life. For example, if you’re house is being taken away from you and you cannot do anything about it, that is an extremely stressful situation since there are no actions you can take to solve this problem. Whereas watching a series of videos to get rid of a parking ticket has a predefined simple path that makes it easy to solve and is therefore not stressful.

Let’s work out an example. Suppose I have to produce some software project within a month. First of all, a month’s worth of work looked at as one whole is a large and forbidding problem. We may never start. The first thing to do is to break this problem down into smaller doable parts. For example, you may mock up a prototype at first, figure out the typical use cases, figure out the software architecture, then write portions of the code. Breaking a hard problem down into easier problems dissipates the belief that the problem is too hard. The other aspect of this problem is, do you have enough time to complete the project? Since you’ve already broken this task down into pieces, you can now attempt to schedule them and see if you’ve enough estimated time to complete them. One thing about this is you should allocate extra time for unforeseen circumstances and this should typically be quite a lot. So for our monthlong example, we would want to complete most of our work by the second or third week and leave ourselves plenty of extra time to complete the work should unforeseen circumstances arise. You may notice that you’ll have to work weekends in order to reach that deadline, and have to work long hours. However, you’ve relieved all the WORRIES that you had about being able to cope with this problem. You know that you can cope the problem with these actions and have turned something that causes stress into a simple solved problem.

Some benefits of this approach is that if you complete the tasks assigned for a particular day, then you’re home free for the rest of the day and can partake in other things in your life. In fact, you are self-incentivizing to finish your work as quickly as possible rather than spread the work out over the course of the whole day. This makes you more time-efficient since you know if you complete your work you can relax and do something fun.

Another tip is to sequence and decompose the tasks for a day such that the easiest things are first and most of the tasks are not too difficult. Sometimes a difficult problem causes people to put off work because they’re worried about it, but if the problems are easy then the cognitive obstacles one must clear in order to start working are much less. Once you start working, then all the obstacles are much less since you are already “in the zone.”

The essence of relieving stress is proving to yourself that you can cope with the problems that come up in life.

The other facet of stress is that some of our beliefs may be preventing ourselves from relieving stress. Suppose you have the belief that you need to be with a certain person in order to be happy. You cannot control what the other person chooses to do, and thus your belief puts you in a position where you are potentially helpless. Putting yourself in that situation is very stressful, but ultimately it is ONLY A PRODUCT OF YOUR BELIEFS. This is when you must reexamine your beliefs and realign them with what is more realistic and healthy. For example, you should believe that there are many people with which you can be with to be happy, and that if you work at it you can find happiness by finding one of these people.

17
Dec
09

Exploring the relationship between teaching and entertaining

Most lectures and textbooks are fairly boring. Why is this? How can we make material more engaging. I think education should look towards entertainment industries for answers. Most material is fairly boring because of the fact lecturers are typically talking about things they understand well and hence have no frame of reference of what the beginner feels. The speaker doesn’t understand his or her audience.

Ira Glass has a youtube series on storytelling that is intriguing (http://www.youtube.com/watch?v=n7KQ4vkiNUk&feature=related). One of the important things he discusses is that good stories provide implicit questions and a sequence of actions. It could be that the human mind has evolved with storytelling as a communication mechanism is central. This means that teaching methods that are closer to stories, which have sequential actions rather than random access discussion, and also creating questions in the audience’s head is a fundamentally better way to communicate material.

I think one good example of this method is The Goal, an operations book which is written as a story. It was easy to digest and was able to get to the heart of the matter, entertaining and fun at the same time.




 

December 2009
M T W T F S S
« Nov   Feb »
 123456
78910111213
14151617181920
21222324252627
28293031