32
Root
4y

I forgot what it was like to have a productive day!

I’m rewriting the Apple wallet pass code to make it fully customizable instead of mostly static, and it’s beautiful.

The code was horrible tangled spaghetti before (and soo slow) but now it’s clean and fast and modular and absolute bliss to spec. Yay, dependency injection!

I actually had fun working today! 😊
It’s been the first time in months.

Comments
  • 1
    :) Congratulations. Already in the new house?
  • 0
    @IntrusionCM 😅 Still a month away
  • 0
    May I ask what language and how do you achieve dependency injection. I'm curious about the topic
  • 1
    @Axel406 she's the fairy of ruby and rails
  • 1
    @Axel406 Ruby on Rails.

    I have a WalletPass model that belongs_to the Order model so I can reference it by name from anywhere in the model. (Literally by just `order`)

    The wallet pass methods I’m writing accept an optional order object (which defaults to the associated order). This way I can pass in nothing at a and have it operate on the associated order, or in specs I can mock an order and pass that into the method to have it operate on data from that order.

    I also broke up the monolithic “generate_wallet_json” method into multiple that generate each piece, and ones that generate larger chunks. This way I can very easily add a new wallet pass type that includes different fields. That all follow the order injection pattern so I can spec them all in the same way without needing to generate the entire wallet pass for every spec.

    This makes it sound fancy, but it’s really just a simple defaulted parameter. 🤷🏻‍♀️
  • 1
    @Root still it turned me on. Platonic. Non sexual. But aroused. *rawr*
  • 0
    @Root interesting, dependency injection topic is new to me.
    I'm developing an app with JavaFX, MVC pattern and I had this problem where a module needs a service from another module. I did some research on what are the best practices and I learned about Spring framework for dependency injection.
    To be honest I didn't try it, maybe I will someday because it looks really cool, I ended up using the Service Locator pattern, I have a singleton class that stores the needed instances of View and Model
  • 1
    @Axel406 Young you are.

    Learn you must.

    Let guide be failure.

    Yoda aside. A start.

    I'd recommend to learn the basic principles without a framework. It will grt you a better understanding of how things _could_ cooperate together. It's very hard to understand this in a full fledged framework.

    Many times, patterns built upon shared ideas / principles and just evolved in different things
Add Comment