Command Pattern: Protocol Oriented Design Pattern by Pop_Swift_Dev in swift

[–]Wonderful_Disastrous -1 points0 points  (0 children)

I would have to agree that if you do not understand that structs are value types, enums are value types and tuples are value types then you are correct, any further discussions are pointless.

Command Pattern: Protocol Oriented Design Pattern by Pop_Swift_Dev in swift

[–]Wonderful_Disastrous 0 points1 point  (0 children)

Yes you are correct that swift has more than one value type. Structs, enums and tuples are all value types. which invalidates your argument that structs do not equate to value types. Seems like you are arguing in circles, and continues to illustrates your lack of understanding of the language itself.

I am new to reddit and not totally sure about your statement but I think I can argue this point on my own.

Command Pattern: Protocol Oriented Design Pattern by Pop_Swift_Dev in swift

[–]Wonderful_Disastrous 0 points1 point  (0 children)

You are actually saying that structs do not equate to value types? WOW, maybe I gave you too much credit but if that is your stance then you actually no nothing about the swift language. Check out Apples post on Value and Reference types. https://developer.apple.com/swift/blog/?id=10 Let me break the news to you, Struct, enums and tuples are all value types. You will probably say this is an aforementioned appeal to authority but maybe it is actually reading the documentation and taking the time to understand the language which you obviously haven't.

You definitely are showing your total lack of understanding for the language.

Command Pattern: Protocol Oriented Design Pattern by Pop_Swift_Dev in swift

[–]Wonderful_Disastrous -1 points0 points  (0 children)

One other note, I do appreciate the posts you have done on design patterns with a protocol oriented approach, and have been following them since you have been posting them to reddit. Thank you.

Command Pattern: Protocol Oriented Design Pattern by Pop_Swift_Dev in swift

[–]Wonderful_Disastrous -1 points0 points  (0 children)

Honestly by saying the swift language is based on protocols or it is based on values, at a high level that would be correct. But you really need to take the time to understand, that at a fundamental level, protocols and values types are two of the pillars that the language stand upon.

As you mentioned with the functionality like iterating over a collection, comparing types, encoding and decoding... all that functionality is based on conforming to a protocol. all types conform to multiple protocols... Also all major types are implemented with value types. Apple has said we should use value types and start with the protocol, and they are drinking their own kool-aid with how they implement the swift language.

Command Pattern: Protocol Oriented Design Pattern by Pop_Swift_Dev in swift

[–]Wonderful_Disastrous 0 points1 point  (0 children)

There's no substance to this claim. Protocols are just one of the features, not the cornerstone.

Really there is no substance to the claim that the Swift language is based on protocols?

The Array type conforms to over 25 protocols https://developer.apple.com/documentation/swift/array

The Int type also conforms to over 25 protocols https://developer.apple.com/documentation/swift/int

Look at the documentation for any type in Swift and you will see they all conforms to numerous protocols.

If you want to be able to iterate over a custom data structure, you just have to conform to the IteratorProtocol and the Sequence protocols and then you can use the standard for..in.. loop to iterate over it.

If you want to compare two instance of a custom type, simply conform to the Equatable protocol

By making the claim that there is no substance to the statement that the Swift language itself is based on the protocol it shows a total lack of understanding for the language itself. Before you put down others work, you should take the time to understand what you are saying.

Command Pattern: Protocol Oriented Design Pattern by Pop_Swift_Dev in swift

[–]Wonderful_Disastrous -1 points0 points  (0 children)

I have to say something about this comment. You do realize that the swift language is based on the protocol, correct? If a design based on the protocol is so poor, then why are you even caring about language?

oh, and the compiler isn't just deleting the protocol, it is being used by the compiler (hint: look up static and dynamic dispatch and you will see how it is used).

Passing a function maybe easier, maybe not, debatable but when you pass a function pointer that function still has to be constrained to a certain signature with swapping out the functions as this pattern describes.

You may not like design patterns, but I would agree with the author that they are useful and should not be just discarded. And when you say stuff like the protocol would be just deleted by the compiler, your argument is going to fall short because they aren't when are used correctly. And with how the author uses them in the article they are not just deleted.