GithubHelp home page GithubHelp logo

Comments (24)

NextNebula avatar NextNebula commented on August 23, 2024 3

I think to be more inclusive it is better to move to a predefined example. Not all students have a work week. Maybe they do not have a job, maybe they are students that do not see their study as work, maybe they have a very irregular job, etc. It is not needed for the exercise to ask students to think about that.

An example like this should be fine: Jane has a fixed work schedule, she works 8 hours on Monday, Tuesday and Thursday. On Wednesday and Friday, Jane works 4 hours. Saturday and Sunday Jane doesn't work.

Some exercises for methods can be.

  • Write a method called RegularWorkWeek that returns the regular work week for Jane. (when a week has 7 days and begins on Sunday)
public static int[] RegularWorkWeek()
{
    throw new NotImplementedException("...");
}
  • Write a method called TotalHoursWorked that returns the total sum of hours Jane works in a week. (itterate over array and reading from array)
public static int TotalHoursWorked()
{
    var hours = WorkingHours.RegularWorkWeek();
    throw new NotImplementedException("...");
}
  • Write a method called HoursWorkedOnDay that takes in a day number and returns the amount of hours worked.
public static int HoursWorkedOnDay(int dayOfTheWeek)
{
    var hours = WorkingHours.RegularWorkWeek();
    throw new NotImplementedException("...");
}
  • Write a method called WorkWeekChanged that takes in a day number and a amount of hours work that returns a changed array using those two parameters.
public static int[] WorkWeekChanged(int dayOfTheWeek, int hoursWorked)
{
    var hours = WorkingHours.RegularWorkWeek();
    throw new NotImplementedException("...");
}

from concepts.

ErikSchierboom avatar ErikSchierboom commented on August 23, 2024 2

Write an array that represents the hours you work every day for the week (when a week has 7 days and begins on Sunday)

Yeah, I like that. So maybe we would have a stub method like this:

public static int[] RegularWorkWeek()
{
    throw new NotImplementedException("...");
}

Then we could indeed have the other methods take the hours array returned by the RegularWorkWeek method. A test would look like this:

[Fact]
public void HoursOnFriday()
{
     var hours = WorkingHours.RegularWorkWeek();
     var actual = WorkingHours.OnFriday(hours);
     Assert.Equal(8, actual);
}

Note that we'd have to use different hours in the array to force a correct implementation, but I feel like this could work.

One small note: we should try to make things use the least amount of math. So I feel the sum of hours (TotalHoursWorked) is fine, but I'd rather we'd not use the average.

@exercism/csharp what do you think?

from concepts.

ErikSchierboom avatar ErikSchierboom commented on August 23, 2024 1

@MarkusReynolds1989 It might be easier to review if you were to create a (draft) PR. Could you do that?

from concepts.

ErikSchierboom avatar ErikSchierboom commented on August 23, 2024 1

I put null because I want to make sure that the students are learning to test for edge cases.

I see, but I'd rather prefer having a separate exercise for error handling an a separate one for dealing with null's (we could even teach the fancy C# 8 nullable features).

The downside of that approach would be require a dependency on enums for this exercise.

Yeah, and the enums exercise currently requires some more advanced Concepts (generics and out parameters). So that might not be the best of options unfortunately :( An alternative would be to simplify the enums exercise.

I think overall them writing their own array would probably be a better fit.

Yeah, we can enforce this by having a method that will return an array. Students will then be forced to write an array.

from concepts.

ErikSchierboom avatar ErikSchierboom commented on August 23, 2024 1

I think so. Are the above comments clear?

from concepts.

ErikSchierboom avatar ErikSchierboom commented on August 23, 2024 1

There is an open PR that creates an array exercise for JavaScript. It might be convenient to port that exercise instead of having to come up with everything ourselves, as much of the groundwork in that exercise can be re-used for a C# exercise (the theme/context), instructions, etc. For an example on how to do a port of an existing exercise, see this video. The JS exercise would need so minor changes, for example arrays in C# have a fixed length and don't in JavaScript, but we can work with that I think.

@MarkusReynolds1989 what do you think? Are you still interested in working on this exercise?

from concepts.

MarkusReynolds1989 avatar MarkusReynolds1989 commented on August 23, 2024

I'll open up that other issue but I'll go ahead and work on this too.
Would you please assign this to me?

from concepts.

MarkusReynolds1989 avatar MarkusReynolds1989 commented on August 23, 2024

https://github.com/markusreynolds1989-fork/v3/tree/arrays/languages/csharp/concept-exercises/arrays
I have some initial concepts in Arrays.cs

from concepts.

ErikSchierboom avatar ErikSchierboom commented on August 23, 2024

@MarkusReynolds1989 Done. I'll look at the initial concepts tomorrow

from concepts.

MarkusReynolds1989 avatar MarkusReynolds1989 commented on August 23, 2024

So in my mind the input of the methods is either the static array that we can provide or null. I put null because I want to make sure that the students are learning to test for edge cases. We could change this to where the student writes their own array, and we could have them make up their own hours worked for the week and then adjust the tests to fit that pretty easily. I think overall them writing their own array would probably be a better fit.

from concepts.

robkeim avatar robkeim commented on August 23, 2024

Cool stuff @MarkusReynolds1989!

If we're looking to demonstrate array access as well, maybe we could have a method:

public int GetHoursWorkedPerDay(DayOfWeek dayOfWeek)

The downside of that approach would be require a dependency on enums for this exercise. If we want to avoid enums, we could always have the day of the week be an int passed and then you'd have a simple index after checking for out of bounds values.

from concepts.

MarkusReynolds1989 avatar MarkusReynolds1989 commented on August 23, 2024

I put null because I want to make sure that the students are learning to test for edge cases.

I see, but I'd rather prefer having a separate exercise for error handling an a separate one for dealing with null's (we could even teach the fancy C# 8 nullable features).

The downside of that approach would be require a dependency on enums for this exercise.

Yeah, and the enums exercise currently requires some more advanced Concepts (generics and out parameters). So that might not be the best of options unfortunately :( An alternative would be to simplify the enums exercise.

I think overall them writing their own array would probably be a better fit.

Yeah, we can enforce this by having a method that will return an array. Students will then be forced to write an array.

Ah okay, then we can do away with all empty input tests and just really focus on testing the array the student writes and the other methods.
How about this:
Write an array that represents the hours you work every day for the week (when a week has 7 days and begins on Sunday)

int[] hoursPerDay = int[]{0,8,8,8,8,8,0};

then they write that array and the methods to operate on it, such as sum of hours, avg hours, and the index of the 2nd most hours worked or amount of hours worked on Friday.

from concepts.

MarkusReynolds1989 avatar MarkusReynolds1989 commented on August 23, 2024

I'm opening the floor to anyone with more method ideas to thoroughly test the array the student writes out.
I like finding the sum and the index. What about a method that finds the first day where the most hours were worked? They could do that with a for loop with just using the built in Array.Sort -> .Reverse and getting the index of the first result.

from concepts.

ErikSchierboom avatar ErikSchierboom commented on August 23, 2024

What about a method that finds the first day where the most hours were worked? They could do that with a for loop with just using the built in Array.Sort -> .Reverse and getting the index of the first result.

I like that! Really nice.

from concepts.

batibot323 avatar batibot323 commented on August 23, 2024

I'm opening the floor to anyone with more method ideas to thoroughly test the array the student writes out.

What about a method that would return a new array containing minutes worked instead of hours? That could be the next step after implementing the TotalHoursWorked(), to practice iterating over an array.

We can also test the use of .Length and making another array from an existing one by requiring to return an array that would only display Monday-Friday. This would be a step up from the HoursOnFriday() method.

from concepts.

ErikSchierboom avatar ErikSchierboom commented on August 23, 2024

@EarthlingRich Great suggestions!

from concepts.

robkeim avatar robkeim commented on August 23, 2024

I really like the conversion to minutes worked because that tests iteration and forces the student to create a new array. Another way to test creating a new array would be to return a "sub" array of only the days during the week, or only the weekend days.

On small nit regarding the first day of the week, I think it makes sense to follow ISO-8601 and start the on Monday instead of Sunday:
https://en.wikipedia.org/wiki/ISO_8601

from concepts.

NextNebula avatar NextNebula commented on August 23, 2024

I agree with the starting on Monday, makes more sense for where I live. It is good to follow a standard. But we should keep stating when the week starts, because this differs per area.

The conversion in minutes sounds like a good exercise for students to create a new array.

from concepts.

robkeim avatar robkeim commented on August 23, 2024

But we should keep stating when the week starts, because this differs per area.

Yes, we'll definitely need to do that in any case

from concepts.

ErikSchierboom avatar ErikSchierboom commented on August 23, 2024

BTW With #663 opened, we could consider depending on the enums-basic Concept for this exercise, to allow use of the WeekDay enum. Another option would be for the dates exercise to depend on the enums-basic Concept and then use one of the date-based enumerations (e.g. WeekDay).

from concepts.

MarkusReynolds1989 avatar MarkusReynolds1989 commented on August 23, 2024

Are we ready for me to write a new version of this based on what we discussed?

from concepts.

MarkusReynolds1989 avatar MarkusReynolds1989 commented on August 23, 2024

There is an open PR that creates an array exercise for JavaScript. It might be convenient to port that exercise instead of having to come up with everything ourselves, as much of the groundwork in that exercise can be re-used for a C# exercise (the theme/context), instructions, etc. For an example on how to do a port of an existing exercise, see this video. The JS exercise would need so minor changes, for example arrays in C# have a fixed length and don't in JavaScript, but we can work with that I think.

@MarkusReynolds1989 what do you think? Are you still interested in working on this exercise?

Hey Erik,
I'll go ahead and just work on porting that exercise then, if there's a great example no reason to reinvent the wheel. I'll watch the video and work on that some time today.

from concepts.

ErikSchierboom avatar ErikSchierboom commented on August 23, 2024

Awesome! This video is also a great one to watch.

from concepts.

ErikSchierboom avatar ErikSchierboom commented on August 23, 2024

Having looked at the JavaScript exercise, I'm thinking that might actually be a better exercise to port to the C# lists exercise, as it will remove and add items.

from concepts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.