Passing Data in OO languages
You need to have context to do certain operations. Like a logging class would need an open file
handle to the log file.
1) Use a public void set(X newx) method and internally use a private X x member variable.
2) Use the ctor(X newx) and internally use a private X x member variable.
3) Require subclassing and internally use a protected abstract X get() method.
4) For each function that requires it, pass it in. public void doSomething(X x);
5) Use a global.
handle to the log file.
1) Use a public void set(X newx) method and internally use a private X x member variable.
2) Use the ctor(X newx) and internally use a private X x member variable.
3) Require subclassing and internally use a protected abstract X get() method.
4) For each function that requires it, pass it in. public void doSomething(X x);
5) Use a global.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home