Git Product home page Git Product logo

containers's Introduction

Containers

What you find here is a programming exercise in Swift, the coolest new language in town.

The purpose of this exercise is to learn how some of the eXtreme Programming practices translate to Swift. We'll be using tools like Quick and Nimble and you'll learn how to overcome certain Swift challenges such as using C libraries in Swift.

You'll need a Mac with Xcode 7.0.1.

Preparations

Start by forking this repository and cloning it to your Mac.

Make sure that you open the .xcworkspace file with Xcode, because if you just open the .xcodeproj file instead you'll miss some dependencies.

Run the tests (keyboard shortcut: โŒ˜U), and see that you have one succeeding test.

The exercise

You have just been hired by a small container port to create software for their latest automatic crane. The crane comes with a state-of-the-art C interface that allows you to raise and lower shipping containers. You can find it in the Crane.c file. Every container has a unique id that must be passed to the crane when raising or lowering that container.

The software that you write is responsible for maintaining a stack of shipping containers. It ought to be able to:

  • raise a container on top of the stack
  • lower a container from the top of the stack
  • inspect whether a stack is empty or not

You'll work by first creating a test and making sure it fails. Next you'll implement the least amount of code to make the test pass. Then you refactor until you do not know how to improve the code any more. And only then are you allowed to create the next test. In other words, you'll be practising the art of Test Driven Development.

Make sure that during this exercise you commit early and often. Making small commits will help you backtrack in case something goes awry, and helps you to analyse what you did later on.

Shipping Containers

The challenge

When you've completed the exercise above, we have an additional challenge for you. Three shipping companies have supplied Swift classes to represent their shipping containers. Your job is to ensure that shipping containers for all three shipping containers can be stacked.

Unfortunately these companies couldn't agree on a common base class, so you'll have to find a way to deal with that. Preferably without using typecasts. Oh, and you're not allowed to change the shipping container classes.

You can find the shipping container classes in ContainerBrands.swift file in the brands branch of this repository.

Advanced challenge

If that was not enough for you, we have more! There is also a Fast Crane that was implemented in Objective-C. This will give you whole new worlds of pain. Your assignment is to implement the classes in the branch fast_crane, specifically FastCrane.m and Container.swift. Of course you need to do this in a test-driven fashion as well.

Wrap-up

We hope that you enjoyed this exercise. Feel free to share your experience at our wiki.

Mark & Stefan

containers's People

Contributors

markspanbroek avatar

Watchers

 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.