Is there a way to mark a method as pending to implement in Pharo?
Asked Answered
M

4

6

Just wondering if you can mark a method as pending to implement in pharo, like you can do in java using "todo"

I'ts really hard for me to keep track of what's complete on pharo without something like that

Maomaoism answered 27/3, 2019 at 21:51 Comment(0)
M
1

I found the solution for this by myself 2 days after asking about it, almost accidentally, just using the context menu option jump to test method over a method without any test. Pharo automatically generated an empty test with this:

self flag: #toImplement.
self assert: false`

the first line, which can be used not only on tests, gives me the behavior I expected as it automatically categorizes the method containing it on a flags category marked with a big "!" allowing to easily check at glance which methods are pending.

The second line forces test to fail and be shown on yellow which is pretty useful because if it's empty it will pass and be shown on green, probably leading to believe it's already done when is not the case. A similar effect can be achieved just using self notYetImplemented

I would probably start doing something like this with my incomplete methods:

MyIncompleteMethod

  self flag: #toImplement.  
  self notYetImplemented.`
Maomaoism answered 30/3, 2019 at 8:41 Comment(1)
And in Pharo 8 we will integrate a new tool to browse flags ;)Unteach
I
12

Methods whose implementation is still pending should send the notYetImplemented message like this:

methodImNotSureHowToImplement
  ^self notYetImplemented

if the unimplemented message gets sent anyway, it will signal a NotYetImplemented exception which will know the offending selector, #methodImNotSureHowToImplement in my example.

Note also that this will make it easy finding all methods that need to be implemented as senders of #notYetImplemented.

The implementation of #notYetImplemented is straightforward, thanks to the existence of NotYetImplemented.

notYetImplemented
  "Announce that this message is not yet implemented"
   NotYetImplemented signalFor: thisContext sender selector

Note also that NotYetImplemented is one of the subclasses of SelectorException which model several situations of similar kinds:

SelectorException
  NotYetImplemented
  PrimitiveFailed
  ShouldBeImplemented
  ShouldNotImplement
  SubclassResponsibility
Irenics answered 28/3, 2019 at 2:52 Comment(0)
M
1

I found the solution for this by myself 2 days after asking about it, almost accidentally, just using the context menu option jump to test method over a method without any test. Pharo automatically generated an empty test with this:

self flag: #toImplement.
self assert: false`

the first line, which can be used not only on tests, gives me the behavior I expected as it automatically categorizes the method containing it on a flags category marked with a big "!" allowing to easily check at glance which methods are pending.

The second line forces test to fail and be shown on yellow which is pretty useful because if it's empty it will pass and be shown on green, probably leading to believe it's already done when is not the case. A similar effect can be achieved just using self notYetImplemented

I would probably start doing something like this with my incomplete methods:

MyIncompleteMethod

  self flag: #toImplement.  
  self notYetImplemented.`
Maomaoism answered 30/3, 2019 at 8:41 Comment(1)
And in Pharo 8 we will integrate a new tool to browse flags ;)Unteach
S
1

you also can use pragmas to mark such methods

Symbiosis answered 7/4, 2019 at 7:47 Comment(0)
B
0

As Smalltalk provides the origin of agile development, let me provide a different answer. In a failing unit test. As you are not supposed to have a lot of those, it automatically provides the pressure to limit work in progress (the number of open #toDo's).

Barquentine answered 8/5, 2019 at 14:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.