Main Content
The spirit of Java - delegating to classes Archive - Originally posted on "The Horse's Mouth" - 2015-02-18 17:00:01 - Graham Ellis
Building up towards the end of a Java course, I've been very much teaching the spirit of Java where code is delegated to classes and leaves the main application as a few short method calls, making it readable in its own right, and allowing code that uses the same data type to be shared between programs. Here's my main program:
import java.util.*;
public class Framework {
public static void main (String [] args) {
MyStream StationSource = new MyStream("rstats2014.xyz");
HashMap NationalRail = Station.factory(StationSource);
System.out.println(NationalRail.get("LAS"));
ArrayList Codes = MyUtils.sortedList(NationalRail);
MyUtils.print(NationalRail,Codes);
}
}
Complete code for this (and the three classes used) [here] and an earlier stage [here] .
Some other articles
Q907 - Object Orientation: Design Techniques Associative objects - one object within another. Spike solution, refactoring into encapsulated object methods - good design practise This article Test driven development, and class design, from first principles (using C++) Using object orientation for non-physical objects Teaching OO - how to avoid lots of window switching early on Storing your intermediate data - what format should you you choose? Inheritance, Composition and Associated objects - when to use which - Python example From Structured to Object Oriented Programming. Rooms ready for guests - each time, every time, thanks to good system design When you should use Object Orientation even in a short program - Python example Spike solutions and refactoring - a Python example Why you should use objects even for short data manipulation programs in Ruby Designing your application - using UML techniques Your PHP website - how to factor and refactor to reduce growing pains Ruby - a training example that puts many language elements together to demonstrate the whole Object Oriented Programming for Structured Programmers - conversion training Comments in and on Perl - a case for extreme OO programming What is a factory method and why use one? - Example in Ruby Turning an exercise into the real thing with extreme programming Should Python classes each be in their own file? Program for reliability and efficiency - do not duplicate, but rather share and re-use Relationships between Java classes - inheritance, packaging and others The Light bulb moment when people see how Object Orientation works in real use Containment, Associative Objects, Inheritance, packages and modules What is a factory? The Multiple Inheritance Conundrum, interfaces and mixins Plan your application before you start Simples Object Oriented programming - a practical design example Planning! Designing a heirarcy of classes - getting inheritance right When should I use OO techniques? Teaching Object Oriented Java with Students and Ice Cream Object Oriented Tcl Object Oriented Programming in Perl - Course Object Relation Mapping (ORM) What are factory and singleton classes? Maintainable code - some positive advice Build on what you already have with OO Comparison of Object Oriented Philosophy - Python, Java, C++, Perl The Fag Packet Design Methodology Think about your design even if you don't use full UML Design - one name, one action Introduction to Object Oriented Programming Tapping in on resources OO - real benefits J715 - Putting the Java Language Together This article Learning to program - comments, documentation and test code Type checking, Java arrays and collections Good Programming practise - where to initialise variables Build on what you already have with OO J050 - Java - General This article Java -making sure you have the right versions Java - an update of the basics Learning to program in Java - yes, we can help. New in Java 7 - and why we are not running public Java 7 courses MySQL and Java - connectivity past, present, and future thoughts Learning to program in ... Exceptions in Java - why and how Java Programming Fundamentals Which Version of Java am I running? C, C++ and C# ... Java and JavaScript Comparing Java Courses - what can we do?