Git Product home page Git Product logo

Comments (7)

czechboy0 avatar czechboy0 commented on July 17, 2024

The reason why everything inherits from XcodeServerEntity is because its init(json: NSDictionary) constructor parses out common fields like id, rev and tinyID. Protocols wouldn't allow for that unfortunately, but overall I agree with you that we should be aiming for a protocol-based approach wherever possible.

from xcodeserversdk.

cojoj avatar cojoj commented on July 17, 2024

Old protocols wouldn't but the new ones? I mean, now we can create extensions with default implementation - this should be a game changer.

from xcodeserversdk.

czechboy0 avatar czechboy0 commented on July 17, 2024

Sure, but the way the objects are now parsed is that the constructor takes a JSON object, pulls out the fields relevant to it and then calls super with the same objects, which does the same thing... until it reaches the XcodeServerEntity, which pulls out the above mentioned fields.

Protocol extensions enable you to only provide a default implementation for all objects conforming to a certain protocol, but AFAIK they don't support inheritance, which is exactly this case.

from xcodeserversdk.

cojoj avatar cojoj commented on July 17, 2024

Sure, with the current architecture of project it's impossible but I was rather thinking about deeper refactoring and dropping this verbose XcodeServerEntity inheritance thing. I'd probably do things similar to you but something (maybe a little Crusty in my head) is telling me that it can be resolved with different approach.

I will rethink this and If I come with any kind of solution or idea I will bring it to you! 😉

from xcodeserversdk.

czechboy0 avatar czechboy0 commented on July 17, 2024

Yeah do, thanks!

from xcodeserversdk.

cojoj avatar cojoj commented on July 17, 2024

I've came to this little article today and I wonder maybe this will be a good approach?

from xcodeserversdk.

czechboy0 avatar czechboy0 commented on July 17, 2024

Interesting, Chris mentions the library called JSONCodable, which I took a look at. Looks very useful for parsing and generating JSON into structs.

There is a couple of reasons why I don't think it would be of much benefit here, mostly because we give different names to properties and to the keys in the JSON. Plus the parsing pattern is very similar to what we're using already, with the exception that we use inheritance to parse the objects, because that's how they are treated by Xcode Server (everything has an _id and a _rev).

Let's open this if we come up with more actionable ideas.

from xcodeserversdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.