2. Variable and Type - CS2030S Programming Methodology II
One of the important abstractions that are provided by a programming language is the variable. Data are stored in some location in computer memory. But we should not be referring to the memory location all the time. First, referring to something like 0xFA49130E is not user-friendly; Second, the location may change. A variable is an abstraction that allows us to give a user-friendly name to a piece of data in memory. We use the variable name whenever we want to access the value in that location, and pointer to the variable or reference to the variable whenever we want to refer to the address of the location. As programs get more complex, the number of variables that the programmer needs to keep track of increases. These variables might be an abstraction over different types of data: some variables might refer to a number, some to a string, some to a list of numbers, etc. Not all operations are meaningful over all types of data. To help mitigate the complexity, we can assign a type to a
Unit 2: Variable and Type After this unit, students should be able to: appreciate the concept of variables as an abstraction understand the concept of types and subtypes contrast between statically typed language vs. dynamically typed language contrast between strongly typed language vs. weakly typed language be familiar with Java variables and primitive types understand widening type conversion in the context of variable assignments and how subtyping dictates whether the type conversion is allowed. Data Abstraction: Variable One of the important abstractions that are provided by a programming
Explore this link on the map →saved by
related reading
- 21. Variance - CS2030S Programming Methodology IInus-cs2030s.github.io
- 4. Encapsulation - CS2030S Programming Methodology IInus-cs2030s.github.io
- 20. Casting - CS2030S Programming Methodology IInus-cs2030s.github.io
- 19. Wrapper Class - CS2030S Programming Methodology IInus-cs2030s.github.io
- 14. Polymorphism - CS2030S Programming Methodology IInus-cs2030s.github.io
- Static typing - Glossary | MDNdeveloper.mozilla.org
- Type system - Wikipediaen.wikipedia.org
- how I think when I think about programming - alice mazalicemaz.com
- No, dynamic type systems are not inherently more openlexi-lambda.github.io
- Variables and Mutability - The Rust Programming Languagedoc.rust-lang.org
- TypeScript: Documentation - TypeScript for the New Programmertypescriptlang.org
- Reading 1: Static Checkingweb.mit.edu