Skip to content

Latest commit

 

History

History
144 lines (121 loc) · 3.89 KB

README.md

File metadata and controls

144 lines (121 loc) · 3.89 KB

ios-interview

The interview question for Rollout.io's IOS developer position

This mission, should you choose to accept it, is to build an application that fetches string condition object from REST api and displays it in a table view. After selecting a condition, the second screen appears and allows to test the string condition

Main Screen:

  • A table view with the content object from 54.173.94.129/conditions
  • The screen should show only condition names
  • Once a user clicks on a condition, the next screen should appear
  • get http://54.173.94.129/conditions will return :
[ 
  {
    name:”condition name”,
    _id:”unique id”
  }[, {}...]
]

Second Screen:

  • The screen should show 2 text fields, a button and the result label
  • When the button is clicked, the condition is tested with the two arguments from the text fields, and the result of the test appears in the result label
  • The condition is loaded via http://54.173.94.129/conditions/:id:
{ 
  name:”condition name”, 
  _id:"unique id”, 
  condition: <ConditionData>, 
} 
  • The input fields are 2 text fields (The condition is only for NSString - to reduce complexity)

Notes:

  • Don’t worry about UI at all, it doesn’t have to look good
  • The condition parser design is important
  • It should easily support adding new operators
  • It is very important to understand the schemas here, and how conditions are constructed, check out the examples

Schemas:

ConditionData schema:

{ 
   // op decralres the type of the condition:
  "op": "eq" | "and" | "or" | "ne" | "containsString",
  
  // The arguments of the operators, it can be a value and argument or another condition depending on the op
  // When the op is "eq" the args can be Value or Argument - [arg1 isEqual @"something"] 
  // When the op is "and" the args must be ConditionData - condition1 && condition2 && condition3
  "args": [ <ConditionData> | <Value> | <Argument > ] 
}

Value Schema:

{
  "type": "string",
  "data": <String> // e.g. “just some text"
}

Argument Schema:

{
  "type": "argument",
  "argumentNumber": 1|2 // the actual argument 
}

Example 1

  • The Condition:

    [arg1 isEqual:@"rollout.io"]

  • In pesudocode it looks like this:

    equals(arg1, “rollout.io”)

  • The model will look like this:

    { 
      "name":"first example - simple eq operator",
      "_id":"1", 
      "condition": {
    	    "op": "eq", 
    	    "args":  [{ "type": "argument", "argumentNumber": 1}, {"type": "string", "value": "rollout.io"}]
      }
    }
 
__Example 2__
 - The Condition:
	
	```[arg1 isEqual: @"rollout.io"] && [arg1 containsString: @"ro"]```
 - In pesudocode it looks like this:
	
	```and(equals(arg1, @"rollout.io"), constainsString(arg1, @"ro"))```
 
- The fetched model will look like this:
```javascript
{ 
	"name":"second example - and operator", 
	"_id":"1", 
	"condition": {
		"op": "and",
		"args": [{
				"op": "ne",
				"args": [{ "type": "argument", "argumentNumber":1}, {"type": "string", "value": "rollout.io"}]
			},{
				"op": "containsString",
				"args": [{ "type": "argument", "argumentNumber":1}, {"type": "string", "value": "ro"}]
			}
		],
	}
}

Example 3

  • The condition:

    [arg1 isEqual: @"rollout.io"] && [arg2 isEqual: @"control your production"]

  • In pesudocode it looks like this:

    and(equals(arg1, "rollout.io"), equals(arg2, @"control your production")

  • The fetched model will look like this:

{ 
  "name":"third example - 2 arguments", 
  "_id":"1", 
  "condition": {
    "op": "and", 
    "args": [{
      "op": "eq",
      "args": [{ "type": "argument", "argumentNumber":1}, {"type": "string", "value": "rollout.io"}]
    },{
      "op": "eq",
      "args": [{ "type": "argument", "argumentNumber":2}, {"type": "string", "value": "control your production"}]
    }],
  }
}