home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / smalltalk-faq < prev    next >
Encoding:
Internet Message Format  |  2004-05-25  |  30.7 KB

  1. Path: senator-bedfellow.mit.edu!dreaderd!not-for-mail
  2. Message-ID: <smalltalk-faq_1082200966@rtfm.mit.edu>
  3. Supersedes: <smalltalk-faq_1079601013@rtfm.mit.edu>
  4. Expires: 31 May 2004 11:22:46 GMT
  5. X-Last-Updated: 1996/05/23
  6. Organization: none
  7. From: vmalik@dc.infi.net (Vikas Malik)
  8. Newsgroups: comp.lang.smalltalk,comp.answers,news.answers
  9. Subject: Smalltalk FAQ (v.1.0)
  10. Followup-To: poster
  11. Approved: news-answers-request@MIT.EDU
  12. Originator: faqserv@penguin-lust.MIT.EDU
  13. Date: 17 Apr 2004 11:27:16 GMT
  14. Lines: 1440
  15. NNTP-Posting-Host: penguin-lust.mit.edu
  16. X-Trace: 1082201236 senator-bedfellow.mit.edu 568 18.181.0.29
  17. Xref: senator-bedfellow.mit.edu comp.lang.smalltalk:144696 comp.answers:56864 news.answers:269840
  18.  
  19. Archive-name: smalltalk-faq
  20. Posting-Frequency: monthly
  21. Last-modified: May 14,1996
  22. Version: 1.0
  23. URL: http://www.infi.net/~vmalik
  24.  
  25. ____________________________________________________________________________
  26.  
  27. Smalltalk Frequently Asked Questions
  28.  
  29.  
  30.  
  31. Copyright =A9 1994 Vikas Malik
  32.  
  33.  
  34.  
  35. All Rights Reserved
  36.  
  37.  
  38.  
  39. This FAQ may be posted to any USENET newsgroup, on-line service, or BBS as
  40.  
  41. long as it is posted in its entirety and includes this copyright statement.
  42.  
  43.  
  44.  
  45. This FAQ may not be distributed for financial gain.
  46.  
  47.  
  48.  
  49. This FAQ may not be included in commercial collections or compilations
  50.  
  51. without express permission from the author.
  52.  
  53.  
  54.  
  55. ____________________________________________________________________________=
  56. _
  57.  
  58.  
  59.  
  60. Vikas Malik - vmalik@dc.infi.net
  61.  
  62.  
  63.  
  64. Knowledge Systems Corporation
  65.  
  66.  
  67.  
  68. ____________________________________________________________________________=
  69. _
  70.  
  71.  
  72.  
  73. Contents
  74.  
  75.  
  76.  
  77.    *  What is self?
  78.  
  79.    *  What is super?
  80.  
  81.    *  What are three different message types in Smalltalk?
  82.  
  83.    *  What is shallow copy?
  84.  
  85.    *  What is deep copy?
  86.  
  87.    *  What are class instance variables?
  88.  
  89.    *  What do you get when you inspect Smalltalk?
  90.  
  91.    *  How can I implement stack and queue operations in Smalltalk?
  92.  
  93.    *  What is the difference between an array and a set?
  94.  
  95.    *  What is the difference between protocol and category?
  96.  
  97.    *  What do I get from 1+2*3?
  98.  
  99.    *  How do I stop the execution of a program?
  100.  
  101.    *  What is the difference between =3D and =3D=3D ?
  102.  
  103.    *  How do I iterate a collection?
  104.  
  105.    *  How do I use message perform: ?
  106.  
  107.    *  What is the difference between detect: and select: methods for
  108.  
  109.      collections?
  110.  
  111.    *  What is the result of sending collect: [ :each | each > 5 ] to
  112.  
  113.      aCollection?
  114.  
  115.    *  What do I use to concatenate strings efficiently?
  116.  
  117.    *  What is superclass of Object?
  118.  
  119.    *  What is subclassResposiblity method used for?
  120.  
  121.    *  What is shouldNotImplement method used for?
  122.  
  123.    *  What methods do I need to implement if I implement =3D method for an
  124.  
  125.      object?
  126.  
  127.    *  What method do I need to implement for proxy objects?
  128.  
  129.    *  What are three pseudo variables used by VisualWorks?
  130.  
  131.    *  What is the difference between SmallInteger and LargeInteger?
  132.  
  133.    *  What is the difference between Symbol and String?
  134.  
  135.    *  What is the difference between Bag and Set?
  136.  
  137.    *  What is the difference between chaining and cascading?
  138.  
  139.    *  What is yourself method used for?
  140.  
  141.    *  What is the difference between isMemberOf: and isKindOf: methods?
  142.  
  143.    *  Where is the method new defined?
  144.  
  145.    *  Why is an IdentitySet faster than a Set?
  146.  
  147.    *  What happens when I modify a collection while iterating over it?
  148.  
  149.    *  What is nil?
  150.  
  151.    *  What are pool dictionaries?
  152.  
  153.    *  What is a literal?
  154.  
  155.  
  156.  
  157. MVC
  158.  
  159.  
  160.  
  161.    *  What is MVC?
  162.  
  163.    *  What is an aspect?
  164.  
  165.    *  What is a dependent?
  166.  
  167.    *  How do I add a dependent to a model?
  168.  
  169.    *  How do I release dependents from a model?
  170.  
  171.    *  What is the change/update mechanism?
  172.  
  173.    *  What happens when I send changed or changed: message to a Model?
  174.  
  175.    *  How do I implement an update method for a view?
  176.  
  177.    *  What does invalidateRectangle: method do?
  178.  
  179.    *  How does a controller accesses keyboard events and mouse state?
  180.  
  181.    *  What is a ValueHolder in VisualWorks?
  182.  
  183.    *  What is a channel?
  184.  
  185.    *  How do an object register interest in a ValueModel?
  186.  
  187.    *  What is a dependency transformer?
  188.  
  189.    *  How do I change the value of a ValueModel without triggering any
  190.  
  191.      updates?
  192.  
  193.    *  What is an AspectAdaptor?
  194.  
  195.    *  What is the subject channel of an AspectAdaptor?
  196.  
  197.    *  What is a PluggableAdaptor?
  198.  
  199.    *  What is an IndexedAdaptor?
  200.  
  201.    *  What is a SelectionInList?
  202.  
  203.    *  What is a BufferedValueHolder?
  204.  
  205.    *  What is the difference between an IndexedAdaptor and an
  206.  
  207.      AspectAdaptor?
  208.  
  209.  
  210.  
  211. Other VisualWorks Questions
  212.  
  213.  
  214.  
  215.    *  What is a BlockClosure in VisualWorks?
  216.  
  217.    *  What is the launcher in VisualWorks?
  218.  
  219.    *  What is a SpecWrapper?
  220.  
  221.    *  What is the difference between an active component and a passive
  222.  
  223.      component?
  224.  
  225.    *  What is a widget?
  226.  
  227.    *  What is difference between application model and aspect model?
  228.  
  229.    *  What is a keyboard hook?
  230.  
  231.    *  What is the Transcript?
  232.  
  233.    *  What is a dispatcher?
  234.  
  235.    *  What is a ComponentSpec?
  236.  
  237.    *  What is a builder in ApplicationModel architecture?
  238.  
  239.    *  What is a FullSpec?
  240.  
  241.    *  What is a builder's resource?
  242.  
  243.    *  What is the builder's source?
  244.  
  245.    *  How does a builder caches resources?
  246.  
  247.    *  What is a lookPolicy object?
  248.  
  249.    *  How can I change a builder's look policy?
  250.  
  251.    *  How is a VisualWorks component built?
  252.  
  253.    *  What methods are used to access window, keyboardProcessor, named
  254.  
  255.      components and aspect models from a builder?
  256.  
  257.    *  What is a keyboard processor?
  258.  
  259.    *  What is the difference between preBuildWith: and postBuildWith:
  260.  
  261.      methods of ApplicationModel?
  262.  
  263.    *  What is the difference between postBuildWith: and postOpenWith:
  264.  
  265.      methods of ApplicationModel?
  266.  
  267.    *  How do I close a window programmatically?
  268.  
  269.    *  Which message is sent to anApplicationModel for notification of a
  270.  
  271.      window close?
  272.  
  273.    *  Which message is sent to anApplicationModel for validation of a
  274.  
  275.      window close?
  276.  
  277.    *  What do I mean by Parent application and subapplication?
  278.  
  279.    *  What is the SubCanvasSpec's clientKey?
  280.  
  281.    *  What is the SubCanvasSpec's majorKey?
  282.  
  283.    *  What is the SubCanvasSpec's minorKey?
  284.  
  285.    *  How do I rebuild a subcanvas?
  286.  
  287.    *  What is ScheduledControllers?
  288.  
  289.    *  How do I access active window?
  290.  
  291.    *  How do I access widget of a named component?
  292.  
  293.    *  How do I give keyboard focus to a widget?
  294.  
  295.    *  How do I change a component's label?
  296.  
  297.    *  How do I make a widget invisible/visible?
  298.  
  299.    *  How do I enable/disable a component?
  300.  
  301.    *  Which method is used by aSequenceView to display its contents?
  302.  
  303.    *  How do I use an arbitrary method to display contents in
  304.  
  305.      aSequenceView?
  306.  
  307.    *  How do I change grid spacing of aSequenceView?
  308.  
  309.  
  310.  
  311. Q1. What is self?
  312.  
  313. Ans. self refers to the receiver of the message. It is usually used within
  314.  
  315. a method to send additional messages to the receiver. self is frequently=
  316.  used=20
  317. when it is desired to pass the sender object (self), as a message argument,=
  318. =20
  319. to a receiver who requires knowledege of the sender or who will in some way=
  320. =20
  321. manipulate the sender.
  322.  
  323.  
  324.  
  325.  
  326. Q2. What is super?
  327.  
  328. Ans. super refers to the superclass of the class that defines the message
  329.  
  330. sent to the receiver.Super is mechanism by which a sender can overide its=20
  331. own defined method hierarchy.
  332.  
  333.  
  334.  
  335.  
  336. Q3. What are three different message types in Smalltalk?
  337.  
  338. Ans. 1. Unary messages
  339.  
  340. 2. Binary Messages
  341.  
  342. 3. Keyword Messages
  343.  
  344.  
  345.  
  346. Q4. What is shallow copy?
  347.  
  348. Ans. shallowCopy returns a copy of receiver which shares the receiver's
  349.  
  350. instance variables.
  351.  
  352.  
  353.  
  354. Q5. What is deep copy?
  355.  
  356. Ans. deepCopy returns a copy of the receiver with shallow copies of each
  357.  
  358. instance variable.
  359.  
  360.  
  361.  
  362. Q6. What are class instance variables?
  363.  
  364. Ans. Class instance variables are similar to class variables, except that
  365.  
  366. they are created for eachsubclass of the defining class. When a class
  367.  
  368. declares a class instance variable, a new variable is created for each
  369.  
  370. subclass of that class. Each subclass then has its own instance of the
  371.  
  372. variable and retains its own value for the variable, but each subclass has
  373.  
  374. a variable with the same name. Only class methods of a class and its
  375.  
  376. subclasses can refer to class instance variables; instance methods cannot.
  377.  
  378.  
  379.  
  380. Q7. What do you get when you inspect Smalltalk?
  381.  
  382. Ans. An instance of SystemDictionary. SystemDictionary maintains all the
  383.  
  384. names of classes, global variables and pool dictionaries in the system.=20
  385. Smalltalk is the sole instance of the class SystemDictionary.
  386.  
  387.  
  388.  
  389. Q8. How can I implement stack and queue operations in Smalltalk?
  390.  
  391. Ans. An OrderedCollection can be used to implement stack and queue
  392.  
  393. operations. A stack is implemented by using addLast: anObject and
  394.  
  395. removeLast methods for pushing and poping respectively. A Queue is
  396.  
  397. implemented by using addLast: anObject and removeFirst methods.
  398.  
  399.  
  400.  
  401. Q9. What is the difference between an array and a set?
  402.  
  403. Ans. An array is a fixed size collection whereas a set can grow in size. An
  404.  
  405. array has integer keys and a set is not keyed. A set enforces uniqueness=
  406.  upon=20
  407. its members.
  408.  
  409.  
  410.  
  411. Q10. What is the difference between protocol and category?
  412.  
  413. Ans. The methods of a class are organised in logical groups called
  414.  
  415. protocols. Classes are grouped together into groups called categories.
  416.  
  417.  
  418.  
  419. Q11. What do I get from 1+2*3?
  420.  
  421. Ans. 9
  422.  
  423.  
  424.  
  425. Q12. How do I stop the execution of a program?
  426.  
  427. Ans. By sending message halt.
  428.  
  429.  
  430.  
  431. Q13. What is the difference between =3D and =3D=3D ?
  432.  
  433. Ans. =3D is a test for equality. =3D=3D is a test for identity (same=
  434.  object).
  435.  
  436. Except for some special classes like Symbol, Character & SmallInteger, two
  437.  
  438. cases of a value (eg. 1.54) will not be the identical object, just one with
  439.  
  440. equal value. The special cases are "special" and any variables that points
  441.  
  442. to such an object will be by definition "Identical".
  443.  
  444.  
  445.  
  446. Q14. How do I iterate a collection?
  447.  
  448. Ans. By using the following enumeration messages.
  449.  
  450. 1. do: aBlock
  451.  
  452. 2. select: aBlock
  453.  
  454. 3. reject: aBlock
  455.  
  456. 4. detect: aBlock
  457.  
  458. 5. collect: aBlock
  459. 6. inject: aValue into: aBlock
  460.  
  461.  
  462. Q15. How do I use message perform: ?
  463.  
  464. Ans. perform: method is used to tell an object to execute a method whose
  465.  
  466. name, rather than being hardcoded, is sent as a parameter. This means that
  467.  
  468. the name of the message need not be know until runtime.
  469.  
  470.  
  471.  
  472.            anObject perform: #methodName
  473.  
  474.  
  475.  
  476. Q16. What is the difference between detect: and select: methods for
  477.  
  478. collections?
  479.  
  480. Ans. detect: aBlock returns the first element of the collection for which
  481.  
  482. aBlock evaluates to true. select: aBlock returns a collection whose
  483.  
  484. elements are the elements of the receiver for which aBlock evaluates to
  485.  
  486. true.
  487.  
  488.  
  489.  
  490. Q17. What is the result of sending collect: [ :each | each > 5 ] to
  491.  
  492. aCollection?
  493.  
  494. Ans. A collection whose elements are true and false.
  495.  
  496. collect:aBlock returns a collection which contains the results of
  497.  
  498. performing the same operation on each element in the receiver collection.
  499.  
  500.  
  501.  
  502. Q18. What do I use to concatenate strings efficiently?
  503.  
  504. Ans. Streams.
  505.  
  506.  
  507.  
  508. Q19. What is superclass of Object?
  509.  
  510. Ans. nil.
  511.  
  512.  
  513.  
  514. Q20. What is subclassResposiblity method used for?
  515.  
  516. Ans. subclassResponsibility method is used to defer the actual
  517.  
  518. implementation of a method.
  519.  
  520.  
  521.  
  522. Q21. What is shouldNotImplement method used for?
  523.  
  524. Ans. shouldNotImplement method is used to indicate that a subclass wants to
  525.  
  526. undefine a method defined in a superclass.
  527.  
  528.  
  529.  
  530. Q22. What methods do I need to implement if I implement =3D method for an
  531.  
  532. object?
  533.  
  534. Ans. hash:
  535.  
  536.  
  537.  
  538. Q23. What method do I need to implement for proxy objects?
  539.  
  540. Ans. doesNotUnderstand: aMessage
  541.  
  542.  
  543.  
  544. Q24. What are three pseudo variables used by VisualWorks?
  545.  
  546. Ans. self, super and thisContext.
  547.  
  548.  
  549.  
  550. Q25. What is the difference between SmallInteger and LargeInteger?
  551.  
  552. Ans. A SmallInteger has fixed number of bytes and a LargeInteger has
  553.  
  554. variable number of bytes.
  555.  
  556.  
  557.  
  558. Q26. What is the difference between Symbol and String?
  559.  
  560. Ans. Symbols are similar to strings except that they are unique. This means
  561.  
  562. that whilst one can create several string objects containing the same
  563.  
  564. sequence of characters, there will only be exactly one instance of a symbol
  565.  
  566. with a given sequence of characters.
  567.  
  568.  
  569.  
  570. Q27. What is the difference between Bag and Set?
  571.  
  572. Ans. A bag can have duplicates whereas a Set contains no duplicate objects.
  573.  
  574.  
  575.  
  576. Q28. What is the difference between chaining and cascading?
  577.  
  578. Ans. In Chaining, one message can follow on after another. In this case the
  579.  
  580. second message is sent to the object which is the result of the first
  581.  
  582. message.
  583.  
  584.  
  585.  
  586.            anObject msg1 msg2 msg3
  587.  
  588.  
  589.  
  590. In Cascading, each message is followed by a semicolon (;) and another
  591.  
  592. message. In Cascading, subsequent messages are sent to the first receiver.
  593.  
  594.  
  595.  
  596.            anObject msg1; msg2; msg3
  597.  
  598.  
  599.  
  600. Q29. What is yourself method used for?
  601.  
  602. Ans. yourself method returns self. It is usually used while cascading
  603.  
  604. messages like add: .
  605.  
  606.  
  607.  
  608.              | aCollection |
  609.  
  610.              aCollection :=3D OrderedCollection new add: 1;
  611.  
  612.                                                   add: 2;
  613.  
  614.                                                   yourself.
  615.  
  616.  
  617.  
  618. In the above example add: returns its argument, not the receiver.
  619.  
  620. Therefore, yourself message is sent to do the proper assignment of an
  621.  
  622. OrderedCollection to aCollection variable.
  623.  
  624.  
  625.  
  626. Q30. What is the difference between isMemberOf: and isKindOf: methods?
  627.  
  628. Ans. isMemberOf: aClass returns true if receiver is an instance of aClass.
  629.  
  630. isKindOf: aClass returns true if receiver is an instance of aClass or one
  631.  
  632. of its subclasses.
  633.  
  634.  
  635.  
  636. Q31. Where is the method new defined?
  637.  
  638. Ans. Method new is defined on instance side of class Behavior.
  639.  
  640.  
  641.  
  642. Q32. Why is an IdentitySet faster than a Set?
  643.  
  644. Ans. An IdentitySet is faster that a Set because =3D=3D is a faster test=
  645.  than =3D
  646.  
  647.  
  648.  
  649.  
  650.  
  651. Q33. What happens when I modify a collection while iterating over it?
  652.  
  653. Ans. Modifying a collection while iterating over it will give unpredictable
  654.  
  655. results.
  656.  
  657.  
  658.  
  659. Employees do: [:anEmployee | anEmployee isProgrammer ifTrue: [ Employees
  660.  
  661. remove: anEmployee]]
  662.  
  663. Above example will not work as expected since we are changing the size of
  664.  
  665. Employees collection while iterating over it. Making a copy of the
  666.  
  667. collection will avoid the above problem.
  668.  
  669. Employees copy do: [:anEmployee | anEmployee isProgrammer ifTrue: [
  670.  
  671. Employees remove: anEmployee]]
  672.  
  673. Q34. What is nil?
  674.  
  675. Ans. nil is the only instance of the class UndefinedObject and it is the
  676.  
  677. default value for any new variable until a specific value is assigned to
  678.  
  679. it.
  680.  
  681.  
  682.  
  683. Q35. What are pool dictionaries?
  684.  
  685. Ans. Pool dictionaries are created for providing access to pool variables
  686.  
  687. to several classes that are not related by inheritance.
  688.  
  689.  
  690.  
  691. Q35+. What is a literal?
  692.  
  693. Ans. A literal is a piece of Smalltalk code that the compiler converts
  694.  
  695. immediately to an object. Literals can be freely included in the programs
  696.  
  697. just by typing them.
  698.  
  699.  
  700.  
  701.                  Literal type           Example
  702.  
  703.                    Character                  $s
  704.  
  705.                    Symbol                     #name
  706.  
  707.                    String                    'David Letterman'
  708.  
  709.                    Number                     12
  710.  
  711.                    Boolean                    false
  712.  
  713.                    UndefinedObject            nil
  714.  
  715.                    Array of literals          #('apple' 12.9 name)
  716.  
  717.  
  718.  
  719. Q36. What is MVC?
  720.  
  721. Ans. MVC stands for Model-View-Controller. Model stores information/data.
  722.  
  723. Model notifies its dependents whenever one or more of its variables is
  724.  
  725. changed. View is the component for displaying output. Contoller is the
  726.  
  727. component that enables the user to interact with, or control, the
  728.  
  729. application.
  730.  
  731.  
  732.  
  733. Q37. What is an aspect?
  734.  
  735. Ans. An aspect is a piece or subset of model's domain information.
  736.  
  737.  
  738.  
  739. Q38. What is a dependent?
  740.  
  741. Ans. A dependent is an object that is dependent on the information residing
  742.  
  743. in a model. A dependent object is usually a view, a window, or another
  744.  
  745. model and is contained in dependents collection of a model.
  746.  
  747.  
  748.  
  749. Q39. How do I add a dependent to a model? Ans. aModel addDependent:
  750.  
  751. aDependent.
  752.  
  753. This method adds aDependent to aModel's dependents collection.
  754.  
  755.  
  756.  
  757. Q40. How do I release dependents from a model?
  758.  
  759. Ans. aModel release replaces aModel's dependents collection with nil.
  760.  
  761.  
  762.  
  763. Q41. What is the changed/update mechanism?
  764.  
  765. Ans. The changed/update mechanism is used by a model to broadcast a
  766.  
  767. notification of change to all its dependents.
  768.  
  769.  
  770.  
  771. Q42. What happens when I send changed or changed: message to a Model?
  772.  
  773. Ans. A changed/changed: message sends an update message to all of
  774.  
  775. receiver's(model) dependents.
  776.  
  777.  
  778.  
  779. Q43. How do I implement an update method for a view?
  780.  
  781. Ans. The prototype for an update method for a view is
  782.  
  783.  
  784.  
  785.    update: anAspect
  786.  
  787.          anAspect =3D anAspectOfInterest
  788.  
  789.           ifTrue: [ self invalidate]
  790.  
  791.  
  792.  
  793. Q44. What does invalidateRectangle: method do?
  794.  
  795. Ans. Invalidate messages initiate a view's redrawing process.
  796.  
  797. invalidateRectangle: aRectangle invalidates only that area of the view
  798.  
  799. defined by aRectangle.
  800.  
  801.  
  802.  
  803. Q45. How does a controller accesses keyboard events and mouse state?
  804.  
  805. Ans. By using its instance variable sensor, which references a
  806.  
  807. TranslatingSensor.
  808.  
  809.  
  810.  
  811. Q46. What is a ValueHolder in VisualWorks?
  812.  
  813. Ans. A ValueHolder is a value model. It holds simple model objects like
  814.  
  815. numbers, strings, etc. A ValueHolder is created by sending asValue message
  816.  
  817. to any object or sending with: anObject to ValueHolder class
  818.  
  819.  
  820.  
  821.                 anObject asValue.
  822.  
  823.         ValueHolder with: anObject
  824.  
  825.  
  826.  
  827. A ValueHolder understands value/value: protocol. value message is used to
  828.  
  829. access its value. value: anObject message is used to set its value to
  830.  
  831. anObject.
  832.  
  833.  
  834.  
  835. Q47. What is a channel?
  836.  
  837. Ans. A channel is a value model that is used as a common access point for a
  838.  
  839. changing value.
  840.  
  841.  
  842.  
  843. Q48. How do an object register interest in a ValueModel?
  844.  
  845. Ans. By sending onChangeSend: aChangeMessage to: anInterestedObject to a
  846.  
  847. ValueModel. The advantages of this approach are:
  848.  
  849. (i) The interested object does not need to be a dependent of the value
  850.  
  851. model.
  852.  
  853. (ii) The interested object does not need to implement an update method.
  854.  
  855.  
  856.  
  857. Q49. What is a dependency transformer?
  858.  
  859. A DependencyTransformer implements the behavior needed by an object to
  860.  
  861. register interest in a value model. A dependencyTransformer is defined as a
  862.  
  863. dependent of a value model and converts an update message sent to itself
  864.  
  865. into a specific change message and sends this change message to the
  866.  
  867. interested object.
  868.  
  869.  
  870.  
  871. Q50. How do I change the value of a ValueModel without triggering any
  872.  
  873. updates?
  874.  
  875. Ans. 1. By using setValue: newValue method instead of value: newValue
  876.  
  877. method. setValue: method replaces the value instance variable without
  878.  
  879. sending update messages to dependents.
  880.  
  881. 2. Remove the DependencyTransformer from the ValueModel's dependents. Send
  882.  
  883. retractInterestsFor: anObject message to the ValueModel. This is done just
  884.  
  885. prior to sending value: newValue message.
  886.  
  887. Using setValue: disallows all updates. retractInterestsFor: only disallows
  888.  
  889. a specific update, allowing all others to proceed.
  890.  
  891.  
  892.  
  893. Q51. What is an AspectAdaptor?
  894.  
  895. Ans. An AspectAdaptor is a ValueModel whose value actually belongs to
  896.  
  897. another object called the subject. The task of AspectAdaptor is to
  898.  
  899. interface the general-purpose view object to just one aspect of the
  900.  
  901. model(subject). An AspectAdaptor is created as follows:
  902.  
  903.  
  904.  
  905.                    | aa |
  906.  
  907.                         aa :=3D AspectAdaptor subject: Employee new.
  908.  
  909.                         aa forAspect: #ssn.
  910.  
  911.  
  912.  
  913. One can change the ssn of this employee by using aa value: aNumber. An
  914.  
  915. AspectAdaptor needs to know which messages to send to the model to access
  916.  
  917. and assign value to one of its aspect. In the above example value/value:
  918.  
  919. messages sent to aa are converted into ssn/ssn: and sent to subject.
  920.  
  921. forAspect: #ssn message sets the getSelector to #ssn and sets the
  922.  
  923. putSelector to #ssn: The value method of AspectAdaptor is implemented as
  924.  
  925.  
  926.  
  927.                    value
  928.  
  929.                              ^subject perform: self getSelector
  930.  
  931.  
  932.  
  933. Q52. What is the subject channel of an AspectAdaptor?
  934.  
  935. Ans. The subject channel is the ValueHolder containing the subject of an
  936.  
  937. AspectAdaptor. It is useful when several AspectAdaptors share the same
  938.  
  939. subject and its value of this subject needs to be changed.
  940.  
  941.  
  942.  
  943. Q53. What is a PluggableAdaptor?
  944.  
  945. Ans. A PluggableAdaptor uses blocks to adapt a model to a view instead of
  946.  
  947. using just selectors like AspectAdaptor. The blocks are called the
  948.  
  949. getBlock, the putBlock and the updateBlock. These blocks get executed when
  950.  
  951. a PluggableAdaptor receives value/value: and update messages. A
  952.  
  953. PluggableAdaptor can be created as follows:
  954.  
  955.  
  956.  
  957.                    | pa |
  958.  
  959.                         pa :=3D PluggableAdaptor on: Employee new.
  960.  
  961.                         pa getBlock: [ :m | m salary * 30 ]
  962.  
  963.                            putBlock: [ :m :v | m salary: (v/30)]
  964.  
  965.                            updateBlock: [ :m :a :p | ....  ].
  966.  
  967.  
  968.  
  969. On sending value message to pa, getBlock gets executed. It send salary
  970.  
  971. message to employee(model), multiplies the result by 30 and returns it. In
  972.  
  973. this way, one can perform more complex operations on model as a result of
  974.  
  975. just sending the value message to pluggableAdapator.
  976.  
  977.  
  978.  
  979. Q54. What is an IndexedAdaptor?
  980.  
  981. Ans. An IndexedAdaptor is similar to AspectAdaptor except that its subject
  982.  
  983. is a sequenceable collection and value/value: messages are dispatched to
  984.  
  985. the subject as at:/at: put: . Q55. What is a SelectionInList?
  986.  
  987. Ans. A SelectionIinList is a selection model. It has two instance
  988.  
  989. variables.
  990.  
  991. (i) listHolder instance variable is a ValueModel containing a sequenceable
  992.  
  993. collection. listHolder acts as a model for SequenceView.
  994.  
  995. (ii) selectionIndexHolder instance variable is a ValueHolder with the index
  996.  
  997. of the current selection as its value.
  998.  
  999. SelectionInList does not have any dependents. Both of its instance
  1000.  
  1001. variables have two dependents : the SequenceView and the SelectionInList
  1002.  
  1003. object itself.
  1004.  
  1005.  
  1006.  
  1007. Q56. What is a BufferedValueHolder?
  1008.  
  1009. Ans. A BufferedValueHolder is a ValueModel that references two other value
  1010.  
  1011. models called its subject and trigger channel. When a BufferedValueHolder
  1012.  
  1013. receives a value: message, it holds onto the new value and does not update
  1014.  
  1015. the subject until trigger channel becomes true.
  1016.  
  1017.  
  1018.  
  1019. Q57. What is the difference between an IndexedAdaptor and an AspectAdaptor?
  1020.  
  1021.  
  1022.  
  1023. Ans. An IndexedAdaptor operates on a numbered instance variable in the
  1024.  
  1025. subject, whereas an AspectAdaptor operates on a named instance variable.
  1026.  
  1027.  
  1028.  
  1029. Q58. What is a BlockClosure in VisualWorks?
  1030.  
  1031. Ans. Class BlockClosure implements the block notation in VisualWorks
  1032.  
  1033. Smalltalk. In VisualWorks, blocks are close to being closures. One can
  1034.  
  1035. declare variables local to the block, and the names of block parameters are
  1036.  
  1037. local to the block.
  1038.  
  1039.  
  1040.  
  1041. Q59. What is the launcher in VisualWorks?
  1042.  
  1043. Ans. The launcher is the root of the VisualWorks development environment.
  1044.  
  1045. Various development tools can be launched (or opened) from its menu.The
  1046.  
  1047. launcher is implemented by VisualLauncher which is a subclass of
  1048.  
  1049. ApplicationModel.
  1050.  
  1051.  
  1052.  
  1053. Q60. What is a SpecWrapper?
  1054.  
  1055. Ans. A VisualWorks component is a SpecWrapper. A SpecWrapper is wrapper
  1056.  
  1057. that contains a widget, decoration for the widget, a copy of WidgetState
  1058.  
  1059. object and ComponentSpec.
  1060.  
  1061.  
  1062.  
  1063. Q61. What is the difference between an active component and a passive
  1064.  
  1065. component?
  1066.  
  1067. Ans. An active component is a VisualWorks component whose widget is a View
  1068.  
  1069. and has a Model and a Controller. A passive component is a VisualWorks
  1070.  
  1071. component whose widget is not a View and it does not depend on a model and
  1072.  
  1073. a controller.
  1074.  
  1075.  
  1076.  
  1077. Q62. What is a widget?
  1078.  
  1079. Ans. A widget is a visual part responsible for the visual representation of
  1080.  
  1081. a VisualWorks component.
  1082.  
  1083.  
  1084.  
  1085. Q63. What is difference between application model and aspect model?
  1086.  
  1087. Ans. An ApplicationModel is responsible for creating and managing a runtime
  1088.  
  1089. user interface. An aspect model contains a single aspect of info and
  1090.  
  1091. provides the model behavior for a single VisualWorks component. The
  1092.  
  1093. relationship between an application model and an aspect model is that an
  1094.  
  1095. application model contains one or more aspect models.
  1096.  
  1097.  
  1098.  
  1099. Q64. What is a keyboard hook?
  1100.  
  1101. Ans. A keyboard hook is a used for intercepting all the keyboard activity
  1102.  
  1103. going to a VisualWorks component. It is a block which is evaluated just
  1104.  
  1105. prior to the widget controller handling a keyboard event. Keyboard hook can
  1106.  
  1107. be set as follows:
  1108.  
  1109.  
  1110.  
  1111.                   | comp |
  1112.  
  1113.                   comp :=3D anApplicationModel builder componentAt:=
  1114.  #myComponent.
  1115.  
  1116.                   comp widget controller keyboardHook: aBlock.
  1117.  
  1118.  
  1119.  
  1120. Q65. What is the Transcript?
  1121.  
  1122. Ans. The Transcript is a text window used by the system to report important
  1123.  
  1124. events. The global variable Transcript is an instance of the class
  1125.  
  1126. TextCollector in VisualWorks and class TranscriptWindow in Digitalk.
  1127.  
  1128.  
  1129.  
  1130. Q66. What is a dispatcher?
  1131.  
  1132. Ans. A dispatcher is used by a widget controller to dispatch notification
  1133.  
  1134. and validation messages to the ApplicationModel. A dispatcher is an
  1135.  
  1136. instance of class UIDispatcher.
  1137.  
  1138.  
  1139.  
  1140. Q67. What is a ComponentSpec?
  1141.  
  1142. Ans. A ComponentSpec describes properties and features of a VisualWorks
  1143.  
  1144. component. ComponentSpec provides behavior for interface persistence in
  1145.  
  1146. form of source code or text file.
  1147.  
  1148.  
  1149.  
  1150. Q68. What is a builder in ApplicationModel architecture?
  1151.  
  1152. Ans. A builder is an instance of class UIBuilder. It is used to construct a
  1153.  
  1154. user interface according to the specifications. It also provides access to
  1155.  
  1156. the runtime interface. Builder provides access to named components, the
  1157.  
  1158. keyboard processor, the window and aspect models of a running application.
  1159.  
  1160.  
  1161.  
  1162. Q69. What is a FullSpec?
  1163.  
  1164. Ans. A FullSpec is a combination of a window spec and a spec collection. A
  1165.  
  1166. window spec describes a window and a spec collection is a collection of
  1167.  
  1168. component specs for all components of a window.
  1169.  
  1170.  
  1171.  
  1172. Q70. What is a builder's resource?
  1173.  
  1174. Ans. A resource is an object used by the builder to construct the interface
  1175.  
  1176. according to the specs. Examples of resources are aspect models, menus,
  1177.  
  1178. images, and labels. There are two types of resources:
  1179.  
  1180. 1. Static resources - do not change during runtime.
  1181.  
  1182. 2. Dynamic resources - change during runtime.
  1183.  
  1184.  
  1185.  
  1186. Q71. What is the builder's source?
  1187.  
  1188. Ans. The builder's source is an ApplicationModel that provides the
  1189.  
  1190. necessary resources to a builder for building an interface according to the
  1191.  
  1192. specs. It is kept in source instance variable of UIBuilder.
  1193.  
  1194.  
  1195.  
  1196. Q72. How does a builder caches resources?
  1197.  
  1198. Ans. A builder uses the following variables to cache resources.
  1199.  
  1200. 1. bindings to cache aspect models reqired by active components.
  1201.  
  1202. 2. labels to cache text labels.
  1203.  
  1204. 3. visuals to cache visual components.
  1205.  
  1206.  
  1207.  
  1208. Q73. What is a lookPolicy object?
  1209.  
  1210. Ans. A lookPolicy object is an instance of one of the subclasses of the
  1211.  
  1212. UILookPolicy abstract class. A lookPolicy object is used to create a
  1213.  
  1214. VisualWorks component based on the componentSpec and the specific window
  1215.  
  1216. environment's look and feel.
  1217.  
  1218.  
  1219.  
  1220. Q74. How can I change a builder's look policy?
  1221.  
  1222. Ans. By sending policy: aLookPolicy message to a builder.
  1223.  
  1224.  
  1225.  
  1226.            aBuilder policy: MotifLookPolicy new.
  1227.  
  1228.  
  1229.  
  1230. Q75. How is a VisualWorks component built?
  1231.  
  1232. Ans. A VisualWorks component is built by either the component spec or by
  1233.  
  1234. the builder's look policy object. Usually it is the look policy object that
  1235.  
  1236. builds a VisualWorks component. A look policy object uses its instance
  1237.  
  1238. methods, component building methods, to construct a VisualWorks component
  1239.  
  1240. based on a ComponentSpec and look & feel of that particular look policy.
  1241.  
  1242.  
  1243.  
  1244. Q76. What methods are used to access window, keyboardProcessor, named
  1245.  
  1246. components and aspect models from a builder?
  1247.  
  1248. Ans.
  1249.  
  1250.  
  1251.  
  1252.                 aBuilder window.
  1253.  
  1254.                 aBuilder keyboardProcessor.
  1255.  
  1256.                 aBuilder componentAt: #componentID.
  1257.  
  1258.                 aBuilder aspectAt: #aspect.
  1259.  
  1260.  
  1261.  
  1262. Q77. What is a keyboard processor?
  1263.  
  1264. Ans. A keyboard processor is an instance of class KeyboardProcessor. It
  1265.  
  1266. directs keyboard events to the current widget controller. There is only one
  1267.  
  1268. keyboard processor per window. A widget controller that takes focus has an
  1269.  
  1270. instance variable, keyboardProcessor, used to reference its window's
  1271.  
  1272. keyboard processor.
  1273.  
  1274.  
  1275.  
  1276. Q78. What is the difference between preBuildWith: and postBuildWith:
  1277.  
  1278. methods of ApplicationModel?
  1279.  
  1280. Ans. preBuildWith: aBuilder method allows anApplicationModel to make any
  1281.  
  1282. changes to its builder prior to handling its full spec. postBuildWith:
  1283.  
  1284. aBuilder method allows any final changes to the interface prior to opening.
  1285.  
  1286.  
  1287.  
  1288. Q79. What is the difference between postBuildWith: and postOpenWith:
  1289.  
  1290. methods of ApplicationModel?
  1291.  
  1292. Ans. In the postBuildWith: method, the interface is completely built but it
  1293.  
  1294. exists in memory only and window is not open. Whereas postOpenWith: method
  1295.  
  1296. allows the application model to make any changes to the interface with the
  1297.  
  1298. window open.
  1299.  
  1300.  
  1301.  
  1302. Q80. How do I close a window programmatically?
  1303.  
  1304. Ans. By sending the closeRequest message to anApplicationModel.
  1305.  
  1306. closeRequest method sends an update: #closeRequest to anApplication Model
  1307.  
  1308. dependents (window is one of the dependents).
  1309.  
  1310.  
  1311.  
  1312. Q81. Which message is sent to anApplicationModel for notification of a
  1313.  
  1314. window close?
  1315.  
  1316. Ans. noticeOfWindowClose: aWindow.
  1317.  
  1318.  
  1319.  
  1320. Q82. Which message is sent to anApplicationModel for validation of a window
  1321.  
  1322. close?
  1323.  
  1324. Ans. requestForWindowClose.
  1325.  
  1326.  
  1327.  
  1328. Q83. What do I mean by Parent application and subapplication?
  1329.  
  1330. Ans. The subapplication is the application model that manages the
  1331.  
  1332. subcanvas. The parent application is the application model that provides
  1333.  
  1334. the subapplication as an aspect model.
  1335.  
  1336.  
  1337.  
  1338. Q84. What is the SubCanvasSpec's clientKey?
  1339.  
  1340. Ans. clientKey is the message name which is sent to parent application to
  1341.  
  1342. acquire the subapplication that manages the subcanvas.
  1343.  
  1344.  
  1345.  
  1346. Q85. What is the SubCanvasSpec's majorKey?
  1347.  
  1348. Ans. majorKey is the name of ApplicationModel subclass that builds and runs
  1349.  
  1350. the subcanvas component.
  1351.  
  1352.  
  1353.  
  1354. Q86. What is the SubCanvasSpec's minorKey?
  1355.  
  1356. Ans. minorKey is name of the class method that returns a full spec
  1357.  
  1358. describing the subcanvas interface.
  1359.  
  1360.  
  1361.  
  1362. Q87. How do I rebuild a subcanvas?
  1363.  
  1364. Ans. By sending one of the following messages to aSubCanvas.
  1365.  
  1366.  
  1367.  
  1368.                 client: appModel
  1369.  
  1370.                 client: appModel spec: aSpec
  1371.  
  1372.                 client: appModel spec: aSpec builder: aBuilder
  1373.  
  1374.  
  1375.  
  1376. appModel is subapplication, aSpec is full spec of subcanvas, and aBuilder
  1377.  
  1378. is an instance of UIBuilder.
  1379.  
  1380.  
  1381.  
  1382. Q88. What is ScheduledControllers?
  1383.  
  1384. Ans. ScheduledControllers is a global variable that refers to the only
  1385.  
  1386. instance of ControlManager. It is responsible for managing all current
  1387.  
  1388. window controllers.
  1389.  
  1390.  
  1391.  
  1392. Q89. How do I access active window?
  1393.  
  1394. Ans. ScheduledControllers currentController view
  1395.  
  1396.  
  1397.  
  1398. Q90. How do I access widget of a named component?
  1399.  
  1400. Ans. (anApplicationModel builder componentAt: #compID) widget
  1401.  
  1402.  
  1403.  
  1404. Q91. How do I give keyboard focus to a widget?
  1405.  
  1406. Ans. By sending takeKeyboardFocus to a VisualWorks component.
  1407.  
  1408.  
  1409.  
  1410. Q92. How do I change a component's label?
  1411.  
  1412. Ans. comp labelString: aString
  1413.  
  1414.  
  1415.  
  1416. Q93. How do I make a widget invisible/visible?
  1417.  
  1418. Ans.
  1419.  
  1420.  
  1421.  
  1422.         comp beInvisible.
  1423.  
  1424.         comp beVisible.
  1425.  
  1426.  
  1427.  
  1428. Q94. How do I enable/disable a component?
  1429.  
  1430. Ans.
  1431.  
  1432.  
  1433.  
  1434.         comp enable.
  1435.  
  1436.         comp disable.
  1437.  
  1438.  
  1439.  
  1440. Q95. Which method is used by aSequenceView to display its contents?
  1441.  
  1442. Ans. displayString
  1443.  
  1444.  
  1445.  
  1446. Q96. How do I use an arbitrary method to display contents in aSequenceView?
  1447.  
  1448. Ans. By sending displayStringSelector: aSymbol message to aSequenceView.
  1449.  
  1450. aSymbol is the name of method used to display strings.
  1451.  
  1452.  
  1453.  
  1454. Q97. How do I change grid spacing of aSequenceView?
  1455.  
  1456. Ans. aSequenceView lineGrid: aNumber
  1457.  
  1458.  
  1459.