- Learning to Program—The stages of programming
- Learning to Program – Some Terms You Should Understand
- Learning to Program – IPO Charts (Stage 1)
- Learn to Program- Flowcharting (Stage 2)
- Learning to Program – Flowcharting (Stage 2). — Decisions and Loops
- Learning to Program—Flowcharting (Stage 2) – Case Statements
- Learning to Program (Stage 2)—Flowcharting – Methods and Classes
- Learning to Program – Structure and Spaghetti Code
- Learning to Program – Pseudocode (Stage 3) an overview
- Learning to Program – Stage 3 Pseudocode commands and reserved words
- Learning to Program—Stage 3 Pseudocode examples Part 1
- Learning to Program – Stage 3 Psuedocode (Arrays)
- Learning to Program – Stage 3: Pseudocode—Methods
- Learning To Program—Stage 3.5 (UML Diagrams)
- Learning to Program – (Stage 4) Coding
- Learning To Program—Stage 5 Testing
- Learning to Program—Stage 6 (Documentation)
- Learning to Program – Stage 7 (Maintenance)
- Learning to Program—Random Thoughts with a Theme
- Learning to Program- Two Main Types of Errors
- Learning to Program – Integrated Development Environments (IDE’s)
- Learning to Program
In my Java course, we began working with UML Diagrams. UML is an acronym for Unified Markup Language. The easiest way to explain this is, it is a blend of objects, classes, pseudocode and flowcharts—all wrapped up into one. I’m not sure whether other languages support these diagrams, but I would imagine that you can still use them.
First a little explanation. Objects are similar to objects in real life. They have attributes (variables) like real-life objects, and they have actions that you can do with them (operations or methods) like real-life objects. Classes are objects.
Here’s an example. A ball is an object. It has attributes: size, shape, color, texture, contents (air, water, foam, etc), and graphics. You have operations that can be done with a ball: throw, catch, hold, bounce, inflate, and deflate.
A class is like the ball. It has attributes (the variables that make the class function), and operations (the methods inside which allow you to access and use the variables).
There are two main types of classes. Superclass and subclass. A superclass is a container for all of the common elements in it’s subclasses. And a subclass is the individual elements for it’s specific need.
The example of this that we’re using in Java is a ticket system. The superclass is the Tickets class, and the subclasses are how the tickets are delivered (will-call, e-delivery, or mailed to you (Printed)). The common elements among all of the subclasses are “event name, location, date, time, cost and number of tickets.” The individual elements are “e-mail address” (e-delivery), “booth location” (will-call), and “mailing address” (Printed).
Then you get into inheritance. Inheritance means that the subclass “inherits” or uses the common elements from the superclass—along with it’s individual elements (without having to create a new instance of the superclass). In UML Diagrams, inheritance is shown by an arrow connecting the subclass to the superclass, with the direction going towards the superclass.
The reason that I’m bringing this up, without going in depth about it is this: In Java, at least, if you create a UML diagram, you’re able to generate code from it automatically. What this will do is, it will create all of the variables for you, and create the names of the operations. You will still have to code the operations themselves, and tweak them a little to make them work. But, the UML will at least create the backbone for you. And it will simplify the inheritance issues for you (by automatically adding the extends superclass to the subclasses).
If you’re coding in Java, and wish to learn how to use the UML diagrams, there is a tutorial at http://netbeans.org/kb/docs/uml/class-diagram.html. Beware it’s intended for Netbeans 6.5 and has not been updated to Netbeans 6.7 or later. And in Netbeans 6.8, you have to use a third-party plugin to do UML diagrams. So, there are variations in how they say to do something, and how you’ll do it (minor things like left-clicking instead of right-clicking and Create … instead of Insert…). Also note that when you generate the code, you have to click outside of the Netbeans window and back for it to show up in your target project.
One last thing to note about UML diagrams (in Netbeans at least). If you have code already, you can reverse-engineer it into it’s UML Diagrams using the plugin.
Now, I’ve finally covered all of the ways to get to coding. Tomorrow, we’ll start talking in general about the actual coding. At the bottom of this post, I will include a picture of the UML Diagram from the tutorial.
Have a great day:)