CSC378 ยท 2078 ยท 5 marks
What is named and positional attribute parameters? Describe the .Net architecture design and principles.
What is named and positional attribute parameters? Describe the .Net architecture design and principles. [5]
Quick answer
Here, "This method is deprecated" is a positional parameter passed in order.
Named and Positional Attribute Parameters & .NET Architecture Design and Principles
Part 1: Named and Positional Attribute Parameters
From the notes, the syntax for an attribute is:
[attribute(positional_parameters, name_parameter=value, ...)]
element
Positional Parameters
- Positional parameters are the mandatory parameters of an attribute.
- They must be passed in a fixed order as defined in the attribute constructor.
- They correspond directly to the constructor arguments of the attribute class.
Example:
[Obsolete("This method is deprecated")]
public void OldMethod() { }
Named Parameters
- Named parameters are optional parameters of an attribute.
- They are specified using a name=value syntax and can be provided in any order.
- They correspond to properties or fields of the attribute class.
Example:
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
Here:
AttributeTargets.Classis the positional parameter (mandatory, in order).AllowMultiple = trueandInherited = falseare named parameters (optional, any order).
Part 2: .NET Architecture Design and Principles
.NET Architecture Overview
The layered architecture of .NET (as described in the notes) is as follows:
+------------------------------------------+
| VB.NET | C# | JScript.NET | More Languages |
+------------------------------------------+
| Common Language Specification (CLS) |
+------------------------------------------+
| Common Type System (CTS) |
+------------------------------------------+
| .NET Framework Class Library (FCL) |
+------------------------------------------+
| ASP.NET | Windows Forms | Console | ADO.NET |
| Web Forms | XML Web Services | .NET Remoting |
+------------------------------------------+
| Common Language Runtime (CLR) |
| [JIT Compilers, Security Manager, etc.] |
+------------------------------------------+
| Common Language Infrastructure (CLI) |
+------------------------------------------+
| Operating System |
+------------------------------------------+
Key Components Explained
| Component | Description |
|---|---|
| CLR (Common Language Runtime) | The heart of .NET Framework. Resides above the OS and handles all .NET applications. Manages garbage collection, Code Access Security (CAS), and memory management. |
| CLI (Common Language Infrastructure) | Provides a language-independent platform for app development. Handles exception handling, garbage collection, and security. |
| CTS (Common Type System) | Specifies a standard that defines what types of data and values can be defined and managed in memory at runtime. |
| CLS (Common Language Specification) | A subset of CTS that defines rules and regulations that every .NET language must follow to ensure interoperability. |
| FCL (Framework Class Library) | Provides system functionality including classes, interfaces, and data types to build desktop, web, and mobile applications. |
Design Principles of .NET
-
Clean Architecture: Applications following the Dependency Inversion Principle and Domain-Driven Design (DDD) are known as clean architecture. It places business logic and application model at the center.
-
MVC Pattern: Separates the application into three components:
- Model: Represents the shape/structure of data.
- View: User interface that displays model data.
- Controller: Handles user requests and manages the flow.
-
N-Tier Architecture: ASP.NET Core automatically creates a pre-defined N-tier architecture for developers, saving time and effort, and easing tier deployment.
-
Separation of Concerns: Each layer/component handles a specific responsibility, making the application maintainable and testable.
-
Language Interoperability: Through CLS and CTS, .NET supports multiple languages (C#, VB.NET, JScript.NET) that can work together seamlessly.
Summary: .NET architecture is a layered, language-independent framework where CLR acts as the execution engine, CTS/CLS ensure type safety and interoperability, and FCL provides reusable libraries. Its design principles promote clean, maintainable, and scalable application development.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.