When you pair with someone on code, you talk about code a lot. This is especially true in a remote context, where just grabbing the keyboard is not convenient. One problem I’ve noticed is that a lot of people don’t have a firm grasp of the syntactic elements common in most programming languages. This makes it very difficult to have the necessary conversations.
This post provides definitions for the following terms: declaration, body, definition, method, signature, block, statement, expression, assignment, variable, field, property, parameter, argument, initializer, righthand side, lefthand side, and symbol/identifier.
If you have an upcoming session with a Producore coach, please make sure you have a firm grasp on each of these terms. If you came here just to read our blog, you still might benefit from having good definitions for these terms.
Reference Code
I’ll use this reference sample to provide examples for all the named syntax elements.
// C#
public class Base;
public partial class Child : Base
{
public void MethodA() { }
public partial void MethodB();
}
public class OtherChild : Base
{
readonly string Content;
OtherChild(string Content)
{
this.Content = Content;
}
public static OtherChild Instance { get; } = new("some content");
public Base AsBase => this;
public bool IsSameType(Base Other) => Other is OtherChild;
}
public class SomeClass
{
bool Flag;
int TimesItHappened;
public void Method1()
{
if (Method2())
{
Console.WriteLine("It happened, again.");
TimesItHappened += 1;
}
}
public bool Method2()
{
return Flag = !Flag;
}
public void Method3()
{
var X = Console.ReadKey(); Console.WriteLine($"You pressed {X}");
Console.WriteLine(
"Try again...");
}
}
Declaration
A statement that a design element exists. It is the description of how to “choose or use” a design element.
The declaration does not describe what is “in” the design element, only how to address it in the design space.
For example, the signature of a method is defined counts as its declaration, but the actual algorithm inside that method does not. Likewise, the name, namespace, type parameters, and constraints of a class are all part of its declaration, but its methods and other members are not.
Some of the sample declarations in the reference code are:
public class Base<T>;public partial class Child<T> : Base<T>public void MethodA()public partial void MethodB();
Body
This is the definition of the content or payload of a design element. The members inside a class or the algorithm inside a method are both examples.
A sample class body from the reference code is:
public void MethodA() { }
public partial void MethodB();
A sample method body from the reference code is:
if (Method2())
{
Console.WriteLine("It happened, again.");
TimesItHappened += 1;
}
Definition
The combination of a declaration and a body, along with any syntactic glue (such as braces around the body of a method).
An sample class definition from the reference code is:
public partial class Child : Base
{
public void MethodA() { }
public partial void MethodB();
}
An sample method definition from the reference code is:
public bool Method2()
{
return Flag = !Flag;
}
Method
Sometimes called a function or procedure. A method is some kind of routine that lives inside a class. Some languages only allow routines to be defined inside a class, in which case all algorithms live in methods. Other languages allow freestanding functions and procedures (e.g., C++, JavaScript). For coaching, method, function, procedure, and any other similar nomenclature might be used interchangeably.
A sample method from the reference code is:
public void Method1()
{
if (Method2())
{
Console.WriteLine("It happened, again.");
TimesItHappened += 1;
}
}
Signature
The unique declaration of a method or function that defines how it can be used and what it produces. For example, string PickLonger(string L, string R) tells the compiler and coder alike that there is a method, it’s name is PickLonger, it returns a string and it takes two strings named L and R, respectively.
Sample signatures from the reference code are:
void MethodA()void MethodB()bool IsSameType(Base Other)bool Method2()
Block
{
Step1();
Step2();
}
In Python, on the other hand, blocks are identified with whitespace. For instance, the following if-else structure has two blocks: one for the if and one for the else:
if (x > 9):
is_tens = true
else:
is_tens = false
A sample block from the reference code is:
{
Console.WriteLine("It happened, again.");
TimesItHappened += 1;
}
Statement
A statement is a single, coherent semantic instruction for the program to run. One way to think of it is “someplace the instruction pointer might highlight in a debugger”. In C-derived languages, statements are terminated with a ;. Others use a convention like “one statement per line”.
When someone says “select the entire statement”, they mean “select the thing you’re looking at or working on right now that is the smallest syntactic element that can stand on its own”.
Sample statements from the reference code are:
return Flag = !Flag;var X = Console.ReadKey();Console.WriteLine("Try again...");
Expression
A structure that can be evaluated to a value. For instance x in reference to a variable is an expression. m * x + B is also an expression. If your cursor is on the following line of code…
var y = m * x + B;
…and someone says “select the entire expression on the righthand side”, they are telling you to select m * x + B;
Some expressions can also be the bodies of statements.
Sample expressions from the reference code:
"It happened, again."1!FlagFlag = !Flag
Assignment
An operation that updates the value of something using something else.
In C-derived languages, the target of the assignment is on the left and the value to be assigned is on the right of an equal sign.
If someone tells you to copy the assignment in reference to the line of code x = y;, they are either telling you to copy x = y or just = y. If it’s not clear from context, ask a question to disambiguate.
Sample assignments from the reference code:
Flag = !Flag= !Flag(if someone means what one might copy and paste elsewhere for a different target)
Variable
This is a broad concept for any state that can change over time within a program. However, when it is used in coaching contexts, it is typically shorthand for local variable: a variable that only exists within the scope of a method call. It does not mean “field” or “property”, but, in some languages (e.g., C, C++).
A sample variable from the reference code is X (which is declared by way of var X).
Field
A member of a type that stores data. If someone says “field”, they probably don’t mean “variable” or “property”.
Sample fields from the reference code are:
bool Flag;int TimesItHappened;
Property
Some languages, such as C# or Swift have the concept of a class member that looks like a field but actually is a container for behavior rather than data. These are properties. When someone says “property”, they probably do not mean “field”, “variable”, or “parameter”.
A sample property from the reference code is:
public Base AsBase => this;
Parameter
One of the things that can vary about a method call. For instance, the following method has three parameters: a, b, and c:
string Combine(int a, string b, char c)
{
return b + (c + a);
}
When someone says “parameter”, they probably do not mean “variable”, “property”, or “field”.
A sample parameter from the reference code is Base Other.
Argument
The value passed in as a parameter to a method call. For instance, the third argument in the following method call is 'a':
ThatThing.Combine(4, "x", 'a');
Initializer
A blanket term for the value assigned to a variable, field, or property as part of its definition… its initial value. In C-derived languages, the initializer typically takes the form of an assignment that is built into the definition of the entity. e.g., the new() expression in the following code (C#):
public static readonly SomeType Instance = new();
A sample initializer from the reference code is = new("some content").
Righthand Side
The portion of a syntactic element that is on the right of something. For instance, in the assignment x = y + z, y + z is the righthand side.
Lefthand Side
The portion of a syntactic element that is on the left of something. For instance, in the expression x + y, x is the lefthand side.
Symbol/Identifier
Many actions in modern development environments revolve around identifiers, which we sometimes call “symbols” or “names”. In most languages these are single tokens with no spaces in them (though some languages do make allowances for spaces). They literally are the ID of a design element in that element’s name-resolution space.
Sample symbols/identifiers/names from the reference code are:
BaseChildOtherChildMethodAMethodB