|
Hi all, I have a question that I’ve struggled to find a sensible answer. A bit of history ..When developing an application, my approach (rightly or wrongly) is to separate the logic into a Framework (SquadKit, BingoKit, WorkoutKit etc.) The problem ..because I like the logic in a separate framework .. I have introduced a complexity in terms of access modifiers (Public, Internal, Private) for classes, structs, enums, methods, properties. What I have most trouble with is properties (and properties of Entities in particular) So for a framework, I would much rather return a Protocol describing the interface of an Entity We have been encouraged down the route of naming Protocols according to a behaviour .. however, QuestionSo my question is this .. what should I be naming my Entity (assuming it conforms to a commonly known as Protocol) ? Idea 1: Use underscoring within the framework (my most likely approach)
Idea 2: Don’t use protocols, but use computed properties instead (not preferred)
Idea 3: Don’t use protocols, because you're the only consumer then trust yourself and make everything public 🤪
What do you think ?.. is my thought-process completely wrong ? .. have you got ideas on this ? |
|
I think if you are not creating super big and dont plan to use the modules elsewhere then it does not make much sense to spend so much time on this. As for the protocols question I am usually just using |
|
Hi @nemecek-filip Thank you for your reply. • Yes, maybe I'm over thinking the need for Framework as Logic , but I do like the structure and discipline it gives me • In terms of framework
consumer of framework
As a consumer, I would expect to be interacting with a I'm very grateful for your time and replying .. but this wouldn't be good for me. |
|
Why not go with |
|
Hi @roosterboy, Yeah, I had previously thought of I'm also going to have a look at some of Apple's open-source code and maybe see how they do it. Thank you for your reply .. I really do appriciate the discussion |
|
For what it's worth, I discovered protocols somewhat by accident recently while trying to figure out how to write a system for a game where combat could take place between two PCs or a PC and a a monster (both of which have nuanced profiles and behaviors that discourage using the same class for both). I went ahead and created a As far as naming goes, I went with something that explicitly and concisely explained the purpose served by the Protocol, in a manner resembling any other class name. Looking at other protocols in common use (e.g. |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.