Skip to content

Commit d063727

Browse files
committed
Improvements (yeah!)
1 parent 9d3f8eb commit d063727

File tree

7 files changed

+20
-26
lines changed

7 files changed

+20
-26
lines changed

Design-Patterns.playground.zip

-25 Bytes
Binary file not shown.

Design-Patterns.playground/section-16.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class ThieveryCorporationPersonDisplay{
2+
23
var name:String?
34
let font:String
45

Design-Patterns.playground/section-2.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class SingletonClass {
22
class var shared : SingletonClass {
3+
34
struct Static {
45
static let instance : SingletonClass = SingletonClass()
56
}

Design-Patterns.playground/section-20.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
let DEFAULT_POINT_BASE = 2.0
22
let DEFAULT_POINT_POLARIZATION = false
33

4-
class NotSoSimplePointConverter
5-
{
6-
func pointFrom(#x:Double,y:Double,z:Double,base:Double,negative:Bool) -> Point
7-
{
4+
class NotSoSimplePointConverter{
5+
6+
class func pointFrom(#x:Double,y:Double,z:Double,base:Double,negative:Bool) -> Point{
7+
88
var point = Point{
99
$0.x = (x*base) * (negative ? -1.0 : 1.0)
1010
$0.y = (y*base) * (negative ? -1.0 : 1.0)
@@ -17,11 +17,9 @@ class NotSoSimplePointConverter
1717

1818
class OhSoSimplePointConverter{
1919

20-
func standarizedXYZFrom(#x:Double,y:Double,z:Double) -> (x:Double!,y:Double!,z:Double!){
21-
22-
let notSimple = NotSoSimplePointConverter()
20+
class func standarizedXYZFrom(#x:Double,y:Double,z:Double) -> (x:Double!,y:Double!,z:Double!){
2321

24-
var pointCalculated = notSimple.pointFrom(x:x,y:y,z:z,base:DEFAULT_POINT_BASE,negative:!DEFAULT_POINT_POLARIZATION)
22+
var pointCalculated = NotSoSimplePointConverter.pointFrom(x:x,y:y,z:z,base:DEFAULT_POINT_BASE,negative:!DEFAULT_POINT_POLARIZATION)
2523

2624
return (pointCalculated.x,pointCalculated.y,pointCalculated.z)
2725
}

Design-Patterns.playground/section-22.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
let simple = OhSoSimplePointConverter()
2-
3-
var tuple = simple.standarizedXYZFrom(x:1.1, y:2.2, z:3.3)
1+
var tuple = OhSoSimplePointConverter.standarizedXYZFrom(x:1.1, y:2.2, z:3.3)
42

53
tuple.x
64
tuple.y

Design-Patterns.playground/section-24.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ class Printer {
66

77
let strategy: PrintStrategy
88

9-
func printString(string:String)->String
10-
{
9+
func printString(string:String)->String{
1110
return self.strategy.printString(string);
1211
}
1312

README.markdown

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Playground generated with: [Swift Playground Builder](https://github.com/jas/swi
2121
```swift
2222
class SingletonClass {
2323
class var shared : SingletonClass {
24+
2425
struct Static {
2526
static let instance : SingletonClass = SingletonClass()
2627
}
@@ -123,6 +124,7 @@ let integer = number.integerValue()
123124

124125
```swift
125126
class ThieveryCorporationPersonDisplay{
127+
126128
var name:String?
127129
let font:String
128130

@@ -162,10 +164,10 @@ Eduardo.name = "Eduardo"
162164
let DEFAULT_POINT_BASE = 2.0
163165
let DEFAULT_POINT_POLARIZATION = false
164166

165-
class NotSoSimplePointConverter
166-
{
167-
func pointFrom(#x:Double,y:Double,z:Double,base:Double,negative:Bool) -> Point
168-
{
167+
class NotSoSimplePointConverter{
168+
169+
class func pointFrom(#x:Double,y:Double,z:Double,base:Double,negative:Bool) -> Point{
170+
169171
var point = Point{
170172
$0.x = (x*base) * (negative ? -1.0 : 1.0)
171173
$0.y = (y*base) * (negative ? -1.0 : 1.0)
@@ -178,11 +180,9 @@ class NotSoSimplePointConverter
178180

179181
class OhSoSimplePointConverter{
180182

181-
func standarizedXYZFrom(#x:Double,y:Double,z:Double) -> (x:Double!,y:Double!,z:Double!){
182-
183-
let notSimple = NotSoSimplePointConverter()
183+
class func standarizedXYZFrom(#x:Double,y:Double,z:Double) -> (x:Double!,y:Double!,z:Double!){
184184

185-
var pointCalculated = notSimple.pointFrom(x:x,y:y,z:z,base:DEFAULT_POINT_BASE,negative:!DEFAULT_POINT_POLARIZATION)
185+
var pointCalculated = NotSoSimplePointConverter.pointFrom(x:x,y:y,z:z,base:DEFAULT_POINT_BASE,negative:!DEFAULT_POINT_POLARIZATION)
186186

187187
return (pointCalculated.x,pointCalculated.y,pointCalculated.z)
188188
}
@@ -191,9 +191,7 @@ class OhSoSimplePointConverter{
191191
```
192192
**Usage:**
193193
```swift
194-
let simple = OhSoSimplePointConverter()
195-
196-
var tuple = simple.standarizedXYZFrom(x:1.1, y:2.2, z:3.3)
194+
var tuple = OhSoSimplePointConverter.standarizedXYZFrom(x:1.1, y:2.2, z:3.3)
197195

198196
tuple.x
199197
tuple.y
@@ -229,8 +227,7 @@ class Printer {
229227

230228
let strategy: PrintStrategy
231229

232-
func printString(string:String)->String
233-
{
230+
func printString(string:String)->String{
234231
return self.strategy.printString(string);
235232
}
236233

0 commit comments

Comments
 (0)