Hi TGK,
This is great! Thanks for posting a helpful resource. You may also
want to post it on CappuccinoFlow.com. A few things I noticed briefly
going through the articles:
We generally wrap the main body of -init methods in if (self):
- (id)init
{
self = [super init];
if (self)
x = y = z = 0.0;
return self;
}
More importantly though, you never really need to initialize a
variable to an empty value, like 0.0. Also in ObjC/J, we like to use
more descriptive variable names, so instead of var p = ... try var
point = ... The section about globals vs. var scoping is right on, but
you may also want to mention that ivars do not use var and are local
to the object.
I'd question whether you'd even want to include the section about
accessing the JS objects directly through dot syntax. While it's
possible, it is entirely beyond bad form; you're actually using an
entirely different programming language. I think it would be better to
just go write into accessors. Just a stylistic thing, we don't like a
space after a colon. - (id)initWithX:(float)newX Y:(float)newY Z:
(float)newZ. Also instead of a -string method on the class, if you
just overwrite -(CPString)description, whenever you CPLog/print (so
print(thePoint)) the object it will output the string you return.
Finally, when you're talking about @accessors, you may also want to
talk about the options you can pass, like property= and readonly.
A few things about the -add: method. You should use setters, [self
setX:x + [otherPoint x]]; This allows things like KVO to work
properly. I know that our public API's will almost never return self
for chaining (though sometimes I wish they did), but I suppose that's
a personal thing.
Other then those issues, it looks great. Thanks again for contributing
this.
--Nick
On Nov 9, 8:24 am, TGK <
thomas.kra...@gmail.com> wrote:
> As a Cappuccino newcomer I’ve been having a good time playing around
> with it. As I get up to speed I’ve been putting my “notes” online as
> a collection of articles/tutorials. They may be of help to others
> getting started with Cappuccino. You can check them out at
>
>
http://cappnotes.worldofkrauss.com/
>
> As an aside (and a shameless plug), I’m looking to “upgrade” my
> airfoil database site (
http://airfoils.worldofkrauss.com/). The
> current site uses Ruby on Rails and I’ve made a rather extensive
> rework using the Erlang-based Nitrogen framework (http://
>
nitrogenproject.com/) which you can see athttp://
airfoils.worldofkrauss.com:8888/.