View this PageEdit this PageUploads to this PageVersions of this PageHomeRecent ChangesSearchHelp Guide

MP4 Discussion

Q: Elkin Florez - 12 June 2007 - Thank you Nicolas. I am receiving th following error:
UndefinedObject(Objec)>>doesNotUnderstand: #organization. Following with the debuger the problem is while doing "MilitaryRank organization allMethodSelectors" in r=testImpementedEqual and something similar happens in testImplementedLess

What I understand fo this error is that the MilitaryRank cannot be found by the compiler or something like that. However, when I try that line in the workspace it prints what it should. I have only defined # and #= So far I have not found the problem.

Something very extrange is happening. If I comment all the code of the test case out, run the test and then uncomment the code back and run the test, it works. I did try this same procedure in the other test and also worked.. It looks like the compiler is not compiling the code or some how it is deffering the compilation. I also tried changing the test case, saving and restored and the test failed again...humm... Anyway, now it is passing the 14 test cases. Did someone else have this extrange behavior ?

A: Nicholas Chen - June 12, 2007 - This is indeed very strange. Did you crash your image before?

One thing that you can check is if there are any open debug windows or another instance of Sunit running. Some of the debug windows might be hidden behind other windows. Close all of them.

Can you try running the older tests from previous homework assignments? I want to see if this problem is isolated to the MilitaryRank object. It appears from your description above that "ArmyRank organization" and "NavyRank organization" in the other test cases work fine.

If we cannot find the problem, I strongly suggest that you start using a new image of Squeak. You can fileOut the changes that you have made and then slowly import them one by one into the new image.

A: Elkin Florez - 14 June 2007 - To your question, Yes, I can run all the other tests and everything is working fine (apparently). I will stay with this image to see if I get the same issue and I can reproduce it. May be we find the reason for the behavior. Thank you Nicholas. I will tell you if the issue comes up again.

Q: Elkin Florez - 11 June 2007 - I have the same question regarding the organization method. My code is passing 12 of the 14 test cases. If I copy the line: "MilitaryRank organization allMethodSelectors" into a workspace and print the result. It shows what is expected. however it does not work in SUnit, Any clue?.

A: Nicholas Chen - June 11 2007 - Which tests are the ones that are failing? And what reason are they failing? Is it because they HAVE the messages #>, #=? Or is it failing for some other reason?

Q: James Shepherd - 11 June 2007 - The MP4 instructions say we should create class and instance methods so that you can say MilitaryRank named: 'private' and get the right kind of instance. You should also write methods to handle MilitaryRank private. The test cases use ArmyRank private and ArmyRank named:. Are we supposed to handle both MilitaryRank private and ArmyRank private?

A: Nicholas Chen - June 11 2007 - Are you asking whether you need to handle creating MilitaryRank private even if it is not tested in the unit tests? Even though the Sunit tests do not try to invoke MilitaryRank private, MilitaryRank general, etc you should have them.

When I did this I just used this array #( 'private' 'corporal' 'sergeant' 'second lieutenant' 'first lieutenant' 'captain' 'major' 'lieutenant colonel' 'colonel' 'general' ) to determine the ranks in the Military.


I realize now that this is a great source of confusion. Lines like "MilitaryRank private" and "Military named: 'private'" makes it appear that MilitaryRank is a concrete class. I was initially under that assumption as well.

However, after getting multiple questions on this, I think that MilitaryRank should be an abstract class. ArmyRank and NavyRank are concrete subclasses of MilitaryRank. If you did it this way, then MilitaryRank private should not be valid.

I will be accepting both implementations: MilitaryRank as a concrete class and MilitaryRank as an abstract class. Sorry for the confusion.



Q: Jeffrey Votteler - June 12 2007 - So if you coded it as MilitaryRank abstract and ArmyRank and NavyRank as concrete. Then is MilitaryRank named: 'Error: this should not happenError: this should not happenError: this should not happen' valid?. It isn't, right, because you can't create an abstract object. Or should it check the child classes and create the first instance of a valid rank or return an exception if no valid rank found?

A: Nicholas Chen - June 14, 2007 - Your formating came out a bit weird, If you want to display the asterisk then use & start ; (without the spaces). Also, please post all new questions on the top of the page or I might miss it.

You should not instantiate an abstract class. So you should not try to check your child classes for valid ranks.


Q: Des Iorgova - June 11 2006 - when I look at the testImplementedLess and testImplementedEqual, the MilitaryRank is undefined (highlighted in red) and as a result when I run these tests I get the following error: undefinedObject does not understand # organization. Do we need to define the "organization" method for MilitaryRank? I don't think we shoud. I am not sure how to debug this error because I have implemented the = and in MilitaryRank. Any suggestions?


A: Paul Adamczyk - June 12 2006 - The error message indicates that the MilitaryRank class is not defined (it's an "undefinedObject"), so the "organization" method can't be called on it. You need to define that class.


Q: Elaine Savino 11 Jun 2006- Per the message below about private, general, general, captain etc being subclass methods, I'm not convinced that this needs to be so. We can have better re-use for the cases that are in common between Navy and Army, such as 'captain', by putting the instance creation method in the parent class. Also, this is OK because the actual rank is determined by the ranks method which IS implemented in the respective subclasses.

A: Paul Adamczyk - June 12 2006 - You're correct. I don't think that any post below disagrees with your comment.


Q: Elaine Savino 11 Jun 2006- Should the return value of the lessthan method and the equals method be a boolean or an actual numerical value?

A: Paul Adamczyk - June 11 2006 - All comparison methods like this should always return boolean. It's one of the rules of Smalltalk.


Q: Manas Dadarkar - 11 Jun 2006 - What is the difference between ArmyRank and MilitaryRank? In testImplementedEqual/Less, there are references to MilitaryRank but all the other places there are references to ArmyRank.

A: Paul Adamczyk - June 11 2006 - MilitaryRank is the superclass of Army and Navy ranks.

Q: Nevedita Mallick - 11 Jun 2006 - Is it not good to make the method that returns the literal array #( 'private' 'corporal' 'sergeant' 'second lieutenant' 'first lieutenant' 'captain' 'major' 'lieutenant colonel' 'colonel' 'general'), a class method. That way, we we don't need to access it through an object?

A: Paul Adamczyk - June 11 2006 - You're right, it's a better approach. I guess the last check in the test case was intended more to indicate what a good name of that method is, rather than that it should be an instance method. Remove the last check from your test code and I'll update the official homework code as well.

Q. Amarnath Bachhu - 11 Jun 2006 - testSubclassesHaveMaximumOneMethod checks if total number of methods in the subclasses is = 1. Probably it should exclude instance creation methods? Because we need to define the private, general and other such methods in the respective subclasses.

A: Paul Adamczyk - June 11 2006 - Instance creation method are "class" methods. Code such as "NavyRank organization allMethodSelectors" finds "instance" methods only, so you're correct and so is the test.



Link to this Page