Posts

Showing posts with the label MAC

Cocoa, falling at the first hurdle?

I was REALLY looking forward to programming some apps on the Mac using Cocoa and objective-C. I am reading "Cocoa programming for MAC OS X" by Aaron Hillegas. I had read as far as page 30 when I saw the following: "Objective-C is a very simple language. It has no visibility specifiers: All methods are public; and all instance variables are protected. (Actually, there are instance specifiers for instance variables, but they are rarely used. The default is protected, and that works nicely.)" WHAT? Works nicely? I disagree! It is actually possible to make a class's method private by not including it in the interface declaration (myclass.h) and just adding the implementation file instead, but what about protected methods? public I expose as little as needed to ensure the class provides the service it was designed to. The signatures/names of members in my public area change as little as possible so as not to break other people's code. Public members are

Enough rails for me

That's it, I've had enough of Ruby on Rails! I like the rails part, it's a very clever approach, but I really dislike the Ruby part! The final straw occurred yesterday. It's very common in OOP to have the constructor set default values for your object just in case the consumer of your class does not set them. In C# I would do something like this..... public class Post : MyBaseClass { private bool isPost = true; } In Ruby I was trying to achieve this simple behaviour... 01: IsPost is set to true 02: A form is displayed with the default value 03: User changes the value 04: My Post instance is updated with the values from the form I tried to override Initialize() only. def Initialize super is_post = true end Now Post.new(params[:post]) is not reachable for some reason. So in my Post class I did this def Initialize(* params) super(params) is_post = true end The problem here is when I try to initialize the values from the form in my controller class. post = Pos