Variables are always necessary?

Good day
In app inventor is it always necessary to use variables no matter how simple the app is? Or are there apps that don't need variables?
Thanks

1 Like

I prefer to avoid global variables, if I can afford it.
Each global variable comes with a cognitive load, worrying where else in the code it changes.

But local variables are a different matter.
Use those as needed.

Either way, use informative names for your variables

  • Doomsday_deadline_datetime
  • lunch_datetime
1 Like

This question is completely unspecific. Where is the specific problem, if there is one at all?

No global variables here ...

The MIT HelloPurr tutorial

1 Like
  • No, in App Inventor it is not always necessary to use variables.

Yes, this is an application without variables.

BUT...

one of the goals of App Inventor is to learn to program, and most programming languages ​​use variables, so the use of variables is very important, recommended and many times necessary.

sumar2

App Inventor allows to use alphanumeric variables in calculations.

sumar3

Depending on the algorithm, it will be more convenient to use global or local variables.

5 Likes

How?
Labels and textbooks are too variables, content of text box varying during the execution of program whatever user put that would be the value of text box. same is true for label as well we use label for informative purpose over the execution replace the old tax of label with the new one according to our requirement.

So I don't think we can have a program without variable.

Variable is Central theme of program, we program around a variable and program for a variable.

In mathematical section we have 1,2,3,4... are also constant but still a variable which cannot be manipulated or modified, 1 will be always 1 the way they are defined in a program as a constant.

Have you read Understanding an App's Architecture (particularly pg 251)?

Information can be stored in memory slots called variables, which you defne in the
Blocks Editor. Variables are like component properties, but they’re not associated with
any particular component

Here are some resources to help you learn to use the AI2 tools. A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook http://www.appinventor.org/book2 ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles

How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling .

Also look here http://kio4.com/appinventor/index.htm and here http://www.imagnity.com/tutorial-index/ for more tutorials.

Learn about components http://ai2.appinventor.mit.edu/reference/components/
and visit the Library http://appinventor.mit.edu/explore/library Help>Library on the MENU

4 Likes

Yes, and we should not forget to mention one of the best (if not the best) sources to understand and learn AI2: https://puravidaapps.com/.

3 Likes

Thanks @SteveJG for helping to understand more about the structure.

Yes, I just gone through that it's all about the perspective, component and its the structure.

My answer wasn't according to the concern of perspectives.

My understanding is a component it is still a container and we can change its value or we can program that component from program blocks if we can do that why we cannot think or consider that container or or a component as a variable.

1 Like

I had the same question as well; making a component is basically invoking a new object onto the heap, isn't it?

What does that change? What is that supposed to help for?
It is always desirable to define terms precisely, at least when a (practically relevant) understanding and benefis arise from it.

So again:

Or is it just a sophistic question?

To be having more clear picture, of what programmer should have. As describe in the suggested document.

Apps have an internal structure that you must understand in order
to create them effectively.

Thanks

But what do variables have to do with it?

(Maybe @ewpatton can say something more about it.)

1 Like

One very important thing about variables is how you name them.

A good variable name should include

  • its type (list, index,name,dictionary, table, component, degreesF,...)
  • its context (name of boss of employee, subtotal of purchase costs,...)
  • some lexical distance from other variable names, like secondsToLunch vs secondsToLaunch in a missile silo app

Hello Anke, thank you for answering, it is not a problem with any app that I am doing, it is a doubt that arises when watching tutorials. In some tutorials they use variables and in others they don't, so I wonder, is it an option of personal taste? Is it the best option to use variables or does it complicate the construction of the app? Is it mandatory to use variables in the construction of any app? Or does it depend on the complexity and size of the app? that is the doubt. :slight_smile:

I defy any one to make this little demo app without using variables ...

2 Likes

you do not have to use variables
Taifun

Hello, do you mean this, I just used the join operation not variable.

image

You defused my trap!

1 Like

Guess the number without variables.

p3_adivina_var.aia (26.3 KB)

1 Like