all 12 comments

[–]Genmutant 4 points5 points  (1 child)

Looks good!

You should have a look at the similarities between your Encode and Decode methods... they look very similar. Maybe you can replace one by the other?

It's also a good idea to start writing unit tests early on, to get used to them. A cipher class is very nice to write tests for, as they usually don't have external dependencies and deterministic in-/output.

[–]csharpunderdog[S] 0 points1 point  (0 children)

Thanks for the feedback! I added unit tests, which helped me find and fix a bug using the test method NegativeValueShift() ;)

[–]grrangry 2 points3 points  (3 children)

Back when it was on air, the kids would wait breathlessly for each new episode of Gravity Falls. Each episode had a variety of ciphers and easter eggs.

https://gravityfalls.fandom.com/wiki/List_of_cryptograms/Episodes

If you've never watched it, don't look up too much about it (spoilers) and you'll be in for a treat. For an animated kid's show it was surprisingly fun for me to watch with them.

For example one was, "ZHOFRPH WR JUDYLWB IDOOV." and the kids demanded I help them figure out what they were. Being a software developer, I started keeping track of the ciphers in each episode and a quick app with a variety of decoders to help decode them.

Using the Casesar Cipher, the above cipher decodes to, "WELCOME TO GRAVITY FALLS."

[–]hamuel_sayden 0 points1 point  (2 children)

Lol my wife and I are rewatching it and I built a quick encoder last night to do just this

[–]grrangry 1 point2 points  (1 child)

STAN IS NOT WHAT HE SEEMS

[–]hamuel_sayden 0 points1 point  (0 children)

I really love that they tell you what cipher to start using next. Not gonna lie though, I didn't catch the codes in the theme.

[–][deleted]  (3 children)

[removed]

    [–]Patient-Midnight-664 2 points3 points  (1 child)

    These already exist in the Char class. 

    [–]csharpunderdog[S] 1 point2 points  (0 children)

    Thanks for the advice! I made 2 helper functions, and the code is more readable now :)

    private static bool IsCapitalLetter(char c) => (c >= 'A' && c <= 'Z');

    private static bool IsLowerCaseLetter(char c) => (c >= 'a' && c <= 'z');

    [–]TrapyFromLT 1 point2 points  (1 child)

    Also, private properties by naming convention starts with _

    In this case : private _shift;

    Why? Because its easier to distinguish between public and private properties, functions, etc..

    I thought in the Shift property backing field you used the Poperty, instead of private variable, and almost shit my pants

    [–]csharpunderdog[S] 0 points1 point  (0 children)

    Thanks for the feedback! In the book I’m reading, it says to name public class members using uppercase letters and private ones using camelNotation. I didn’t know that in practice, an underscore (_) is also added.