ThoughtForTheDay
|
|
Your trail: |
In a effort to reduce XP to Radio 4 programmes, OliBye has started a 5 minute thought for the day following our StandUpMeeting? at http://www.wdsglobal.com
- DontDoubleDereference?
-
- It breaks encapsulation. Making it hard to change the implementation of the "middle" object as you've build knowledge into the left object.
- I'm hoping this might lead onto tomorrow's PassSomethingIn
- PassSomethingIn
-
- The LawOfDemeter tells us that we should not break encapsulation by making calls against things returned to us by calls we make on objects we have references to. (see DontDoubleDereference?).
- Calling methods on the results of Getters and Setters are a prime example of this.
- However this can make it hard to write programs that do anything!
- Until you realise there is another way. It's a little counter intuative, but you'll see the benefits early, so stick with it.
-
- Instead of using getters you could pass a memento in, and have the receiver set state in the memento.
- an other example would be Java Exceptions writing themselves out on a PrintWriter?
- Note that OliBye would try to balance "PassSomethingIn" against the power of DoubleDispatch?.
- DoubleDispatch?
-
- new StringBuffer?().append("hello").append(" ").append("world");
- get the receiver to choose the implementation of the next call.
- return this; // or something that implements the same interface
-
- OliBye is enjoying how today's ThoughtForTheDay seems to generate tomorrow's ThoughtForTheDay
- PassByReference? (C++)
-
- But beware of reference member variables going out of scope in the caller.
- C++ Resource management.
-
- Allocate resources in constructors, and de-allocate in destructors. Seems obvious.
- Then use thes objects as automatics within a scope, so that throwing exceptions (for example) automatically frees the resources.
- Java 1.4's assert, does it really help with design by contract?
- Arrays are bad in Java
-
- if AT extends T, BT extends T
- T = new AT; // is legal
- T = new BT(); // is legal at compile time, and returns a runtime error.
- Encourages knowledge of the length of the collection.
- Multidimensional arrays, expose structural implementation.
- Arrays are however useful for SOAP compatability between Java and .NET
What are we really testing?
Edit this page More info... Attach file...
|
This page last changed on 02-Jul-2003 15:22:20 BST by unknown. |
|