My Microsoft LEAP Apprenticeship Program Journey — Au Revoir Classroom Training, Hello Field Work.

Michelle Aniuchi
6 min readFeb 27, 2020
Photo by Romain V on Unsplash

As with all good things, the classroom training had to come to an end. The brief but power and knowledge packed 4-week stint eventually came to a halt about 3 weeks ago after which we were released into the field to use what we have learned so far. Monday the 10th of February marked the beginning of that new phase in this journey.

Meeting up with the team and getting to learn about some of the interesting projects they’re working on got me tingling with excitement about the prospects to grow and opportunities to apply what I’ve been able to absorb so far.

However, in this article, I’ll like to give brief recap of all we did in those four weeks and special points I picked:

Introduction to C#

Typing

C# is a strongly typed language and coming from a JS background, it can be pretty odd to work with at first but once you get a hang of it, it’s pretty sweet! What do I mean by strongly typed? Your variables are bound to a specific data type and will result in type errors if types do not match up as expected in the expression. So when you’re creating your variables, you have to specifically (explicitly) state what data type you’ll want to store in those variables. For example, I want to create a variable x, that stores the number '5'. In C#, I’ll have to declared and initialize it thus:int x = 5.

Data Types

I also got to learn some new data types found to the C# language — the enum and the struct(structure) — to be precise.

1. For the struct, it’s a user defined data type. It’s used to group items of different (or similar) types into one type. These items are usually related in some way. For example, you could create a structure struct called Movie in which we have a string type variable called name, an string variable called genre and a double variable called price all grouped together in a single type — a Movie type. It‘s a value type.

2. An enum is a value data type that is used to declare a list of named integer constants. Now its easy to define a data type but in what scenario would you want to make use of an enum and what are its benefits? Well consider you have a subscription-based system that keeps track of different types of subscriptions you might have such as Weekly, Monthly and Annually. You could declare an enum type called SubscriptionType thus:

public enum SubscriptionType {
Weekly = 1,
Monthly = 2,
Annually = 3
}

In your project, perhaps you have a database with a the following tables:

// TABLE CUSTOMERS
Id(PK) | Name | SubscriptionType(FK)(Id from Subscription Table)
1 | Customer1 | 2
1 | Customer2 | 3
1 | Customer3 | 1
1 | Customer4 | 2
1 | Customer5 | 3
// Table Subscription
Id(PK) | Name
1 | Weekly
2 | Monthly
3 | Annually

As you can see from the table there are numbers (ids) assigned to each subscription type. For each customer, there is a SubscriptionType corresponding to an ID on the Subscription table. So Customer1 is on a Weekly subscription type. Now say in your code, you want to carry out some action (say give a discount) based on if the customer’s SubscriptionType is Annually which has an Id of 3 in our example. You might write something like this:

// If the customer's SubscriptionType is equal to 3
if(customer.SubscriptionType == 3) {
// give discount
}

‘2’ in the code above can be referred to as a “magic number.” When another developer comes along to update this code or read it, they aren’t going to understand what ‘3’ means. If you need to change the subscription type, how do you know what number to place in the if statement? This is where the benefit and usefulness of enums comes in. So you could use that enum declared earlier in the code above like this:

// If the customer's SubscriptionType is equal to 3
if(customer.SubscriptionType == SubscriptionType.Annually) {
// give discount
}

So in order words, you can use enums to eliminate magic numbers in your code thus making your code explicit and easy to read. This in itself is a best practice. Pretty cool huh?

Data Structures

I also got to learn about a host of built in data structures like the LinkedList, Arrays, Stacks, Queues and List. I think the point I picked from this part of the class training is you almost always should use a List and I am beginning to see it as I work on projects with the team

Azure DevOps

I got introduced to a pretty amazing Microsoft product — Azure DevOps. It’s a multifaceted product that covers the entire software application development life cycle from requirements gathering to release and enables DevOps capabilities. Not only does it provide project management capabilities for a software application development project, it also provides version control, reporting, requirements management, automated builds, lab management, testing and release management capabilities. Awesome right? I was awed too.

It also allows you to chose what project management methodology you want to go with and you can even customize it for your own specialized agile methodologies you want.

I got to learn how to create projects, assign tasks to team members, move items around the boards. I also got to work with the version controlling feature using git control flow and also build pipelines for automated deployment.

Introduction to MSSQL and LINQ

Last but not the lease, I got to work with MSSQL. Prior to this time, I had worked with MySQL and PostgreSQL so the discussions were not foreign to me. LINQ — Language Integrated Query — however was a different ball game. It was a whole new world.

Basically LINQ allows you to query different data sources using a uniformed query syntax which looks similar to how C# code is written. In order words, querying capabilities are integrated directly into the C# language and theset technologies based on this integration is called LINQ. As opposed to writing, SQL statements explicitly to retrieve items from your database, you can use LINQ to do this just as easily.

LINQ isn’t just for SQL Server Database querying though. It can be used to query lists, arrays and other collection of objects that support the an IEnumerable or the generic IEnumerable<T> interface as well as XML documents, ADO.NET Datasets.

Examples:

  1. Using LINQ with an array
class LINQQueryExpressions1
{
static void Main()
{
// Specify the data source.
int[] age= new int[] { 97, 92, 81, 60, 11, 20 };
// Define the query expression.
IEnumerable<int> ageQuery =
from age in age
where age > 20
select age;
// Execute the query.
foreach (int i in ageQuery)
{
Console.Write(i + " ");
}
}
}
// Output: 97 92 81 60

2. Using LINQ with Entity Framework from an SQL Server Database

----
class LINQQueryExpressions2
{
static void Main()
{
using (var context = new SchoolDBEntities())
{
var query = from st in context.Students
where st.StudentName == "Bill"
select st;

var student = query.FirstOrDefault<Student>();
}
}
}
//returns a row where studentName is bill or returns null if it //doesn't exist in the db

N.B: A LINQ query that returns a sequence of values like the first example above is not is not executed until until the query variable is iterated over in a foreach or For Each loop. The query variable itself never holds the query results and only stores the query commands. This is called deferred execution. In order words, query execution occurs some time after the query is constructed. To force execution of a query, you can call the ToList(), ToDictionary() or the ToArray() methods on the query or query variable.

The second example on the other hand is a query that returns a singleton value and these type of queries are executed immediately. This is called immediate execution. They execute immediately because the query must produce a sequence to calculate the singleton result. Some examples of such singleton queries are Count(), Max(), FirstOrDefault(), First(), LastOrDefault(), Sum(), Average() etc.

This brings me to the end of my summary of the four (4) week class training. It took me almost three weeks to complete this after starting and getting stuck at some point deciding what to include and what not to include so that it doesn’t drag on (and it looks like it probably did in spite of my best efforts and I’m sorry).

However, I really hope you enjoyed reading this. If you did please share with your friends and don’t forget to leave a ‘clap’ (or more) for me. Thank you.

Till next time.

--

--