Skip to main content
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 ...
Rick Davin's user avatar
  • 6,360
3 votes
Accepted

Text based dispachment and processment

Just top down a few things that I noticed... assuming you can use C# 7. "(?<message>.{2})(\\(?<parameter>[^\\]{2,}))*" all messages contain ...
t3chb0t's user avatar
  • 44.3k
3 votes
Accepted

Binary protocol variability V2.0

If you have various devices, any chance you'll get a different endianness? If there's any chance of that, create your own class and override the read methods for the reader so you can switch ...
Peter4499's user avatar
  • 196
3 votes

Binary protocol variability

A couple of comments: Your approach to "mapping" is rather unconventional IMHO. If you simply used a Dictionary<int, Type>, you would have much less lines of ...
vgru's user avatar
  • 1,388
3 votes

Binary protocol variability

I dont like the method ProtocolReader.Write that logs a value and return them. IMHO that makes the code harder to read. For instance compare: ...
JanDotNet's user avatar
  • 8,538
2 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. ...
Martin R's user avatar
  • 23.3k
2 votes
Accepted

View controllers and delegation for a weightlifting app in Swift

For me it's a bit misleading that you have CalculationFormula all over the place. I'd create an extra model or struct to handle the formula logic or just hold the ...
Marc's user avatar
  • 136
2 votes

Swift inheritance versus composition

The Protocol + Delegate method is a standard pattern in Cocoa/Cocoa Touch programming, and is used by Apple in many ways (i.e., NSTableViewControllerDeleagte, NSFetchedResultsControllerDelegate, ...
Graystripe's user avatar
2 votes

Binary protocol variability V2.0

EventReader A method following the TryXXX pattern should never throw an exception. So if either Tokenizer is ...
Heslacher's user avatar
  • 50.4k
2 votes
Accepted

Wrapping messages into common header, ANSI C

Here are some thoughts on how to improve this code. Provide complete compilable code for review When the code is missing many pieces, as with this question, it makes it more difficult for reviewers ...
Edward's user avatar
  • 66.5k
2 votes
Accepted

Network protocol using TCP, sending images through sockets

One comment about the recv function: you should check that you indeed received the complete request/reply. For blocking sockets, recv will indeed block until some ...
Tob Ernack's user avatar
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 ...
proxpero's user avatar
  • 121
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 ...
black_pearl's user avatar
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: ...
Martin R's user avatar
  • 23.3k
2 votes

Internet Protocol Version 4 Datagram - Checksum Calculator

In addition of @Rick-Davin, too broad method names : GetInternetChecksum and IsValidChecksum and ...
iSR5's user avatar
  • 5,328
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 ...
qwerty's user avatar
  • 121
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 ...
Martin R's user avatar
  • 23.3k
1 vote
Accepted

Timeout thrower using multithreading

The Timeout class doesn't solve the problem you have If you write: ...
G. Sliepen's user avatar
  • 58.3k
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 ...
JDługosz's user avatar
  • 11.4k
1 vote

Simple protocol client library

for ...
alx - recommends codidact's user avatar
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 ...
Richard Neumann's user avatar
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 ...
MrJre's user avatar
  • 131
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 ...
malhal's user avatar
  • 111
1 vote

View controllers and delegation for a weightlifting app in Swift

Here are the changes I ended up making. I abandoned the idea of using an enum for the formulas. I already had the formulas as NSManagedObjects and now I know how to get what I need with those. I also ...
Jim's user avatar
  • 185
1 vote
Accepted

Binary protocol variability

public class CommandReader A public class with a public constructor which is acting on a passed in argument (here ProtocolReader reader) should check if the used ...
Heslacher's user avatar
  • 50.4k

Only top scored, non community-wiki answers of a minimum length are eligible