Git Product home page Git Product logo

jobs's Introduction

Sunrise Challenges

Instructions

Create a new private GitHub repository and push your commits to it as you are completing the challenge.

Once you are ready, add someone from the Sunrise team to the repository and send an email for us to review it.

Don't hesitate to ask us questions. Displaying creativity is a bonus in all challenges.

What We Look For

Code Consistency

The code should be consistently formatted. Consistent code reduces syntax related distractions and helps us focus on the important logic. Use a code linter if necessary to help you spot these inconsistencies.

Example of Inconsistent Code:

if (a == b) {
  //
} else if (a == c)
{
  //
}
else {
  //
}

Variable Naming Clarity

We should be able to understand the logic of code blocks by reading the names of variables and functions. A clearly named variable means we won't need to look up the definition of the variable or function right away in order to understand what it does.

Example of Clear Code:

var listEvents = function(cb) {
  var tasks = [
    fetchEventsForSharedCalendars,
    fetchEventsForUserCalendars
  ];
  parallel(tasks, function(error, results) {
    if (error) {
      log.error(error);
      return cb(error);
    }

    var events = flatten(results);
    return cb(null, events);
  });
};

Useful Comments

A comment should be used in cases where the code cannot be formatted to fix clarity. The comment should allow us to skip over code blocks when looking for an overview of the code. We can come back later to the smaller bits of code to confirm they do what the comment says.

Example of Useful Comments:

for (NSNumber *timestamp in timestampArray) {
  // Create Start Date
  NSDate *startDate = [NSDate dateWithTimeIntervalSince1970:icaltime_as_timet([timestamp doubleValue])];

  // Ignore Before Earliest Date
  if ([startDate compare:earliestDate] == NSOrderedAscending) {
      continue;
  }

  // Ignore EXDATE
  BOOL isExcludedDate = NO;
  for (NSDate *excludedDate in excludedDates) {
      if ([startDate isEqualToDate:excludedDate]) {
          isExcludedDate = YES;
      }
  }
  if (isExcludedDate == YES) {
      continue;
  }

  // Ignore After Latest Date
  if ([startDate compare:latestDate] == NSOrderedDescending) {
      continue;
  }

  // Save Valid Start Date
  [datesArray addObject:startDate];
}

Unit Tests

Write unit tests for critical parts of your app. The process of writing tests for your code also reminds you of input cases that you may have missed before.

Example of Multiple Input Unit Tests:

- (void)testEncodedURLQueryString
{
    NSDictionary *dictionary = nil;

    // Should return nil on non-NSString values
    dictionary = @{@"key": [[UIView alloc] init]};
    XCTAssert([dictionary queryString] == nil);

    // Should return nil on nested values
    dictionary = @{@"key": @{@"key1": @"value1"}};
    XCTAssert([dictionary queryString] == nil);

    // Should return urlEncoded key value pairs joined with `&`
    dictionary = @{@"key#0": @"value#0", @"key#1": @"value#1"};
    XCTAssert([[dictionary queryString] isEqualToString:@"key%230=value%230&key%231=value%231"]);
}

Challenges

jobs's People

Contributors

joeydong avatar pierrevalade avatar acemtp avatar

Watchers

Ben Drucker avatar James Cloos avatar  avatar

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.