Category: Uncategorized

  • Guided project – Develop foreach and if-elseif-else structures to process array data in C#

    Gain experience developing a console app that implements arrays, foreach loops, and if statements to achieve app specifications.

    Learning objectives

    In this module, you’ll practice how to:

    • Use Visual Studio Code to develop a C# console application that uses foreach loops to access array data.
    • Use if statements to evaluate conditions and create code branches.

    https://lernix.com.my/big-data-hadoop-training-courses-malaysia

  • Install and configure Visual Studio Code

    Learn how to configure Visual Studio Code for C# and how to use this professional IDE to create and run console applications.

    Learning objectives

    In this module, you will:

    • Configure Visual Studio Code and your development environment for programming in C#.
    • Explore the Visual Studio Code user interface.
    • Create, edit, build, and run a console application using Visual Studio Code.

    https://lernix.com.my/blockchain-training-courses-malaysia

  • Prepare

    In this guided project, you’ll use Visual Studio Code to develop portions of a C# console application. You’ll begin by writing the code that performs various numeric calculations. All calculations must be completed within the existing iteration and selection structures. This Prepare unit provides you with the overall goals of the project and the requirements for your application. The Setup section describes how to set up your development environment, including a “Starter” code project.

     Important

    This module includes coding activities that require Visual Studio Code. You’ll need access to a development environment that has Visual Studio Code installed and configured for C# application development.

    Project specification

    The Starter code project for this module is a C# console application that implements the following code features:

    • Uses arrays to store student names and assignment scores.
    • Uses a foreach statement to iterate through the student names as an outer program loop.
    • Uses an if statement within the outer loop to identify the current student’s name and access that student’s assignment scores.
    • Uses a foreach statement within the outer loop to iterate through the assignment scores array and sum the values.
    • Uses an algorithm within the outer loop to calculate the average exam score for each student.
    • Use an if-elseif-else construct within the outer loop to evaluate the average exam score and assign a letter grade automatically.
    • Integrates extra credit scores when calculating the student’s final score and letter grade as follows:
      • Detects extra credit assignments based on the number of elements in the student’s scores array.
      • Applies a 10% weighting factor to extra credit assignments before adding extra credit scores to the sum of exam scores.

    Your goal in this challenge is to implement the coding updates required to produce the teacher’s requested score report.

    The current score report lists the student’s name followed by the calculated overall grade and letter grade. Here is the existing report format:

    OutputCopy

    Student         Grade   Letter Grade
    
    Sophia          95.6    A
    Andrew          91.6    A-
    Emma            89.2    B+
    Logan           93      A
    

    In addition to the student’s final numeric score and letter grade, the teacher wants the updated report to include the exam score and the impact that extra credit work has on the student’s final grade. The format of the updated score report should appear as follows:

    OutputCopy

    Student         Exam Score      Overall Grade   Extra Credit
    
    Sophia          92.2            95.88   A       92 (3.68 pts)
    Andrew          89.6            91.38   A-      89 (1.78 pts)
    Emma            85.6            90.94   A-      89 (5.34 pts)
    Logan           91.2            93.12   A       96 (1.92 pts)
    

    Setup

    Use the following steps to prepare for the Challenge project exercises:

    1. To download a zip file containing the Starter project code, select the following link: Lab Files.
    2. Unzip the download files.Unzip the files in your development environment. Consider using your PC as your development environment so that you have access to your code after completing this module. If you aren’t using your PC as your development environment, you can unzip the files in a sandbox or hosted environment.
      1. On your local machine, navigate to your downloads folder.
      2. Right-click Challenge-project-foreach-if-array-CSharp-main.zip, and then select Extract all.
      3. Select Show extracted files when complete, and then select Extract.
      4. Make note of the extracted folder location.
    3. Copy the extracted ChallengeProject folder to your Windows Desktop folder. NoteIf a folder named ChallengeProject already exists, you can select Replace the files in the destination to complete the copy operation.
    4. Open the new ChallengeProject folder in Visual Studio Code.
      1. Open Visual Studio Code in your development environment.
      2. In Visual Studio Code, on the File menu, select Open Folder.
      3. Navigate to the Windows Desktop folder and locate the “ChallengeProject” folder.
      4. Select ChallengeProject and then select Select Folder.The Visual Studio Code EXPLORER view should show the ChallengeProject folder and two subfolders named Final and Starter.

    https://lernix.com.my/ibm-aix-system-i-training-courses-malaysia

  • Review the solution to the improve code readability challenge activity

    The following code is one possible solution for the challenge from the previous unit.

    c#Copy

    /*
       This code reverses a message, counts the number of times 
       a particular character appears, then prints the results
       to the console window.
     */
    
    string originalMessage = "The quick brown fox jumps over the lazy dog.";
    
    char[] message = originalMessage.ToCharArray();
    Array.Reverse(message);
    
    int letterCount = 0;
    
    foreach (char letter in message)
    {
        if (letter == 'o')
        {
            letterCount++;
        }
    }
    
    string newMessage = new String(message);
    
    Console.WriteLine(newMessage);
    Console.WriteLine($"'o' appears {letterCount} times.");
    

    This code is merely “one possible solution“. You may have come up with some different variable names and different vertical spacing and tab indentation. Here’s a list of changes that were made.

    • The code includes a higher-level description of what the entire code listing is attempting to accomplish in a multi-line comment at the top. You could argue that this is a small improvement over the original code comments, however, given the challenge’s description of the code, there wasn’t much more context available.
    • The individual comments were removed because they weren’t providing any real insight into the code’s purpose or function.
    • Several blank lines were added to improve the phrasing of the code listing. Keep code lines together when they appear similar, or when they work with each other to accomplish a small task.
    • Line feeds and tabs were added to improve the appearance of the foreach statement and the if statement.
    • Local variable naming conventions were applied to better convey the purpose of each value.

    If you identified the same issues and addressed them in a similar way, congratulations! Continue on to the knowledge check in the next unit.

    https://lernix.com.my/ibm-cognos-bi-training-courses-malaysia

  • Choose variable names that follow rules and conventions

    A software developer once famously said, “The hardest part of software development is naming things.” Not only does the name of a variable have to follow certain syntax rules, it should also be used to make the code more human-readable and understandable. That’s a lot to ask of one line of code!

    Variable name rules

    There are some variable naming rules that are enforced by the C# compiler.

    • Variable names can contain alphanumeric characters and the underscore (_) character. Special characters like the pound #, the dash -, and the dollar sign $ are not allowed.
    • Variable names must begin with an alphabetical letter or an underscore, not a number. Using an underscore character to start a variable name is typically reserved for private instance fields. A link to further reading can be found in the module summary.
    • Variable names must NOT be a C# keyword. For example, these variable name declarations won’t be allowed: float float; or string string;.
    • Variable names are case-sensitive, meaning that string MyValue; and string myValue; are two different variables.

    Variable name conventions

    Conventions are suggestions that are agreed upon by the software development community. While you’re free to decide not to follow these conventions, they’re so popular that it might make it difficult for other developers to understand your code. You should practice adopting these conventions and make them part of your own coding habits.

    • Variable names should use camel case, which is a style of writing that uses a lower-case letter at the beginning of the first word and an upper-case letter at the beginning of each subsequent word. For example: string thisIsCamelCase;.
    • Variable names should be descriptive and meaningful in your application. You should choose a name for your variable that represents the kind of data it will hold (not the data type). For example: bool orderComplete;, NOT bool isComplete;.
    • Variable names should be one or more entire words appended together. Don’t use contractions because the name of the variable may be unclear to others who are reading your code. For example: decimal orderAmount;, NOT decimal odrAmt;.
    • Variable names shouldn’t include the data type of the variable. You might see some advice to use a style like string strMyValue;. It was a popular style years ago. However, most developers don’t follow this advice anymore and there are good reasons not to use it.

    The example string firstName; follows all of these rules and conventions, assuming you want to use this variable to store data that represents someone’s first name.

    Variable name examples

    Here’s a few examples of variable declarations (using common data types):

    c#Copy

    char userOption;
    
    int gameScore;
    
    float particlesPerMillion;
    
    bool processedCustomer;
    

    Other naming conventions

    The rules and conventions described above are for local variables. A local variable is a variable that is scoped within the body of a method, or a variable in a console application that uses top-level statements (like the code in this module).

    There are other types of constructs that you can use in your applications, and many have their own conventions. For example, classes are often used in C# programming, and have associated conventions. Although you won’t be creating classes in this module, it’s important for you to know that the naming conventions you just learned about fit into a larger naming framework.

    https://lernix.com.my/ibm-informix-training-courses-malaysia

  • Get started with .NET Libraries

    There’s more to building a C# application than stringing together lines of code. You’ll need the .NET Runtime, which hosts and manages your code as it executes on the end user’s computer. You’ll also rely on the .NET Class Library, a prewritten collection of coding resources that you can use in your applications. This unit explains what the .NET Class Library is and how it complements the C# programming language.

    What is the .NET Class Library?

    When you need to find a book, a public library is a good place to look. After all, libraries contain thousands and thousands of books, and they’re organized into sections that help you to find what you’re looking for. When you need to implement a programming task, the .NET Class Library is a good place to look, because it’s an organized collection of programming resources.

    The .NET Class Library is a collection of thousands of classes containing tens of thousands of methods. For example, the .NET Class Library includes the Console class for developers working on console applications. The Console class includes methods for input and output operations such as Write()WriteLine()Read()ReadLine(), and many others. For example, you may already be familiar with the following code:

    C#Copy

    Console.WriteLine("Hello, World!")
    

    You can think of a class as a container for methods, kind of like the sections of the public library. Developers typically keep related methods together in a single class. As you saw in the previous example, any methods that can send or receive information from a console window are collected into the System.Console class in the .NET Class Library.

    In many cases, these classes and methods enable you to build a specific type of application. For example, one of the larger subsets of classes and methods enable you to create dynamic web applications. There’s also several families of classes that enable you to build native desktop applications. Another subset of classes and methods enable you to access a database. There are lots of classes in the .NET Class Library that support specific types of applications.

    There are other classes with methods that provide support in a more general way. In other words, their utility spans a wide range of device platforms, application frameworks, and technology areas. For example, if you want to read or write file information, or perform trigonometry or calculus operations, there are general purpose classes that you can use in your code. It doesn’t matter whether you’re building applications for the web, desktop, mobile device, or the cloud, general purpose classes and methods are there to help.

    As you can imagine, having a massive library of functionality available to your applications is a huge time saver for you as a software developer. The classes and methods in the .NET Class Library are created by Microsoft and are available for use in your applications.

    Even data types are part of the .NET Class Library

    C# data types (such as string and int) are actually made available through classes in the .NET Class Library. The C# language masks the connection between the data types and the .NET classes in order to simplify your work. However, behind the scenes, the data types are implemented just like every other class in the .NET Class Library. This connection provides your everyday variables with built-in methods that can be very helpful. The string class has lots of these helpful methods. For example, the string class has methods for converting text to uppercase and lowercase (ToUpper and ToLower).

    How to find what you need in the .NET Class Library

    With so many classes and methods, how can you find what you need for your application?

    First of all, remember that finding every class and method in the .NET Class Library is like finding every book in a large public library. You don’t need every book in the library, and you won’t be using every class and method in the .NET Class Library. Depending on the types of projects that you work on, you’ll become more familiar with some parts of the .NET Class Library and less familiar with others. Again, it’s like spending time in a section of the public library, over time you become familiar with what’s available. No one knows all of the .NET Class Library, not even people that work at Microsoft.

    Second, necessity will drive you to what you need. Most people go to the library when they need to find a book, not to see how many different books they can find. You don’t need to research classes and methods without a reason. When you have trouble figuring out a programming task, you can use your favorite search engine to find blog posts, articles, or forums where other developers have worked through similar issues. Third-party sources can give you clues about which .NET classes and methods you might want to use, and you may even find sample code that you can try.

    Third, Microsoft provides an online language reference and programming guide for C# that you can search through. You’ll likely spend time reading Microsoft’s documentation when you need to understand exactly what methods do, how they work, and their limitations. This documentation will become your source of truth for the .NET Class Library. Microsoft’s documentation team works closely with the .NET Class Library’s software developers to ensure its accuracy.

    Finally, as you begin to experiment with small code projects you’ll deepen your understanding of how the classes and methods work.

    All software developers follow a similar process when stepping into unfamiliar territory. The process of discovery is enjoyable, albeit challenging.

    Recap

    • The .NET Class Library supplies you with a wealth of functionality that you can use by merely referencing the classes and methods that you need.
    • Even your data types are part of the .NET Class Library. C# merely provides an alias for those data types.

    https://lernix.com.my/ibm-informix-training-courses-malaysia

  • Prepare for guided project

    You’ll be using the .NET Editor as your code development environment. You’ll be writing code that uses string and numeric variables, performs calculations, then formats and displays the results to a console.

    Project overview

    You’re developing a Student GPA Calculator that will help calculate students’ overall Grade Point Average. The parameters for your application are:

    • You’re given the student’s name and class information.
    • Each class has a name, the student’s grade, and the number of credit hours for that class.
    • Your application needs to perform basic math operations to calculate the GPA for the given student.
    • Your application needs to output/display the student’s name, class information, and GPA.

    To calculate the GPA:

    • Multiply the grade value for a course by the number of credit hours for that course.
    • Do this for each course, then add these results together.
    • Divide the resulting sum by the total number of credit hours.

    You’re provided with the following sample of a student’s course information and GPA:

    OutputCopy

    Student: Sophia Johnson
    
    Course          Grade   Credit Hours	
    English 101         4       3
    Algebra 101         3       3
    Biology 101         3       4
    Computer Science I  3       4
    Psychology 101      4       3
    
    Final GPA:          3.35
    

    Setup

    Use the following steps to prepare for the Guided project exercises:

    1. Open the .NET Editor coding environment.
    2. Copy and paste the following code into the .NET Editor. These values represent the student’s name and course details.C#Copystring studentName = "Sophia Johnson"; string course1Name = "English 101"; string course2Name = "Algebra 101"; string course3Name = "Biology 101"; string course4Name = "Computer Science I"; string course5Name = "Psychology 101"; int course1Credit = 3; int course2Credit = 3; int course3Credit = 4; int course4Credit = 4; int course5Credit = 3;

    Now you’re ready to begin the Guided project exercises. Good luck!

    https://lernix.com.my/ibm-infosphere-datastage-training-courses-malaysia

  • Complete the challenge to convert Fahrenheit to Celsius

    In this challenge, you’ll write code that will use a formula to convert a temperature from degrees Fahrenheit to Celsius. You’ll print the result in a formatted message to the user.

    Challenge: Calculate Celsius given the current temperature in Fahrenheit

    1. Select all of the code in the .NET Editor, and press Delete or Backspace to delete it.
    2. Enter the following code in the .NET Editor:C#Copyint fahrenheit = 94;
    3. To convert temperatures in degrees Fahrenheit to Celsius, first subtract 32, then multiply by five ninths (5 / 9).
    4. Display the result of the temperature conversion in a formatted messageCombine the variables with literal strings passed into a series of Console.WriteLine() commands to form the complete message.
    5. When you’re finished, the message should resemble the following output:OutputCopyThe temperature is 34.444444444444444444444444447 Celsius.

    https://lernix.com.my/ibm-lotus-notes-domino-datastage-training-courses-malaysia

  • Monitor and optimize over time

    What was important yesterday might not be important today. As you learn more from running workloads in production, expect changes. Your setup, business needs, workflows, and even your team might shift. You might need to tweak how you build and release software. External factors might also change, like the cloud platform, its resources, and your agreements.

    Keep an eye on how changes affect your costs. Check in regularly to see if your return on investment (ROI) is trending in the right direction, and adjust your goals or requirements if needed.

    Example scenario

    Contoso Air provides a baggage tracking solution for airlines. The workload is hosted in Azure and runs on Azure Kubernetes Service (AKS) with Azure Cosmos DB for its database and uses Azure Event Hubs for messaging. The workload is deployed in both the West US and East US regions.

    Track and monitor your spending

    Use a cost tracking system to regularly review how much you’re spending on resources, data, and support. If you have underused resources, think about shutting them down, replacing them, or reworking them to be more efficient.

    Understanding where your money goes is the first step to controlling it. By tagging resources, classifying expenses, and setting up alerts, you can track spending across teams, services, and environments.

    This visibility helps you catch unexpected charges early, support showback or chargeback models, and make smarter decisions about where to cut or invest.

    Contoso’s challenge

    • The workload team has always stayed under budget, so reducing costs hasn’t been a focus.
    • But next year, they’re planning to boost the workload’s reliability, which means higher Azure costs. That could push them over budget, so they’re thinking about asking for a bigger budget to cover it.

    Applying the approach and outcomes

    • Before the team asks for more budget, they decide to take a closer look at their current Azure and support costs to see if there’s any room to save. They dig into the cost breakdowns by resource, resource group, and tags by using their cost tracking system. They find unexpected spending.
    • The team finds some virtual machines (VMs) still running that were used for an old build system that they don’t need anymore. There’s also old data sitting in Azure Storage that could be moved to a cheaper tier. On top of that, they’re paying for a support contract that includes consulting hours, but they haven’t been using them.
    • The team optimizes their Azure costs by deleting the unused VMs and moving the old data to Archive storage. They begin working more closely with their cloud provider to make good use of their consulting services.
    • They add a recurring task to their backlog to regularly review and optimize their workload costs going forward.

    Tune your workload continuously

    Continuously adjust architecture design decisions, resources, code, and workflows based on ROI data.

    Cloud environments evolve, and so should your architecture. Review your metrics, performance, billing, and feature usage regularly. You might find small tweaks that save money and make things run smoother. Even small adjustments can add up to big savings over time.

    Contoso’s challenge

    • Since the team has stayed under budget historically, they haven’t looked at other ways to do things. Instead, most of their planning focused on building new features.
    • But after finding waste during their first cost review, they decided to take a closer look at the rest of their setup to find more ways to optimize.

    Applying the approach and outcomes

    • The team realizes that they’re putting too many resources into low-priority flows. They can scale back on the throughput without disrupting performance. Instead of over-preparing for peak times, they’ll switch to a queue-based load leveling system.
    • They also notice that their compute platform now includes a new feature in their chosen SKU that replaces some of the authentication code. Using this feature means less code to maintain and test.

    Optimize your cloud environment continuously

    Make it a habit to regularly check for unused resources or old data in your cloud setup and remove them. Over time, these components that were once useful can stick around and quietly accrue costs. Keep your environment optimized to help keep things efficient and save money.

    Shutting down resources that you’re not using and deleting data that you don’t need frees up budget for more important work.

    Contoso’s challenge

    • Over the past year, the team created several temporary environments for testing new features and running performance experiments. Many of these environments were never cleaned up.
    • They discovered multiple Event Hubs namespaces and Azure Cosmos DB containers that haven’t received any traffic in months but are still incurring storage and throughput costs.
    • Old baggage tracking data from previous airline partners is still stored in hot-access tiers, even though it’s no longer needed for operations or compliance.
    • The team lacks a regular process for identifying and removing unused resources, so clutter continues to build up unnoticed.

    Applying the approach and outcomes

    • The team sets up a monthly cleanup routine that includes tagging resources with expiration dates and reviewing usage metrics to flag idle services.
    • They decommission unused AKS node pools, delete inactive Event Hubs, and consolidate Azure Cosmos DB containers where possible.
    • For historical baggage data, they implement lifecycle policies to automatically archive or delete data based on age and access patterns.
    • They also review their resource SKUs and downgrade services that are over-provisioned.
    • These actions help them reduce unnecessary spend, improve operational efficiency, and keep their cloud environment clean and manageable.

    https://lernix.com.my/ibm-websphere-training-courses-malaysia

  • Design for rate optimization

    You don’t always need to redesign or renegotiate to save money. Sometimes, you can make better use of what you already have. If you don’t optimize existing resources and operations, you could be wasting money without seeing any real benefit.

    Example scenario

    Contoso’s business intelligence (BI) team hosts a suite of GraphQL APIs so that different departments can access data without touching the databases directly. Over time, they’ve added versioning and now run everything through a single Azure API Management gateway on the Consumption tier.

    Three Azure Kubernetes Service (AKS) clusters are behind the API Management instances:

    • One runs a Windows node pool for APIs written in .NET 4.5.
    • One Linux cluster for the APIs written in Java Spring.
    • One runs a Windows node pool for APIs written in .NET Core on Linux. They inherited this cluster from a prior team.

    These clusters are only used for the APIs and are now all managed by the BI team. It’s not the cleanest setup, but it works, so they’ve left it alone.

    The BI team is a cost center in the business, so they’re looking for ways to optimize its rates to drive down operating costs.

    Combine infrastructure where it makes sense

    Try to run things in the same place, whether it’s resources, workloads, or teams. Use services that help you pack more into less space. Consider any trade-offs, especially around security.

    When you pack more utility into fewer systems, you use less hardware and spend less on managing it all. That means lower costs and less complexity.

    Contoso’s challenge

    • Contoso’s team followed the Microsoft AKS baseline architecture. They run three clusters that each have three system nodes, so nine nodes total.
    • They apply patches and updates to all clusters three times every month.

    Applying the approach and outcomes

    • After the team does testing, they decide to combine all the APIs into a single cluster with three user node pools while achieving the same performance and OS characteristics of their original cluster.
    • They also consolidate to four nodes for their system node pool, saving the costs of five virtual machines.
    • Now they only have one cluster to patch and update, which saves even more time.
    • Next, they’re looking at merging two Linux node pools into one to make things even simpler.

    Take advantage of reservations and other infrastructure discounts

    Optimize by committing and prepurchasing to take advantage of discounts offered on resource types that aren’t expected to change over time and for which costs and utilization are predictable. Also, work with your licensing team to influence future purchase agreement programs and renewals.

    Microsoft offers reduced rates for predictable and long-term commitment to specific resources and resource categories. Resources cost less during the usage period and can be amortized over the period.

    By keeping your licensing team aware of the current and predicted investment by resource, you can help them rightsize commitments when your organization signs the agreement. In some cases, these projections and commitments could influence your organization’s price sheet, which benefits your workload’s cost and also other teams that use the same technology.

    Contoso’s challenge

    • Now that the team has consolidated onto one cluster, removing some of the excess compute and operational burden they previously absorbed, they’re interested in finding additional measures to lower the cost of the cluster.
    • Because the BI team is happy with the AKS platform, they plan on continuing to use it for the foreseeable future, and likely will even grow its usage.

    Applying the approach and outcomes

    • Because AKS is built on top of Azure Virtual Machine Scale Sets, the team looks into Azure reservations. They know the expected SKUs and scale units they need for the user nodes.
    • They purchase a three-year reservation that covers the system node pool and the minimum instance count of nodes per user node pool.
    • With this purchase, the team knows they’re getting the best deal on their compute needs while allowing the workload to grow over time.

    Use fixed-price billing when practical

    Switch to fixed-price billing instead of consumption-based billing for a resource when its utilization is high and predictable and a comparable SKU or billing option is available.

    When utilization is high and predictable, the fixed-price model usually costs less and often supports more features. Using it could increase your ROI.

    Contoso’s challenge

    • The API Management instances are all deployed as Consumption tier SKUs currently. After evaluating the APIs’ usage patterns, they understand that the APIs are used globally and sometimes quite heavily. The team decides to analyze the cost differences between the current billing model and a fixed-price model.

    Applying the approach and outcomes

    • After performing the cost analysis, the team finds that migrating from Consumption to Standard tier will be a bit less expensive overall given the current usage patterns. As the services grow over the next year, the cost differences will likely become more pronounced. Even though the fixed-pricing model doesn’t reflect the elasticity characteristics of the requests, sometimes prepurchased billing models are the right choice.
    • As an added bonus, using the Standard tier allows the use of a private endpoint for inbound connections, which the team has been eager to implement for the workload.
    • In this case, switching SKUs made sense for both utilization purposes and for the added benefit of the additional network segmentation that’s possible with a private endpoint implementation.

    https://lernix.com.my/iot-internet-of-things-training-courses-malaysia