Don't get this chapter


#1

I was happily with you prior to this chapter and was feeling very confident about objective c. Now on reading this chapter I am totally lost as to what this chapter means! I get the fact that instance variables are pointers can be pointers to other objects. But on reading the rest of the chapter I am totally confused:

  1. Firstly what is an unsigned int?
    2)Plus what are you trying to say with regards to “adding a to-many relationship to employee”? :frowning:
  2. What is the best approach in tackling this chapter and challenge.

Regards from a very despondent reader! :frowning:


#2

[quote=“amidabrian”]I was happily with you prior to this chapter and was feeling very confident about objective c. Now on reading this chapter I am totally lost as to what this chapter means! I get the fact that instance variables are pointers can be pointers to other objects. But on reading the rest of the chapter I am totally confused:

  1. Firstly what is an unsigned int?
    2)Plus what are you trying to say with regards to “adding a to-many relationship to employee”? :frowning:
  2. What is the best approach in tackling this chapter and challenge.

Regards from a very despondent reader! :frowning:[/quote]

Don’t get down! You can power through it too like I did…

  1. Remember back to the numbers chapter. An unsigned int is simply an integer number that can only be positive. A signed int has a + or - in front of it.
  2. In this chapter Aaron has us add an array (many) to an employee object (one). So the “to-many” relationship simply means that an employee object owns all the many objects in the array of assets.
  3. I really liked the challenge in this chapter as it illustrates a lot that is good about object oriented programming. Note that you can simply use your StockHolding class from the earlier chapters by adding its files into your project. Take a look at the solutions in the forum here if you get stuck.

Keep at it!


#3

This is definitely difficult material if you don’t have a background in C programming. Don’t give up the fight.

Answers to your first two questions; I’ll leave the third for the moment because it’s much broader.

Unsigned int(eger)s are whole-number values which cannot be negative.

So: 0, 1, 2, 3, etc.

They are represented differently inside the computer than integers which can be negative. An int is always signed unless you add the unsigned keyword.

A “to-many relationship” indicates a relationship from one object to 0 or more other objects. Specifically, an employee may have any number of assets.

Typically you’ll see references in software and database design to “one to many”, “one to one”, “many to one”, or “many to many” relationships. An employee conceptually has a “one to one” relationship with an employee ID, for example, although typically you don’t describe it that way because the employee ID does not reside in a different object.

Examples of the different types of relationships:

  • One to one: US citizen to social security number
  • One to many: manager to underling
  • Many to one: Vehicles to manufacturer
  • Many to many: children to parents (a parent may have multiple children, and a child hopefully has multiple parents)

Don’t get confused between many to one and many to many: yes, there are many cars and many manufacturers, but each car is made by only one manufacturer.

And zero counts as “many”, typically: a manager may not actually have anyone reporting to him/her, but still be a manager.

I think it’s safe to say that some vehicles are designed by multiple manufacturers but still built by just one, but that just illustrates my next point: it’s sometimes dangerous (but usually necessary) to make assumptions about the nature of these relationships. Data errors and software bugs can often be traced back to simplifying assumptions that prove to be incorrect. People do, in fact, have multiple social security numbers on very rare occasion.

(Edit: multiple SSNs are not so rare, apparently, but not legal either.)


#4

Thanks for the reply from macintux and macshome. It is really encouraging that the support is out there. I will plough on and I am sure the penny will drop! :slight_smile: As you may have realised I do not have a programming background and I am learning this between work and family life. So I already have a steep hill to climb ; but I keep at it as I really enjoy those moments when things seem to come together. So it is that moment I am looking forward to! :wink:


#5

I kind of get the principle of this chapter but I have pretty much given up on the challenge !!! I tried to get macshome solution to work but with no success. I hope this is not a sign of things to come!!! Will plough on to the next chapter and see how this works out. :frowning:


#6

Hmm… I wonder why my code wouldn’t compile for you.

As long as you have the understanding under control on this chapter I would move on and not get frustrated. I’ve made that mistake in the past and lost interest in other books.

In general my approach to this book has been.

  1. Read the chapter. No coding.
  2. Read the chapter again. Do the code this time.
  3. If I feel shaky on any topics I come here and then mess around with code until I feel confident.

#7

Have read the chapter again and it is slowly sinking in. I am not going to give up on this as I have come too far. Will take your advice on how to approach the subject.


#8

I’m having the same issue right now. I think I get what it’s about, but it’s already late (11.30pm).
I also have a full time job and a family and try to squeeze some hobbies in between all that and no real coding background either except of a little MSAccess and LabView. And really, this is just one of the hobbies I have. But still, I find it challenging (compared to my everyday work which grew a little boring over the last 10 years).
I also try not to give up, but for now, I’ll leave the challenge for another night.

This is how I tackled some of the other challenges before:

  1. Read a chapter. 2. Get coding (without understanding too much). 3. Reread the chapter if still in doubt that I understood what’s been written. 4. Tackle the challenge going back and forth within the book to the appropriate parts to see the basics of what you need for the challenge :smiley:

#9

My learning tip…

I like to print out the programs and make my own notes on how they tie in together…

Even if I have to use the book, it helps me grasp it… I can lay the pages in a square and draw arrows going from page to page…

Try it & good luck!


#10

The problem - the Object Instance Variable lesson was lost on overriding dealloc to show how ownership is given up. Given that Aaron states it is “far more common for instance variables to be pointers to other objects” we should have focused on that with a bit more explanation of why we are doing something. I’ve loved the ease of readability on previous sections, this one should get a rewrite on the next version.

Also, solution seems overkill, you can find the value of the portfolio like this.

create a float and have it equal 0, then put it inside your array loop.

totalThem = [s valueInDollars] + totalThem;

then print the value of totalThem. This seems more real world to me.

I’ve learned a lot with this book, but found this chapter to be extremely frustrating. Given Aaron’s talent to explain, I wonder what happened with this chapter.


#11

I’m glad I’m not alone… I’m a VB programmer trying to get my head around Objective C and like many others, was doing well till I hit this chapter. I like the idea of printing out the code, I think I’ll give that a try… I’m a visual learner. It would be great if someone wrote a book like this with and accompanying video tutorial on YouTube or the like.