Programming Principles – Introduction to Programming & C#

Acknowledgement of Traditional Owners

  • QUT formally recognises the Turrbal and Yugara peoples as First Nations custodians of the land on which the university is situated.
    • Respect is paid to Elders, lores, customs and creation spirits.
    • Acknowledges the land’s continuous role as a place of teaching, research and learning.
    • Reaffirms the contribution of Aboriginal and Torres Strait Islander peoples within the QUT community.

Defining Programming

  • Core guiding questions raised:
    • What exactly is programming?
    • Which models best capture its lifecycle?
    • Which paradigms guide day-to-day practice?
  • Dictionary & encyclopaedia perspectives:
    • Britannica: “A detailed plan or procedure for solving a problem with a computer.”
    • Collins: “The act or process of writing a program so that data may be processed by a computer.”
    • Cambridge: “The instructions that tell a computer what to do.”
  • Practical takeaway: Programming = synthesis of a plan, the act of codifying that plan, and the artifact (program) telling the machine what to do.

Software-Development Lifecycle (Waterfall Model)

  • Canonical sequential phases (each leads into the next; feedback minimal):
    1. Requirements – engage client, capture needs, analyse feasibility.
    2. Analysis – refine requirements, model system behaviour (e.g., UML).
    3. Design – high- & low-level architecture, choose data structures, algorithms.
    4. Implementation – actual coding (in CAB201 we use C# + OO design).
    5. Testing – unit, integration, system, acceptance.
    6. Deployment – deliver to production environment.
    7. Maintenance – ongoing fixes, enhancements; viewed humorously as “”.
  • Pre-Programming focus = requirements + analysis → understand the client problem & feasibility.
  • Programming focus = design + implementation + testing:
    • Break problems into classes & relationships (object-oriented design).
    • Implement in C#.
    • Test both classes and full system.
  • Post-Programming focus = deployment + maintenance (business value generation).

Incremental & Iterative Models

  • Both approaches overlay or replace Waterfall in modern practice.
  • Incremental
    • Decompose the large problem into smaller, deliverable increments.
    • Each increment goes through its own mini-design → implementation → testing.
    • After several increments, evaluate the integrated system.
  • Iterative
    • Continuously repeat the cycle, refining requirements/design with each pass.
    • Encourages early feedback, adaptability, risk mitigation.
  • Agile methods (e.g., Scrum) are real-world instantiations blending both.

Programming – Key Take-Home Messages

  • It is an art: involves creativity as well as engineering rigour.
  • Standard workflow:
    1. Take a real-world problem.
    2. Deconstruct it into manageable parts.
    3. Reconstruct a coherent software solution.
  • Requires simultaneous attention to:
    • Design: conceptual modelling before code.
    • Implementation: translating design into syntax-correct, efficient code.
    • Testing: assurance that solution meets requirements and behaves correctly.

Introducing C

  • Guiding questions: What type of language? How does it compare to others?
  • Essential facts:
    • Developed by Microsoft; considered “middle-aged” (initial release 2000).
    • Historically mirrors Java conceptually (sometimes dubbed “MS Java”).
    • Adopts C-style syntax (curly braces, semicolons, etc.).
  • Primary language elements:
    • Data literals (e.g., 42, "Hello").
    • Data representations – variables, parameters/arguments, fields.
    • Behaviours – operations, control-flow statements, methods.
    • Modules – classes (fundamental OO unit).

Object-Oriented Nature

  • Based on modelling real-world things (objects) & their interactions.
    • E.g., object Sally that Walks, Studies at QUT, Plays with Pepper.
  • Core OO pillars implicitly referenced: abstraction, encapsulation, inheritance, polymorphism (covered deeper in course).

High-Level Language & Compilation Pipeline

  • High-Level C# Source (developer-friendly syntax).
  • Compiler translates to Intermediate Language (IL) / Common Intermediate Language (CIL).
  • IL executes atop the .NET Framework / CLR (Common Language Runtime).
  • Just-In-Time (JIT) Compiler at runtime converts IL to native machine code for the target OS/architecture.
  • Benefits:
    • Write once; run on any platform with compatible CLR (Windows, macOS, Linux via .NET Core/5/6/7+).
    • Leverages extensive .NET class libraries → rapid development.

C# Summary Take-Home

  • C# is:
    • Object-Oriented.
    • High-Level.
    • Compiles to Intermediate Language.
    • Part of the .NET ecosystem.
  • Practical pay-offs:
    • Easier implementation of complex, high-level concepts.
    • Faster coding via frameworks/libraries.
    • Cross-platform deployment capability.

Hands-On: Your First C# Program – “Hello World”

  • IDE: Visual Studio (rich tooling, intellisense, debugger, designer, etc.).
  • Step-by-Step project creation:
    1. Launch Visual Studio.
    2. Click Create a new project.
    3. Search & select Console App template.
    4. Provide an appropriate name.
    5. Choose a directory to store the solution.
    6. Select “Do not use top-level statements” to keep classic (Main) scaffolding.
    7. Pick a relevant Framework version (e.g., 8.0).
    8. Click Create.
  • Remember to set paths correctly (ensures compilers, SDKs, dependencies resolve).

Base Template Code

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World!");
        }
    }
}

Extending the Example

  • Print multiple lines:
  Console.WriteLine("Homer Simpson");
  Console.WriteLine("36");
  Console.WriteLine("Hello, World!");
  • Concatenate strings across lines (the blurst reference):
  Console.WriteLine("it was the best of times " +
                    "it was the blurst of times");
  • Comments for documentation & code hiding:
    • Single-line: // This is a single line comment.
    • Multi-line block:
      csharp /* This is a multiline comment */
    • Temporarily disable code:
      csharp // Console.WriteLine("Hello, World!")

Ethical, Philosophical & Practical Implications

  • Respecting Indigenous custodians parallels respecting original authors when reusing code (attribution, licensing).
  • Choosing Waterfall vs. Iterative models affects stakeholder expectations, project risk and sustainability.
  • Writing maintainable, well-tested C# code aligns with professional ethics (safety, reliability).
  • Cross-platform .NET development promotes accessibility & inclusion (software availability on diverse OSes).

Numerical & Symbolic References (LaTeX Notation)

  • Literal examples: 42 (integer), 5 (loop limit), string literal "Hello World!".
  • Loop header from example: i < 5 and i++ represents i = i + 1 each iteration.
  • Waterfall phases can be enumerated 1 \to 7$$, emphasising their linear progression.

Connections to Foundational Principles

  • Decomposition (breaking problems into classes/increments) recalls top-down design from introductory computing courses.
  • Abstraction (high-level language hiding machine code) echoes early lessons on Von-Neumann architecture.
  • Compile → IL → JIT pipeline expands on previous discussion of interpreters vs. compilers.

Real-World Relevance

  • Majority of enterprise Windows applications rely on C# & .NET (finance, health, education).
  • Cross-platform mobile apps via Xamarin/Maui show industry push for one-codebase strategy.
  • Game development (Unity) primarily scripted in C#.

Summary & Next Steps

  • Programming involves iterative design-implement-test cycles, regardless of lifecycle model.
  • C# offers a modern, object-oriented, cross-platform path to implement those cycles efficiently.
  • Mastery begins with small programs (Hello World) and expands to complex systems integrating OO principles and .NET libraries.
  • Upcoming lectures will dive deeper into C# syntax, control structures, data types, error handling, and advanced OO constructs.

End of Notes – Thank You