Code syntax elements in a graph

Syntax Elements Guide

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<T>;

public partial class Child<T> : Base<T>
{
  public void MethodA() { }

  public partial void MethodB();
}

public class OtherChild<T> : Base<T>
{
  readonly string Content;
  
  OtherChild(string Content)
  {
    this.Content = Content;
  }

  public static OtherChild<T> Instance { get; } = new("some content");
  
  public Base<T> AsBase => this;

  public bool IsSameType(Base<T> Other) => Other is OtherChild<T>;
}

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<T> : Base<T>
{
  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

A sequence of statements that are assembled together into a single syntactic element. In C-derived languages, the following is an example of a 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
  • !Flag
  • Flag = !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<T> 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:

  • Base
  • Child
  • OtherChild
  • MethodA
  • MethodB

Partial List

The content of this post is tuned to Producore engineering skills coaching sessions. It is not intended to be a comprehensive glossary, but it gives readers what they need to communicate effectively with a coach about code.

Get our Newsletter

Subscribe

Privacy Policy

Effective date: 1st day of January, 2023

www.producore.com (the “Site”) is owned and operated by Producore LLC. Producore LLC can be contacted at:

Phone: +1-307-226-2200
Email: [email protected]
Mailing Address: 13601 W MCMILLAN RD STE 102-277, BOISE ID 83713-2025

Purpose

The purpose of this privacy policy (this “Privacy Policy”) is to inform users of our Site of the following:

  1. The personal data we will collect;

  2. Use of collected data;

  3. Who has access to the data collected;

  4. The rights of Site users; and

  5. The Site’s cookie policy.

This Privacy Policy applies in addition to the terms and conditions of our Site.

Consent

By using our Site users agree that they consent to:

  1. The conditions set out in this Privacy Policy; and

  2. The collection, use, and retention of the data listed in this Privacy Policy.

Personal Data We Collect

We only collect data that helps us achieve the purpose set out in this Privacy Policy. We will not collect any additional data beyond the data listed below without notifying you first.

Data Collected Automatically

When you visit and use our Site, we may automatically collect and store the following information:

  1. IP address;

  2. Location;

  3. Hardware and software details;

  4. Clicked links; and

  5. Content viewed.

Data Collected in a Non-Automatic Way

We may also collect the following data when you perform certain functions on our Site:

  1. First and last name;

  2. Email address;

  3. Phone number;

  4. Address; and

  5. Payment information.

This data may be collected using the following methods:

  1. Creating an account; and

  2. Submitting an order.

How We Use Personal Data

Data collected on our Site will only be used for the purposes specified in this Privacy Policy or indicated on the relevant pages of our Site. We will not use your data beyond what we disclose in this Privacy Policy.

The data we collect automatically is used for the following purposes:

  1. Statistics for internal-use only to improve our website and our services..

The data we collect when the user performs certain functions may be used for the following purposes:

  1. Communication; and

  2. Processing payments.

Who We Share Personal Data With

Employees

We may disclose user data to any member of our organization who reasonably needs access to user data to achieve the purposes set out in this Privacy Policy.

Other Disclosures

We will not sell or share your data with other third parties, except in the following cases:

  1. If the law requires it;

  2. If it is required for any legal proceeding;

  3. To prove or protect our legal rights; and

  4. To buyers or potential buyers of this company in the event that we seek to sell the company.

If you follow hyperlinks from our Site to another Site, please note that we are not responsible for and have no control over their privacy policies and practices.

How Long We Store Personal Data

User data will be stored until the purpose the data was collected for has been achieved.

You will be notified if your data is kept for longer than this period.

How We Protect Your Personal Data

In order to protect your security, we use the strongest available browser encryption and store all of our data on servers in secure facilities. All data is only accessible to our employees. Our employees are bound by strict confidentiality agreements and a breach of this agreement would result in the employee’s termination.

While we take all reasonable precautions to ensure that user data is secure and that users are protected, there always remains the risk of harm. The Internet as a whole can be insecure at times and therefore we are unable to guarantee the security of user data beyond what is reasonably practical.

Children

We do not knowingly collect or use personal data from children under 13 years of age. If we learn that we have collected personal data from a child under 13 years of age, the personal data will be deleted as soon as possible. If a child under 13 years of age has provided us with personal data their parent or guardian may contact our privacy officer.

How to Access, Modify, Delete, or Challenge the Data Collected

If you would like to know if we have collected your personal data, how we have used your personal data, if we have disclosed your personal data and to who we disclosed your personal data, or if you would like your data to be deleted or modified in any way, please contact our privacy officer at:

[email protected]

(307) 226-2200

300 N. Center Street, Unit 6, Casper, WY 82601

Do Not Track Notice

Do Not Track (“DNT”) is a privacy preference that you can set in certain web browsers. We do not track the users of our Site over time and across third party websites and therefore do not respond to browser-initiated DNT signals.

How to Opt-Out of Data Collection, Use or Disclosure

In addition to the method(s) described in the How to Access, Modify, Delete, or Challenge the Data Collected section, we provide the following specific opt-out methods for the forms of collection, use, or disclosure of your personal data specified below:

You can opt-out of the use of your personal data for marketing emails. You can opt-out by clicking “unsubscribe” on the bottom of any marketing email or updating your email preferences under “Your Account”

Cookie Policy

A cookie is a small file, stored on a user’s hard drive by a website. Its purpose is to collect data relating to the user’s browsing habits. You can choose to be notified each time a cookie is transmitted. You can also choose to disable cookies entirely in your internet browser, but this may decrease the quality of your user experience.

We use the following types of cookies on our Site:

  1. Functional cookies are used to remember the selections you make on our Site so that your selections are saved for your next visits; and

  2. Analytical cookies allow us to improve the design and functionality of our Site by collecting data on how you access our Site, for example data on the content you access, how long you stay on our Site, etc.

Modifications

This Privacy Policy may be amended from time to time in order to maintain compliance with the law and to reflect any changes to our data collection process. When we amend this Privacy Policy we will update the “Effective Date” at the top of this Privacy Policy. We recommend that our users periodically review our Privacy Policy to ensure that they are notified of any updates. If necessary, we may notify users by email of changes to this Privacy Policy.

Contact Information

If you have any questions, concerns or complaints, you can contact our privacy officer at:

Phone: +1-307-226-2200
Email: [email protected]
Mailing Address: 13601 W MCMILLAN RD STE 102-277, BOISE ID 83713-2025

Terms & Conditions

These terms and conditions (the “Terms and Conditions”) govern the use of www.producore.com (the “Site”). This Site is owned and operated by Producore LLC.

By using this Site, you indicate that you have read and understand these Terms and Conditions and agree to abide by them at all times.

THESE TERMS AND CONDITIONS CONTAIN A DISPUTE RESOLUTION CLAUSE THAT IMPACTS YOUR RIGHTS ABOUT HOW TO RESOLVE DISPUTES. PLEASE READ IT CAREFULLY.

Intellectual Property

All content published and made available on our Site is the property of Producore LLC and the Site’s creators. This includes, but is not limited to images, text, logos, documents, downloadable files and anything that contributes to the composition of our Site.

Acceptable Use

As a user of our Site, you agree to use our Site legally, not to use our Site for illegal purposes, and not to:

  • Harass or mistreat other users of our Site;

  • Violate the rights of other users of our Site;

  • Violate the intellectual property rights of the Site owners or any third party to the Site;

  • Hack into the account of another user of the Site;

  • Act in any way that could be considered fraudulent; or

  • Post any material that may be deemed inappropriate or offensive.

If we believe you are using our Site illegally or in a manner that violates these Terms and Conditions, we reserve the right to limit, suspend or terminate your access to our Site. We also reserve the right to take any legal steps necessary to prevent you from accessing our Site.

User Contributions

Users may post the following information on our Site:

  • Public comments.

By posting publicly on our Site, you agree not to act illegally or violate these Terms and Conditions.

Accounts

When you create an account on our Site, you agree to the following:

  1. You are solely responsible for your account and the security and privacy of your account, including passwords or sensitive information attached to that account; and

  2. All personal information you provide to us through your account is up to date, accurate, and truthful and that you will update your personal information if it changes.

We reserve the right to suspend or terminate your account if you are using our Site illegally or if you violate these Terms and Conditions.

Sale of Goods And Services

These Terms and Conditions govern the sale of goods and services available on our Site.

The following goods are available on our Site:

  • Templates; and

  • Guides.

The following services are available on our Site:

  • Training courses;

  • Coaching services; and

  • Consulting services.

The services will be paid for in full when the services are ordered.

These Terms and Conditions apply to all the goods and services that are displayed on our Site at the time you access it. This includes all products listed as being out of stock. All information, descriptions, or images that we provide about our goods and services are as accurate as possible. However, we are not legally bound by such information, descriptions, or images as we cannot guarantee the accuracy of all goods and services we provide. You agree to purchase goods and services from our Site at your own risk.

We reserve the right to modify, reject or cancel your order whenever it becomes necessary. If we cancel your order and have already processed your payment, we will give you a refund equal to the amount you paid. You agree that it is your responsibility to monitor your payment instrument to verify receipt of any refund.

User Goods and Services

Our Site allows users to sell goods and services. We do not assume any responsibility for the goods and services users sell on our Site. We cannot guarantee the quality or accuracy of any goods and services sold by users on our Site. However, if we are made aware that a user is violating these Terms and Conditions, we reserve the right to suspend or prohibit the user from selling goods and services on our Site.

Subscriptions

Your subscription does not automatically renew. You will be notified before your next payment is due and must authorize that payment in order for your subscription to continue.

You may cancel your subscription anytime before the renewal date and up to 14 days after renewal.

Payments

We accept the following payment methods on our Site:

  • Credit Card;

  • Debit; and

  • Direct Debit.

When you provide us with your payment information, you authorize our use of and access to the payment instrument you have chosen to use. By providing us with your payment information, you authorize us to charge the amount due to this payment instrument.

If we believe your payment has violated any law or these Terms and Conditions, we reserve the right to cancel or reverse your transaction.

Consumer Protection Law

Where any consumer protection legislation in your jurisdiction applies and cannot be excluded, these Terms and Conditions will not limit your legal rights and remedies under that legislation. These Terms and Conditions will be read subject to the mandatory provisions of that legislation. If there is a conflict between these Terms and Conditions and that legislation, the mandatory provisions of the legislation will apply.

Limitation of Liability

Producore LLC and our directors, officers, agents, employees, subsidiaries, and affiliates will not be liable for any actions, claims, losses, damages, liabilities and expenses including legal fees from your use of the Site.

Indemnity

Except where prohibited by law, by using this Site you indemnify and hold harmless Producore LLC and our directors, officers, agents, employees, subsidiaries, and affiliates from any actions, claims, losses, damages, liabilities and expenses including legal fees arising out of your use of our Site or your violation of these Terms and Conditions.

Applicable Law

These Terms and Conditions are governed by the laws of the State of Wyoming.

Dispute Resolution

Subject to any exceptions specified in these Terms and Conditions, if you and Producore LLC are unable to resolve any dispute through informal discussion, then you and Producore LLC agree to submit the issue first before a non-binding mediator and to an arbitrator in the event that mediation fails. The decision of the arbitrator will be final and binding. Any mediator or arbitrator must be a neutral party acceptable to both you and Producore LLC. The costs of any mediation or arbitration will be shared equally between you and Producore LLC.

Notwithstanding any other provision in these Terms and Conditions, you and Producore LLC agree that you both retain the right to bring an action in small claims court and to bring an action for injunctive relief or intellectual property infringement.

Severability

If at any time any of the provisions set forth in these Terms and Conditions are found to be inconsistent or invalid under applicable laws, those provisions will be deemed void and will be removed from these Terms and Conditions. All other provisions will not be affected by the removal and the rest of these Terms and Conditions will still be considered valid.

Changes

These Terms and Conditions may be amended from time to time in order to maintain compliance with the law and to reflect any changes to the way we operate our Site and the way we expect users to behave on our Site. We will notify users by email of changes to these Terms and Conditions or post a notice on our Site.

Contact Details

Please contact us if you have any questions or concerns. Our contact details are as follows:
Phone: +1-307-226-2200
Email: [email protected]
Mailing Address: 13601 W MCMILLAN RD STE 102-277, BOISE ID 83713-2025

Effective Date

1st day of January, 2023