Problem Solvers

Since the Dawn of Time

For as long as anyone can remember, humans have been trying to solve problems. And solving problems in a repeatable way forms the foundation of the development, transmission, and preservation of human knowledge.

Whoa. That's a lot to live up to as a humble programmer.

But what is a programmer? For the purposes of this course, we provide the following definition:

A computer programmer solves human problems by creating software.

Human Civilization Keeps Advancing

As human civilization has become more complex, the problems we need to solve have increased in scale and complexity. But regardless of the scope and complexity of any problem, there are some fundamental steps we can perform to secure our understanding of the problem while laying the foundation to create the simplest and most reliable solution we can possible create.

Remember: iteratively remove unnecessary complexity. (Keep removing "features" and "logic" that get in the way of expressing your problem and its solution.)

Simple Steps to Solve a Problem

  1. Clearly identify the problem you are trying to solve. Commonly, "use cases" or "features" are described in this format: "As a ____, I want to ____ so that ____."
  2. Imagine the types of objects you'll need to build your system.
  3. Imagine the information or data you would want each object to possess (privately or it can share).
  4. Imagine how those objects are going to perform actions. For example, my Cup object might have a .pour() method/action/verb it can perform.
  5. Imagine how these objects will interact with each other.
  6. Imagine how data will flow through this system like an assembly line, or like a telephone switch, or like a railroad, or like an inventory system, or a catalog, or a ledger, or a spreadsheet, or a web browser, or virtually any THING else you can imagine.
  7. Repeat Steps #2-6 until you have sufficiently described your system in only as much detail as is actually needed.
  8. Keep building and testing your assumptions until you have a working system.
  9. Fill up on comfort food and your favorite beverages until the next assignment comes in from HQ.

This is a bit abstract, but we will jump into a tiny, real world example.

Pro Tip: the whole process, from Step 1 through Step 7, looks like a recipe. Another name for this recipe is: algorithm. Programmers use algorithms to implement solutions in a repeatable and predictable way. This makes our code highly testable.

Classes and Instances

Before we get too far ahead of ourselves, we should give a brief overview of type systems - from most abstract to most concrete. Confused about abstract and concrete? The more abstract something is, the more... generic it is. Like off-brand cereal at the bottom of the isle. The more concrete a type is, the more specific it is. Like off-brand cereal at the bottom of the isle designed to compete with Cocoa Puffs™.

Cereal Class Hierarchy

  • Cereal
  • --> Generic Cereal
  • -----> Cocoa Puffs™ competitor
  • -----> Corn Flakes™ competitor
  • --> On Brand Cereal
  • -----> Cocoa Puffs™
  • -----> Corn Flakes™

Putting it All Together

If I'm holding in my hand a box of Corn Flakes™, then I can make the following statement:

This individual box of Corn Flakes™ is a specific instance of the Type of On Brand Cereal called Corn Flakes™. "On Brand" is an umbrella with many brands beneath it. In the most general sense, my individual object - my box of Corn Flakes™ - for all of its apparent magic is simply Cereal. And I'm hungry.

Hungry indeed. Let's chew on that for a while.

Here's a simple real-world example of creating an object in our system, from concept to code:

When designing our great new web service, we quickly discover the need to create and store records related to Users.

What's a User? What types of information are relevant to our needs when programming Users in our system?

Let's store the following information about each individual user on our website:

  • Name
  • Email Address
  • User Name
  • Encrypted Password
  • Created and Modified Timestamps

Download
Complete and Continue  
Discussion

0 comments