Question

I'm trying to write pseudocode for an android GPS app example, i know there is no standard but is it acceptable to do this or there a better and more clear way?

Define class MainActivity inherits Android Activity class and implements LocationListener interface
MainActivity Start
Override the void onCreate method of Activity class
start
  set the buttons of the main screen layout:
  do
  set 'my point button' to start GeoLocation class
  set 'settings button' to start Settings class
  set 'address button' to start My Address class
  set 'Help image_button' to start Help class
  done
End

Override the void onResume method of Activity class
start
  request Location Updates every 5 seconds
end
// and so on

and what about representing activity life cycle? can it represented this way?

when the activity created
do ...........
done
when the activity Resumed
//and so on

and then i'll write the other classes

thank you

Was it helpful?

Solution 3

Pseudocode is a high-level description of an algorithm. Therefore, it is best to avoid using language-specific terms or lower-level expressions and structures. The goal of pseudocode is to describe an algorithm in such way that it can be implemented in any language (as much as possible).

For instance, avoid using terms like class, implements, void, Override, etc.

Although (almost) any pseudocode you write will be technically valid, you should try to follow a structured syntax, may it be you own or a renowned one. Take a look at Wikipedia's page, and inspire from this!

Raw example:

PROCEDURE someAlgorithm(number: Integer)
    number <- number + 42
    IF number > 50
        number -> DISPLAY
    END IF
END PROCEDURE

OTHER TIPS

I don't know if you're writing pseudocode, or just Java code in a more verbose way.

Instead of writing something like

@Override
public void onResume() {
 ...
}

you write

Override the void onResume method of Activity class
start
  request Location Updates every 5 seconds
end

What's the advantage of that, versus writing Java code from the start?

Go more abstract.

What you're giving there is very implementation specific (and, trivial, pardon the wording). The role of pseudocode is in describing actual calculations/algorithms in a technology-independent manner, but this is obviously not what you're trying to do. For example, in your pseudocode there is no abstraction, which would make it easily possible to port your program to C# or Objective-C, because terms like Activity don't exist there.

Is there a reason why you would need pseudocode for that at all?

Use groovy-DSL instead of pseudocode, it's even compilable (not in android of course). It's way more compact than java code, and provides great level of abstraction

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top