Unit 2- Program Design Strategies Flashcards

1
Q

Top-down design vs bottom-up design

A

Top-down design starts with the broad vision and breaks it down into smaller, more manageable parts, while Bottom-up design starts with the small details and builds them up into a larger system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Local scope?

A

Local scope in C# refers to variables or functions that are declared within a specific block, such as a method or loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Global scope?

A

Global scope, on the other hand, refers to variables or functions that are declared outside of any block or function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

These variables are only accessible within that block, and cannot be accessed outside of it. For example, if a variable is declared within a method, it can only be accessed within that method, and any attempt to access it from outside the method will result in an error.
THIS IS?

A

LOCAL VARIABLE/SCOPE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

These variables can be accessed and modified from anywhere within the program, including within functions and blocks. ……… variables are often used to store information that needs to be shared between different parts of the program.

A

GLOBAL VARIABLE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Using global variables can sometimes lead to issues such as naming conflicts, where…

A

a variable with the same name is declared in different parts of the program, or unintended modification of variables by different parts of the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

To avoid these issues, it is generally best practice to limit the use of global variables and instead use local variables whenever possible.

A

DUE TO THE NAME CONFLICTS ASSOCIATED WITH GLOBAL VARIABLES

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

DIFFERENCE BETWEEN LOCAL AND GLOBAL SCOPE

A

local scope in C# refers to variables or functions that are only accessible within a specific block, while global scope refers to variables or functions that can be accessed from anywhere within the class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

PRIVATE AND PUBLIC ACCESS MODIFIERS

A

the private access modifier limits access to only within the class, while the public access modifier allows access from anywhere in the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Modularity

A

refers to the process of breaking down a large program into smaller, more manageable, and reusable modules or components.

Each module is designed to perform a specific task or set of tasks, and can be used independently or in combination with other modules to create a complete program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

IIST some importance of modularity within C# environment

A

Maintainability
Reusability
Scalability
Encapsulation
Debugging IS EASIER
Develop applications more rapidly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Reuse OF Code

A

This can help to save time and effort, and also ensures consistency across projects. For example, a module that handles input validation can be reused in multiple applications, rather than having to rewrite that code for each project.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Debugging

A

By breaking code into smaller, more manageable modules, developers can isolate and identify problems more quickly.

Modules are typically designed to perform specific tasks, so any issues that arise can be more easily traced back to the relevant module.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Develop Applications

A

By breaking a large application into smaller modules, developers can work on different parts of the application simultaneously. This can help to speed up the development process, as multiple team members can work on different modules at the same time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Main method?

A

This is the entry point of the program and serves as the control center. It prompts the user for input, calls other methods to handle user input and perform calculations, and displays the result to the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Parameter passing?

A

Parameter passing: The methods in this program use parameters to pass data between them.

For example, the GetNumberFromUser method takes a string message as a parameter, which is used to prompt the user for input.

17
Q

Method calling?

A

Method calling: In the Main method, we call other methods to perform specific tasks.

For example, we call the GetNumberFromUser method to get the first and second numbers from the user, and the GetOperationFromUser method to get the operation to perform.

18
Q

Called methods?

A

The GetNumberFromUser, GetOperationFromUser, and Calculate methods are examples of called methods. These methods are designed to perform a specific task and are called by other methods in the program to perform that task.

19
Q

the Main method.

A

his makes them global in scope, meaning they can be accessed by any other method within the program. By doing this, we can share data between different methods and perform calculations with ease.

20
Q

HOW DO WE CALL A METHOD?

A

To call a method in C#, you need to specify the name of the method followed by parentheses, with any required arguments (if any) inside the parentheses.

21
Q

public void SayHello(string name)
{
Console.WriteLine(“Hello, “ + name + “!”);
}

// Call the SayHello method
SayHello(“John”);

A

In this example, we have a method called SayHello that takes a string parameter name and outputs a greeting message to the console. To call this method, we simply write SayHello(“John”), where “John” is the argument we pass to the method.

22
Q

public class MyClass
{
public static void SayHello(string name)
{
Console.WriteLine(“Hello, “ + name + “!”);
}
}

public class Program
{
static void Main(string[] args)
{
// Call the SayHello method from MyClass
MyClass.SayHello(“John”);
}
}

A

In this example, we have a class called MyClass that contains a static method called SayHello.

To call this method from the Program class, we use the syntax MyClass.SayHello(“John”).

The MyClass part specifies the class name, and the SayHello part specifies the method name.