3
votes
Internet Protocol Version 4 Datagram - Checksum Calculator
This is interesting code and I'm happy it works for you in your specific usage, but on a general level I find it lacking.
For starters, you have ZERO checks to validate the input ...
3
votes
Let's play some Swift Poker
This answer is written in the spirit of New answers on old questions using new language features: The Swift language has developed considerably from Swift 1 (in 2014) to the current version Swift 5. ...
2
votes
Unit testing needs only optional methods of protocol in Swift
There are plenty of approaches that can fix your problem. But the main issue is how you build your classes. So IMHO you should focus on that.
Recommendation 1: You should build your classes with ...
2
votes
Efficiently structuring data with protocol oriented approach in Swift
Your intuition is correct: you don't need either the Resultable or the Responsable protocol. The reason is that each protocol ...
2
votes
Accepted
iOS: configuring UI appearance and layout, use protocol to extract common code
U can go forward.
To simplify the question, you can handle the top part like this
...
2
votes
Accepted
Swift protocol with lazy property requirement
You don't need the additional _footype variable and a computer “wrapper” property. The protocol requirement can be satisfied with a lazy stored property:
...
2
votes
Internet Protocol Version 4 Datagram - Checksum Calculator
In addition of @Rick-Davin,
too broad method names : GetInternetChecksum and IsValidChecksum and ...
2
votes
Accepted
Adding dragging ability to a UIView using UIKitDynamics
Comparing an optional value with nil as in
return getValue == nil ? false : getValue!
is better done with the nil-coalescing ...
1
vote
Accepted
Timeout thrower using multithreading
The Timeout class doesn't solve the problem you have
If you write:
...
1
vote
OO design for chat protocol
The problem with the Command Pattern is indeed the explosion of classes and the verbose boilerplate around each little function. That is better done today with lambda functions: the closure syntax ...
1
vote
Accepted
Classes for representing teleconferencing numbers
I think you've used the wrong abstraction here. I think that's the cause of all these switch statements.
Use Objects or structs
...
1
vote
1
vote
Accepted
Library for RCON clients
I managed to get rid of the struct module used in proto.py, after I learned that int has a ...
1
vote
Accepted
Webservice class with parser using generics
Turns out I can just use the generic ModelType defined in the ParserType, and I don't need the same generic parameter in ...
1
vote
Core-data object with relationships conforming protocol in swift
NSManagedObjects already have a property for their current context. It is weak however, which is usually ok for most cases because you would retain the context in ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
protocols × 26swift × 14
c# × 5
serialization × 3
python × 2
c++ × 2
c × 2
object-oriented × 2
design-patterns × 2
unit-testing × 2
ios × 2
objective-c × 2
delegates × 2
mocks × 2
beginner × 1
python-3.x × 1
c++11 × 1
multithreading × 1
parsing × 1
python-2.x × 1
reinventing-the-wheel × 1
json × 1
generics × 1
playing-cards × 1
socket × 1